diff --git a/scripts/buld.py b/scripts/buld.py index 875940d..e6c23f5 100644 --- a/scripts/buld.py +++ b/scripts/buld.py @@ -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) \ No newline at end of file diff --git a/scripts/instruments.py b/scripts/instruments.py index ac977f0..551fab9 100644 --- a/scripts/instruments.py +++ b/scripts/instruments.py @@ -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 \ No newline at end of file diff --git a/scripts/patch.py b/scripts/patch.py new file mode 100644 index 0000000..49ab8c7 --- /dev/null +++ b/scripts/patch.py @@ -0,0 +1,6 @@ +def PathcIos(build_config): + print('start patch ios') + + +def PathcAndroid(build_config): + print('start patch ios') \ No newline at end of file diff --git a/scripts/settings.py b/scripts/settings.py index f9207aa..41021cd 100644 --- a/scripts/settings.py +++ b/scripts/settings.py @@ -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"] \ No newline at end of file +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] +