-
Notifications
You must be signed in to change notification settings - Fork 8
/
lib_ide_xcode.py
72 lines (63 loc) · 3.63 KB
/
lib_ide_xcode.py
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
# BuildFox ninja generator
import os
import uuid
import json
from lib_ide_make import gen_make
from lib_util import cxx_findfiles
xcode_reference_prj = r"""
{"archiveVersion": "1",
"classes": {},
"objectVersion": "46",
"objects": {"EF0AF33C1C83A4DC00290920": {"children": [],
"isa": "PBXGroup",
"sourceTree": "<group>"},
"EF0AF33D1C83A4DC00290920": {"buildConfigurationList": "EF0AF3401C83A4DC00290920",
"compatibilityVersion": "Xcode 3.2",
"hasScannedForEncodings": "0",
"isa": "PBXProject",
"knownRegions": ["en"],
"mainGroup": "EF0AF33C1C83A4DC00290920",
"projectDirPath": "",
"projectRoot": "",
"targets": ["EF0AF3411C83A4DC00290920"]},
"EF0AF3401C83A4DC00290920": {"buildConfigurations": ["EF0AF3431C83A4DC00290920"],
"defaultConfigurationIsVisible": "0",
"defaultConfigurationName": "Build",
"isa": "XCConfigurationList"},
"EF0AF3411C83A4DC00290920": {"buildArgumentsString": "$(ACTION)",
"buildConfigurationList": "EF0AF3441C83A4DC00290920",
"buildPhases": [],
"buildToolPath": "/usr/bin/make",
"buildWorkingDirectory": "...",
"dependencies": [],
"isa": "PBXLegacyTarget",
"name": "test",
"passBuildSettingsInEnvironment": "1",
"productName": "test"},
"EF0AF3431C83A4DC00290920": {"buildSettings": {},
"isa": "XCBuildConfiguration",
"name": "Build"},
"EF0AF3441C83A4DC00290920": {"buildConfigurations": ["EF0AF3461C83A4DC00290920"],
"defaultConfigurationIsVisible": "0",
"defaultConfigurationName": "Build",
"isa": "XCConfigurationList"},
"EF0AF3461C83A4DC00290920": {"buildSettings": {},
"isa": "XCBuildConfiguration",
"name": "Build"}},
"rootObject": "EF0AF33D1C83A4DC00290920"}
"""
def gen_xcode(all_files, includedirs, prj_name, buildfox_name, cmd_env, ninja_gen_mode):
gen_make(buildfox_name, cmd_env, ninja_gen_mode)
all_files = cxx_findfiles(all_files)
includedirs = [".", "build/bin_debug"] + includedirs
prj_location = prj_name + ".xcodeproj"
if not os.path.exists(prj_location):
os.makedirs(prj_location)
ref = json.loads(xcode_reference_prj)
import mod_pbxproj # TODO would be nice to remove external dependency before release, because mod_pbxproj doesn't work with python3
prj = mod_pbxproj.XcodeProject(ref, prj_location + "/project.pbxproj")
target = prj.get_build_phases('PBXLegacyTarget')
target[0]["buildWorkingDirectory"] = os.path.abspath(prj_location + "/..")
for file in all_files:
prj.add_file_if_doesnt_exist(os.path.relpath(file, prj_location + "/.."))
prj.save()