Добавил механизм билд конфигураций с возможностью наследования свойств и их переопределения
This commit is contained in:
parent
893a98feea
commit
9b13209726
|
|
@ -17,12 +17,18 @@ import instruments
|
|||
# print("projects to build:")
|
||||
# print(projects_to_build)
|
||||
|
||||
sln_config = "Debug|iPhone Simulator"
|
||||
sln_dir = os.path.dirname(settings.sln_path)
|
||||
cmd_args = {'version' : '1.2.3', 'some_field' : 'some_value'}
|
||||
# sln_dir = os.path.dirname(settings.sln_path)
|
||||
|
||||
# instruments.CreateOrRestoreFromBackup(sln_dir, settings.files_for_backup)
|
||||
# instruments.RemoveProjectFromSolution(settings.sln_path, settings.projects_to_exclude)
|
||||
# instruments.CleanSolution(settings.mdtool, settings.sln_path)
|
||||
# instruments.BuildSolution(settings.mdtool, settings.sln_path, sln_config)
|
||||
|
||||
instruments.CompileConfigs(settings.build_ready_configs, cmd_args)
|
||||
|
||||
for conf in settings.build_ready_configs:
|
||||
print conf
|
||||
|
||||
instruments.CreateOrRestoreFromBackup(sln_dir, settings.files_for_backup)
|
||||
instruments.RemoveProjectFromSolution(settings.sln_path, settings.projects_to_exclude)
|
||||
instruments.CleanSolution(settings.mdtool, settings.sln_path)
|
||||
instruments.BuildSolution(settings.mdtool, settings.sln_path, sln_config)
|
||||
|
||||
# instruments.DeleteBackups(sln_dir, settings.files_for_backup)
|
||||
|
|
@ -62,6 +62,7 @@ def RemoveProjectFromSolution(abs_path_to_sln, project_names):
|
|||
reg_pattern = r'\n*Project.*?"{0}".*?\n*EndProject'.format(pn)
|
||||
content = re.sub(reg_pattern, "", content)
|
||||
|
||||
# override file
|
||||
sln_file.seek(0)
|
||||
sln_file.write(content)
|
||||
sln_file.truncate()
|
||||
|
|
@ -84,3 +85,29 @@ def BuildSolution(mdtool, abs_path_to_sln, config):
|
|||
print(build_cmd_text)
|
||||
ret_code = call(build_cmd_text, shell=True)
|
||||
print('finished with return code: {0}'.format(ret_code))
|
||||
|
||||
def CompileConfigs(configs_lst, cmd_args):
|
||||
|
||||
for c_dict in configs_lst:
|
||||
|
||||
ancestors = GetAncestorsFromRootTo(c_dict)
|
||||
ancestors.append(cmd_args)
|
||||
|
||||
union_config = {}
|
||||
for a in ancestors:
|
||||
union_config.update(a)
|
||||
|
||||
c_dict.clear()
|
||||
c_dict.update(union_config)
|
||||
|
||||
def GetAncestorsFromRootTo(config):
|
||||
|
||||
ancestors = []
|
||||
c = config
|
||||
|
||||
while c is not None:
|
||||
ancestors.append(c)
|
||||
c = c['parent']
|
||||
|
||||
ancestors.reverse()
|
||||
return ancestors
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
def PathcIos(build_config):
|
||||
print('start patch ios')
|
||||
|
||||
|
||||
def PathcAndroid(build_config):
|
||||
print('start patch ios')
|
||||
|
|
@ -1,4 +1,35 @@
|
|||
mdtool = "/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool"
|
||||
sln_path = "/Users/rzaitov/Documents/Apps/BuildScript/BuildSample/BuildSample.sln"
|
||||
files_for_backup = ["BuildSample.sln", "BuildSample/CoolApp.csproj"]
|
||||
projects_to_exclude = ["NotCompileApp"]
|
||||
import patch
|
||||
|
||||
build_root = {
|
||||
'mdtool' : '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool',
|
||||
'version' : '0.0.0',
|
||||
'parent' : None
|
||||
}
|
||||
|
||||
ios_root = {
|
||||
'sln_path' : '/Users/rzaitov/Documents/Apps/BuildScript/BuildSample/BuildSample.sln',
|
||||
'parent' : build_root
|
||||
}
|
||||
|
||||
ios_development_root = {
|
||||
'files_for_backup' : ['BuildSample.sln', 'BuildSample/CoolApp.csproj'],
|
||||
'projects_to_exclude' : ['NotCompileApp'],
|
||||
'parent' : ios_root
|
||||
}
|
||||
|
||||
ios_development_production = {
|
||||
'name' : 'ios_development_production',
|
||||
'sln_config' : 'Release|iPhone',
|
||||
'patch' : patch.PathcIos,
|
||||
'parent' : ios_development_root
|
||||
}
|
||||
|
||||
ios_development_staging = {
|
||||
'name' : 'ios_development_staging',
|
||||
'sln_config' : 'Debug|iPhone',
|
||||
'patch' : patch.PathcIos,
|
||||
'parent' : ios_development_root
|
||||
}
|
||||
|
||||
build_ready_configs = [ios_development_production, ios_development_staging]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue