Реализовал патчинг файлов для ios (sln info.plist)

This commit is contained in:
Rustam Zaitov 2013-09-15 18:21:40 +04:00
parent 5107c83ab1
commit c4631e1805
5 changed files with 76 additions and 35 deletions

View File

@ -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

View File

@ -11,7 +11,7 @@
<key>MinimumOSVersion</key>
<string>6.0</string>
<key>CFBundleVersion</key>
<string>0.0.0</string>
<string>1.2.3</string>
<key>CFBundleDisplayName</key>
<string>BuidScript</string>
<key>CFBundleIdentifier</key>

View File

@ -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)
# 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)

View File

@ -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'<CodesignKey>.*?</CodesignKey>'
condesign_key_node = r'<CodesignKey>{0}</CodesignKey>'.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*<key>CFBundleVersion</key>\s+<string>[\d\.]+</string>'
version_node = r'\n\t<key>CFBundleVersion</key>\n\t<string>{0}</string>'.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')
print('start patch ios')

View File

@ -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]