bingxue.py
3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import shutil
import os
import plistlib
import config
import json
import packageProj
from mod_pbxproj import XcodeProject
gameProjName = config.gameProjName
channelName = "bingxue"
#copy dir xcodeproj
copyNewDirName = gameProjName + '_' + channelName + '.xcodeproj'
currentPath = os.path.abspath('.')
currentPath += '/' + copyNewDirName
if os.path.exists(currentPath):
shutil.rmtree(currentPath)
shutil.copytree(gameProjName + '.xcodeproj',currentPath)
project = XcodeProject.Load(copyNewDirName + '/project.pbxproj')
project.add_other_ldflags('-ObjC')
#frameworks = project.add_folder('poolsdk_file/poolsdk_itools')
#print(frameworks);
#add search path
channelRootPath = config.channelRootPath#'poolsdk_file'
frameworksPath = '$(PROJECT_DIR)/' + channelRootPath + '/poolsdk_' + channelName + '/SDK'
print(frameworksPath);
#add header search path
project.add_header_search_paths(frameworksPath, recursive=False)
#add framework search path
project.add_framework_search_paths(frameworksPath, recursive=False)
#add library search path
project.add_library_search_paths(frameworksPath, recursive=False)
#add poolsdk_xy dir all file into project
project.remove_group_by_name('poolsdk')
frameworkRelativePath = project.add_folder(channelRootPath + '/poolsdk_' + channelName + '/SDK')
#add sdk lib framework
#project.add_file_if_doesnt_exist('XYPlatform.framework',parent=frameworkRelativePath, weak=True)
#project.add_file_if_doesnt_exist('XYPlatformResources.bundle',parent=frameworkRelativePath, weak=True)
#remove demo file and replace sdk file
#project.remove_file_by_path('poolsdk_file/Demo')
#project.remove_group_by_name('poolsdk_file')
#project.add_file_if_doesnt_exist('PoolSdk.h',parent=frameworkRelativePath, weak=True)
#project.add_file_if_doesnt_exist('PoolSdk.m',parent=frameworkRelativePath, weak=True)
#project.add_file_if_doesnt_exist('SDKInterface.h',parent=frameworkRelativePath, weak=True)
#project.add_file_if_doesnt_exist('SDKInterface.m',parent=frameworkRelativePath, weak=True)
#ignore_unknown_type
project.add_file_if_doesnt_exist('pool_setting',parent=frameworkRelativePath, weak=True,ignore_unknown_type=True)
systemFrameworks = project.get_or_create_group('Frameworks')
#add system framework
project.add_file_if_doesnt_exist('System/Library/Frameworks/CoreTelephony.framework',parent=systemFrameworks, weak=True, tree='SDKROOT')
project.add_file_if_doesnt_exist('System/Library/Frameworks/SystemConfiguration.framework',parent=systemFrameworks, weak=True, tree='SDKROOT')
#add system dylib
systemLibs = project.get_or_create_group('Libraries')
project.add_file_if_doesnt_exist('/usr/lib/libsqlite3.dylib',parent=systemLibs, weak=True, tree='<absolute>')#absolute path
#modify info.plist reference path
project.add_single_valued_flag('INFOPLIST_FILE',channelRootPath + '/poolsdk_' + channelName + '/Info.plist')
project.add_single_valued_flag('ENABLE_BITCODE', 'NO')
readInfoPlistFilePath = channelRootPath + '/poolsdk/Info.plist'
writeInfoFilePath = channelRootPath + '/poolsdk_' + channelName + '/Info.plist'
infoContent = plistlib.readPlist(readInfoPlistFilePath)
xyInfoPath = channelRootPath + '/poolsdk_' + channelName + '/Info_' + channelName + '.plist'
xyInfoContent = plistlib.readPlist(xyInfoPath)
#read pool_setting file
settingFile = open(channelRootPath + '/poolsdk_' + channelName + '/SDK/pool_setting','rw')
try:
settingFileContent = settingFile.read( )
finally:
settingFile.close( )
#json op
jsonStr = json.loads(settingFileContent)
#modify bundle id
project.add_single_valued_flag('PRODUCT_BUNDLE_IDENTIFIER',jsonStr["appScheme"])
#update and add info.plist content
infoContent.update(xyInfoContent)
#write
plistlib.writePlist(infoContent,writeInfoFilePath)
project.save()
packageProj.buildProjName = gameProjName + '_' + channelName
packageProj.targetName = gameProjName
packageProj.buildProj()