Собираемые конфигурации указываются в глобальных настройках

This commit is contained in:
rzaitov 2013-11-05 19:29:40 +04:00
parent a1b111f8a2
commit 9024f00ba4
5 changed files with 69 additions and 15 deletions

2
scripts/StagingSteps.txt Normal file
View File

@ -0,0 +1,2 @@
sh echo hello from '{@author}'
sh echo version: '{@version}'

View File

@ -20,6 +20,7 @@ class TestBuildConfigProvider(unittest.TestCase):
def test_unionConfig(self):
wr0 = {
'parent': None,
'name': None,
'dict': {
'key1': 'a',
'key2': 'b',
@ -29,6 +30,7 @@ class TestBuildConfigProvider(unittest.TestCase):
}
wr1 = {
'parent': wr0,
'name' : 'name0',
'dict':{
'key2': 'bb',
'key3': 'cc',
@ -39,6 +41,7 @@ class TestBuildConfigProvider(unittest.TestCase):
}
wr2 = {
'parent': wr1,
'name': 'name1',
'dict':{
'key3': 'ccc',
'key4': 'ddd',
@ -47,7 +50,8 @@ class TestBuildConfigProvider(unittest.TestCase):
}
}
config = self.provider.fetchConfigFromLeafWrapper(wr2)
configInfo = self.provider.fetchConfigInfoFromLeafWrapper(wr2)
config = configInfo[1]
expected = {
'key1': 'a',
'key2': 'bb',
@ -57,3 +61,36 @@ class TestBuildConfigProvider(unittest.TestCase):
'key6': 'fff'
}
self.assertDictEqual(expected, config)
def test_buildReadyNames(self):
config = {
'configs': 'ios, android, wp7'
}
names = self.provider.fetchBuildReadyConfigNames(config)
self.assertEqual(3, len(names))
self.assertTrue('ios' in names)
self.assertTrue('android' in names)
self.assertTrue('wp7' in names)
def test_getConfig(self):
rootConfig = {
'configs': 'ios, android',
'ios': {
},
'android': {
},
'wp7': {
}
}
configs = self.provider.getConfigs(rootConfig)
self.assertEqual(2, len(configs))

View File

@ -1,6 +1,7 @@
# global settings
build_tool = '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool'
version = '0.0.0'
configs = 'appstore, staging'
# ios platform settings
ios.steps = 'scripts/IosSteps.txt'
@ -8,14 +9,15 @@ ios.tf_api_token = '0e6925075d4fc10fed0e7bbf43fa6894_NjQ0OTI2MjAxMi0wOS0yNSAxMTo
ios.tf_team_token = 'c5c3cf7a6dae2bea4382dfbd181a2075_Mjc4ODkwMjAxMy0wOS0yOSAxNDowOTo1OC40Mzg5MTY'
# android platform settings
# android.steps = 'AndroidSteps.txt'
# android.steps = 'scripts/AndroidSteps.txt'
# config settings
ios.appstore.build_ready = 'true'
ios.appstore.app_name = 'CoolApp'
ios.appstore.sln_config = 'Release|iPhone'
ios.appstore.author = 'Rustam'
ios.appstore.version = '7.7.7'
#ios.staging.build_ready = 'true'
ios.staging.app_name = 'CoolApp staging'
ios.staging.steps = 'scripts/StagingSteps.txt'
ios.staging.author = 'Fedor'
ios.staging.version = '7.8.9'

View File

@ -41,8 +41,8 @@ class TaskRunner:
self.lineConveyor.addProcessor(macroResolver)
def run(self):
settings = self.settingsProvider.fetchSettings()
buildReadyConfigs = self.configsProvider.getConfigs(settings)
rawSettings = self.settingsProvider.fetchSettings()
buildReadyConfigs = self.configsProvider.getConfigs(rawSettings)
for bc in buildReadyConfigs:
self.valueProvider.setConfig(bc)

View File

@ -3,21 +3,34 @@ class BuildConfigProvider:
pass
def getConfigs(self, rootConfig):
buildReadyConfigNames = self.fetchBuildReadyConfigNames(rootConfig)
leafs = []
self.traverseDict(None, rootConfig, leafs)
self.traverseDict(None, None, rootConfig, leafs)
configs = []
for l in leafs:
config = self.fetchConfigFromLeafWrapper(l)
if config.get('build_ready', 'false') == 'true':
configInfo = self.fetchConfigInfoFromLeafWrapper(l)
name = configInfo[0]
config = configInfo[1]
if name in buildReadyConfigNames:
configs.append(config)
return configs
def traverseDict(self, parent, dictForTraverse, leafs):
def fetchBuildReadyConfigNames(self, rootConfig):
value = rootConfig['configs']
names = value.split(',')
names = [name.strip(' ') for name in names]
return names
def traverseDict(self, parent, key, dictForTraverse, leafs):
wrapper = {
'parent' : parent,
'dict' : dictForTraverse
'parent': parent,
'dict': dictForTraverse,
'name': key
}
isLeaf = True
@ -26,12 +39,12 @@ class BuildConfigProvider:
if type(value) is dict:
isLeaf = False
self.traverseDict(wrapper, value, leafs)
self.traverseDict(wrapper, key, value, leafs)
if isLeaf:
leafs.append(wrapper)
def fetchConfigFromLeafWrapper(self, leafWrapper):
def fetchConfigInfoFromLeafWrapper(self, leafWrapper):
ancestors = self.getAncestorsFor(leafWrapper)
unionConf = {}
@ -42,7 +55,7 @@ class BuildConfigProvider:
if type(value) is str:
unionConf[k] = value
return unionConf
return leafWrapper['name'], unionConf
def getAncestorsFor(self, leaf):
ancestors = [leaf]