Добавил команду подписи apk файла
This commit is contained in:
parent
53edc99ad9
commit
4939004dca
|
|
@ -0,0 +1,30 @@
|
|||
from commands.CleanBuildCommands.SignApkCommand import SignApkCommand
|
||||
from parsers.SignApkParser import SignApkParser
|
||||
|
||||
|
||||
class SignApkCommandBuilder:
|
||||
def __init__(self, pathToBuildUtil):
|
||||
assert pathToBuildUtil is not None
|
||||
|
||||
self.pathToBuildUtil = pathToBuildUtil
|
||||
|
||||
def isSignApk(self, line):
|
||||
assert line is not None
|
||||
|
||||
parser = SignApkParser()
|
||||
isValid = parser.isValidLine(line)
|
||||
|
||||
return isValid
|
||||
|
||||
def getCommandFor(self, line):
|
||||
assert line is not None
|
||||
|
||||
parser = SignApkParser()
|
||||
result = parser.parseLine(line)
|
||||
|
||||
slnPath = result[0]
|
||||
slnConfig = result[1]
|
||||
projectName = result[2]
|
||||
|
||||
command = SignApkCommand(self.pathToBuildUtil, slnPath, slnConfig, projectName)
|
||||
return command
|
||||
|
|
@ -11,6 +11,7 @@ from CommandBuilders.PatchManifestCommandBuilder import PatchManifestCommandBuil
|
|||
from CommandBuilders.RemoveProjectCommandBuilder import RemoveProjectCommandBuilder
|
||||
from CommandBuilders.RestoreBackupCommandBuilder import RestoreBackupCommandBuilder
|
||||
from CommandBuilders.ShCommandBuilder import ShCommandBuilder
|
||||
from CommandBuilders.SignApkBuilder import SignApkCommandBuilder
|
||||
from CommandBuilders.TestflightCommandBuilder import TestflightCommandBuilder
|
||||
|
||||
|
||||
|
|
@ -42,6 +43,7 @@ class StepsRunner:
|
|||
buildUtilPath = config['build_tool']
|
||||
self.cleanBuilder = CleanBuildCommandBuilder(buildUtilPath, 'clean')
|
||||
self.buildBuilder = CleanBuildCommandBuilder(buildUtilPath, 'build')
|
||||
self.signAndroid = SignApkCommandBuilder(buildUtilPath)
|
||||
|
||||
def run(self, content):
|
||||
assert content is not None
|
||||
|
|
@ -64,6 +66,8 @@ class StepsRunner:
|
|||
cmd = self.cleanBuilder.getCommandFor(line)
|
||||
elif self.buildBuilder.isCleanBuild(line):
|
||||
cmd = self.buildBuilder.getCommandFor(line)
|
||||
elif self.signAndroid.isSignApk(line):
|
||||
cmd = self.signAndroid.getCommandFor(line)
|
||||
elif self.createBackupBuilder.isCreateBackup(line):
|
||||
cmd = self.createBackupBuilder.getCommandFor(line)
|
||||
elif self.createDirs.isMakeDirsCommand(line):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
from commands.ShellCommandBase import ShellCommandBase
|
||||
|
||||
|
||||
class SignApkCommand(ShellCommandBase):
|
||||
def __init__(self, pathToBuildUtil, slnPath, slnConfig, projectName):
|
||||
ShellCommandBase.__init__(self)
|
||||
|
||||
assert pathToBuildUtil is not None
|
||||
assert slnPath is not None
|
||||
assert slnConfig is not None
|
||||
assert projectName is not None
|
||||
|
||||
self.pathToBuildUtil = pathToBuildUtil
|
||||
self.slnPath = slnPath
|
||||
self.slnConfig = slnConfig
|
||||
self.projectName = projectName
|
||||
|
||||
self.commandPattern = '%(mdtool) -v build "--configuration:%(config)" "--project:%(project)" /t:SignAndroidPackage "%(slnPath)"'
|
||||
|
||||
def execute(self):
|
||||
cmdText = self.commandPattern % {
|
||||
'mdtool': self.pathToBuildUtil,
|
||||
'config': self.slnConfig,
|
||||
'project': self.projectName,
|
||||
'slnPath': self.slnPath
|
||||
}
|
||||
|
||||
self.executeShell(cmdText)
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import re
|
||||
from parsers.LineParser import LineParser
|
||||
from parsers.RegexpBuilder import RegexpBuilder
|
||||
|
||||
|
||||
class SignApkParser(LineParser):
|
||||
def __init__(self):
|
||||
LineParser.__init__(self)
|
||||
|
||||
def parseLine(self, line):
|
||||
assert line is not None
|
||||
|
||||
filePathRegexp = r"'(?P<path>[./ a-zA-Z]+\.sln)'"
|
||||
slnConfigRegexp = r"'(?P<config>[a-zA-Z|]+)'"
|
||||
projectRegexp = r"(?P<project>[.a-zA-Z]+)$"
|
||||
|
||||
rb = RegexpBuilder()
|
||||
rSrc = rb.startsWith('sign') + rb.than('android') + filePathRegexp + rb.keywordToken('for') + slnConfigRegexp +\
|
||||
rb.keywordToken('project') + projectRegexp
|
||||
regexp = re.compile(rSrc, re.UNICODE)
|
||||
|
||||
match = regexp.match(line)
|
||||
self._guardMatch(match, line, rSrc)
|
||||
|
||||
path = match.group('path')
|
||||
slnConfig = match.group('config')
|
||||
project = match.group('project')
|
||||
|
||||
return path, slnConfig, project
|
||||
|
||||
def isValidLine(self, line):
|
||||
assert line is not None
|
||||
|
||||
rb = RegexpBuilder()
|
||||
rSrc = rb.startsWith('sign') + rb.than('android')
|
||||
|
||||
regexp = re.compile(rSrc, re.UNICODE)
|
||||
match = regexp.match(line)
|
||||
|
||||
return match is not None
|
||||
Loading…
Reference in New Issue