Merge branch 'build-command'
This commit is contained in:
commit
f4e70b0f8d
|
|
@ -0,0 +1,44 @@
|
|||
from commands.CleanBuildCommands.BuildCommand import BuildCommand
|
||||
from commands.CleanBuildCommands.CleanCommand import CleanCommand
|
||||
from parser.CleanBuildParser.CleanBuildParser import CleanBuildParser
|
||||
|
||||
|
||||
class CleanBuildCommandBuilder:
|
||||
def __init__(self, pathToBuildUtil, commandToken):
|
||||
assert pathToBuildUtil is not None
|
||||
assert commandToken is not None
|
||||
|
||||
self.__pathToBuildUtil = pathToBuildUtil
|
||||
self.__commandToken = commandToken
|
||||
|
||||
def isCleanBuild(self, line):
|
||||
assert line is not None
|
||||
|
||||
parser = CleanBuildParser(self.__commandToken)
|
||||
isValid = parser.isValidLine(line)
|
||||
|
||||
return isValid
|
||||
|
||||
def getCommandFor(self, line):
|
||||
assert line is not None
|
||||
|
||||
parser = CleanBuildParser(self.__commandToken)
|
||||
result = parser.parseLine(line)
|
||||
|
||||
slnPath = result[0]
|
||||
slnConf = result[1]
|
||||
|
||||
command = self.__getCommandByToken(slnPath, slnConf)
|
||||
return command
|
||||
|
||||
def __getCommandByToken(self, slnPath, slnConfig):
|
||||
command = None
|
||||
|
||||
if self.__commandToken == 'clean':
|
||||
command = CleanCommand(self.__pathToBuildUtil, slnPath, slnConfig)
|
||||
elif self.__commandToken == 'build':
|
||||
command = BuildCommand(self.__pathToBuildUtil, slnPath, slnConfig)
|
||||
else:
|
||||
raise Exception('unrecognised command token {0}'.format(self.__commandToken))
|
||||
|
||||
return command
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
from CommandBuilders.CleanBuildCommandBuilder import CleanBuildCommandBuilder
|
||||
|
||||
buildUtilPath = '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool'
|
||||
line = "build 'BuildSample/BuildSample.sln' for 'Release|iPhone'"
|
||||
|
||||
builder = CleanBuildCommandBuilder(buildUtilPath, 'build')
|
||||
|
||||
command = builder.getCommandFor(line)
|
||||
command.execute()
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
from CommandBuilders.CleanBuildCommandBuilder import CleanBuildCommandBuilder
|
||||
|
||||
buildUtilPath = '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool'
|
||||
line = "clean 'BuildSample/BuildSample.sln' for 'Release|iPhone'"
|
||||
|
||||
builder = CleanBuildCommandBuilder(buildUtilPath, 'clean')
|
||||
|
||||
command = builder.getCommandFor(line)
|
||||
command.execute()
|
||||
|
|
@ -0,0 +1 @@
|
|||
__author__ = 'rzaitov'
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import unittest
|
||||
from parser.CleanBuildParser.CleanBuildParser import CleanBuildParser
|
||||
|
||||
|
||||
class TestCleanBuildParser(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.parser = CleanBuildParser('CMD_TOKEN')
|
||||
|
||||
def test_isValid(self):
|
||||
line = "CMD_TOKEN bla bla"
|
||||
isValid = self.parser.isValidLine(line)
|
||||
|
||||
self.assertEqual(True, isValid)
|
||||
|
||||
def test_isNotValid(self):
|
||||
line = 'bla bla CMD_TOKEN'
|
||||
isValid = self.parser.isValidLine(line)
|
||||
|
||||
self.assertEqual(False, isValid)
|
||||
|
||||
def test_parse(self):
|
||||
line = "CMD_TOKEN '../Base dir/Solution.sln' for 'Release|iPhone'"
|
||||
result = self.parser.parseLine(line)
|
||||
|
||||
self.assertEqual('../Base dir/Solution.sln', result[0])
|
||||
self.assertEqual('Release|iPhone', result[1])
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
from commands.CleanBuildCommands.CleanBuildCommandBase import CleanBuildCommandBase
|
||||
|
||||
|
||||
class BuildCommand(CleanBuildCommandBase):
|
||||
def __init__(self, pathToBuildUtil, slnPath, slnConfig):
|
||||
commandPattern = '{0} -v build "--configuration:{1}" "--target:Build" {2}'
|
||||
CleanBuildCommandBase.__init__(self, commandPattern, pathToBuildUtil, slnPath, slnConfig)
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
from subprocess import call
|
||||
|
||||
|
||||
class CleanBuildCommandBase:
|
||||
def __init__(self, commandPattern, pathToBuildUtil, slnPath, slnConfig):
|
||||
assert commandPattern is not None
|
||||
assert pathToBuildUtil is not None
|
||||
assert slnPath is not None
|
||||
assert slnConfig is not None
|
||||
|
||||
self.__commandPattern = commandPattern
|
||||
self.__pathToBuildUtil = pathToBuildUtil
|
||||
self.__slnPath = slnPath
|
||||
self.__slnConfig = slnConfig
|
||||
|
||||
def execute(self):
|
||||
cmdText = self.__commandPattern.format(self.__pathToBuildUtil, self.__slnConfig, self.__slnPath)
|
||||
returnCode = call(cmdText, shell=True)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from commands.CleanBuildCommands.CleanBuildCommandBase import CleanBuildCommandBase
|
||||
|
||||
|
||||
class CleanCommand(CleanBuildCommandBase):
|
||||
def __init__(self, pathToBuildUtil, slnPath, slnConfig):
|
||||
commandPattern = '{0} -v build "--configuration:{1}" "--target:Clean" {2}'
|
||||
CleanBuildCommandBase.__init__(self, commandPattern, pathToBuildUtil, slnPath, slnConfig)
|
||||
|
|
@ -0,0 +1 @@
|
|||
__author__ = 'rzaitov'
|
||||
|
|
@ -7,7 +7,7 @@ class CopyCommand:
|
|||
assert copyArguments is not None
|
||||
|
||||
self.__pathProvider = pathProvider
|
||||
self.__copyArguments = copyArguments
|
||||
self.__copyArguments = copyArguments
|
||||
|
||||
def execute(self):
|
||||
source = self.__expandPath(self.__copyArguments.source)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
from parser.LineParser import LineParser
|
||||
import re
|
||||
|
||||
class CleanBuildParser(LineParser):
|
||||
def __init__(self, commandToken):
|
||||
assert commandToken is not None
|
||||
|
||||
self.__commandToken = commandToken
|
||||
|
||||
def parseLine(self, line):
|
||||
assert line is not None
|
||||
|
||||
filePathRegexp = r"'(?P<path>[./ a-zA-Z]+\.sln)'"
|
||||
slnConfigRegexp = r"'(?P<config>[a-zA-Z|]+)'$"
|
||||
|
||||
regexpSource = self.startsWithKeywordToken(self.__commandToken) + filePathRegexp + self.keywordToken('for') + slnConfigRegexp
|
||||
regexp = re.compile(regexpSource, re.UNICODE)
|
||||
|
||||
match = regexp.match(line)
|
||||
self._guardMatch(match, line, regexpSource)
|
||||
|
||||
path = match.group('path')
|
||||
slnConfig = match.group('config')
|
||||
|
||||
return (path, slnConfig)
|
||||
|
||||
def isValidLine(self, line):
|
||||
assert line is not None
|
||||
|
||||
isValid = line.startswith(self.__commandToken)
|
||||
return isValid
|
||||
|
|
@ -0,0 +1 @@
|
|||
__author__ = 'rzaitov'
|
||||
|
|
@ -16,5 +16,7 @@ os.chdir(baseDir)
|
|||
#import ManualTests.run_sh_command
|
||||
#import ManualTests.make_dirs
|
||||
#import ManualTests.remove_project
|
||||
#import ManualTests.infoplist_test
|
||||
#import ManualTests.clean_test
|
||||
|
||||
import ManualTests.infoplist_test
|
||||
import ManualTests.build_test
|
||||
Loading…
Reference in New Issue