From 9b13209726fa9f248d3be9f17663a2f7d607b483 Mon Sep 17 00:00:00 2001 From: Rustam Zaitov Date: Sun, 15 Sep 2013 15:32:56 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=85=D0=B0=D0=BD=D0=B8=D0=B7=D0=BC=20=D0=B1=D0=B8?= =?UTF-8?q?=D0=BB=D0=B4=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B9=20=D1=81=20=D0=B2=D0=BE=D0=B7=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D0=BB=D0=B5=D0=B4=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=20=D0=B8=20=D0=B8?= =?UTF-8?q?=D1=85=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BE=D0=BF=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/buld.py | 18 ++++++++++++------ scripts/instruments.py | 27 +++++++++++++++++++++++++++ scripts/patch.py | 6 ++++++ scripts/settings.py | 39 +++++++++++++++++++++++++++++++++++---- 4 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 scripts/patch.py 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] +