From c4631e1805d743a9bbf9e66173490747b697077d Mon Sep 17 00:00:00 2001 From: Rustam Zaitov Date: Sun, 15 Sep 2013 18:21:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D0=BF=D0=B0=D1=82=D1=87=D0=B8=D0=BD=D0=B3?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?ios=20(sln=20info.plist)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BuildSample/BuildSample.sln | 4 +-- BuildSample/BuildSample/Info.plist | 2 +- scripts/buld.py | 41 ++++++++++++---------------- scripts/patch.py | 43 +++++++++++++++++++++++++++--- scripts/settings.py | 21 ++++++++++++--- 5 files changed, 76 insertions(+), 35 deletions(-) diff --git a/BuildSample/BuildSample.sln b/BuildSample/BuildSample.sln index fd8c3bd..6022986 100644 --- a/BuildSample/BuildSample.sln +++ b/BuildSample/BuildSample.sln @@ -2,9 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoolApp", "BuildSample\CoolApp.csproj", "{E7393DD4-5E5F-456A-89AB-000EC63BD901}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotCompileApp", "NotCompileApp\NotCompileApp.csproj", "{3DE4FDFA-1502-44CF-9B73-78B6D730C59F}" -EndProject +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{BD5EC0A1-EDC9-4D90-BACF-AE54F26148C1}" EndProject Global diff --git a/BuildSample/BuildSample/Info.plist b/BuildSample/BuildSample/Info.plist index 93ab139..a18532e 100644 --- a/BuildSample/BuildSample/Info.plist +++ b/BuildSample/BuildSample/Info.plist @@ -11,7 +11,7 @@ MinimumOSVersion 6.0 CFBundleVersion - 0.0.0 + 1.2.3 CFBundleDisplayName BuidScript CFBundleIdentifier diff --git a/scripts/buld.py b/scripts/buld.py index e6c23f5..6d49660 100644 --- a/scripts/buld.py +++ b/scripts/buld.py @@ -3,32 +3,25 @@ import os import settings import instruments -# print("all projects:") -# print(settings.all_projects) - -# project_to_remove = settings.projects_to_exclude[0]; -# print("project to remove:") -# print(project_to_remove); - - -# projects_to_build = settings.all_projects[:] -# projects_to_build.remove(project_to_remove) - -# print("projects to build:") -# print(projects_to_build) - -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) +cmd_args = {'version' : '1.2.3', 'some_field' : 'some_value', 'action' : 'setup'} instruments.CompileConfigs(settings.build_ready_configs, cmd_args) -for conf in settings.build_ready_configs: - print conf +for bc in settings.build_ready_configs: + sln_path = bc['sln_path'] + sln_dir = os.path.dirname(sln_path) + instruments.CreateOrRestoreFromBackup(sln_dir, bc['files_for_backup']) + instruments.RemoveProjectFromSolution(sln_path, bc['projects_to_exclude']) -# instruments.DeleteBackups(sln_dir, settings.files_for_backup) \ No newline at end of file + # try patch source code files + path_function = bc['patch'] + if path_function is not None: + path_function(bc) + + if bc['action'] == 'build': + instruments.CleanSolution(bc['mdtool'], sln_path) + instruments.BuildSolution(bc['mdtool'], sln_path, bc['sln_config']) + + instruments.CreateOrRestoreFromBackup(sln_dir, settings.files_for_backup) + instruments.DeleteBackups(sln_dir, settings.files_for_backup) \ No newline at end of file diff --git a/scripts/patch.py b/scripts/patch.py index 49ab8c7..e4187d5 100644 --- a/scripts/patch.py +++ b/scripts/patch.py @@ -1,6 +1,43 @@ -def PathcIos(build_config): - print('start patch ios') +import re +import os +def RewriteFile(file_to_rewrite, content): + file_to_rewrite.seek(0) + file_to_rewrite.write(content) + file_to_rewrite.truncate() + file_to_rewrite.close() + + +def PatchSlnForIos(build_config): + + sln_file = open(build_config['sln_path'], 'r+') + content = sln_file.read() + + condesign_key_patt = r'.*?' + condesign_key_node = r'{0}'.format(build_config['codesign_key']) + content = re.sub(condesign_key_patt, condesign_key_node, content) + + RewriteFile(sln_file, content) + +def PatchInfoPlist(build_config): + + sln_dir = os.path.dirname(build_config['sln_path']) + abs_info_plist_path = os.path.join(sln_dir, build_config['info_plist_rel_path']) + + info_plist_file = open(abs_info_plist_path, 'r+') + content = info_plist_file.read() + + version_patt = r'\s*CFBundleVersion\s+[\d\.]+' + version_node = r'\n\tCFBundleVersion\n\t{0}'.format(build_config['version']) + content = re.sub(version_patt, version_node, content) + + RewriteFile(info_plist_file, content) + +def PathcIos(build_config): + + PatchSlnForIos(build_config) + PatchInfoPlist(build_config) def PathcAndroid(build_config): - print('start patch ios') \ No newline at end of file + print('start patch ios') + diff --git a/scripts/settings.py b/scripts/settings.py index 41021cd..9bc0ce7 100644 --- a/scripts/settings.py +++ b/scripts/settings.py @@ -1,8 +1,10 @@ +# -*- coding: utf-8 -*- import patch build_root = { 'mdtool' : '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool', 'version' : '0.0.0', + 'action' : 'build', # 'build'|'setup' 'parent' : None } @@ -12,24 +14,35 @@ ios_root = { } ios_development_root = { - 'files_for_backup' : ['BuildSample.sln', 'BuildSample/CoolApp.csproj'], + 'files_for_backup' : ['BuildSample.sln', 'BuildSample/CoolApp.csproj', 'BuildSample/Info.plist'], 'projects_to_exclude' : ['NotCompileApp'], + 'info_plist_rel_path' : 'BuildSample/Info.plist', + 'patch' : patch.PathcIos, 'parent' : ios_root } ios_development_production = { 'name' : 'ios_development_production', + 'sln_config' : 'Release|iPhone', - 'patch' : patch.PathcIos, + 'codesign_key' : 'iPhone Developer: Рустам Заитов (CTL85FZX6K)', + 'codesign_provision' : '8F606DAE-F9C9-4A19-8EFF-34B990D76C28', + 'parent' : ios_development_root } ios_development_staging = { 'name' : 'ios_development_staging', + 'sln_config' : 'Debug|iPhone', - 'patch' : patch.PathcIos, + 'codesign_key' : 'iPhone Developer', + 'codesign_provision' : 'F82B1481-F3D0-4CB5-AA6E-8B8D8E3A9DC1', + 'parent' : ios_development_root } -build_ready_configs = [ios_development_production, ios_development_staging] +ios_app_store = { +} +# build_ready_configs = [ios_development_production, ios_development_staging] +build_ready_configs = [ios_development_production]