Skip to content

Commit 2b857af

Browse files
authored
Merge pull request swiftlang#70 from nkcsgexi/xcode-proj-gen
build-script: teach the build-script to generate an Xcode project
2 parents 336413b + 5dc76d4 commit 2b857af

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

build-script.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
GYB_EXEC = WORKSPACE_DIR + '/swift/utils/gyb'
1919
LIT_EXEC = WORKSPACE_DIR + '/llvm/utils/lit/lit.py'
2020

21+
### Generate Xcode project
22+
23+
def xcode_gen(config):
24+
print('** Generate SwiftSyntax as an Xcode project **')
25+
os.chdir(PACKAGE_DIR)
26+
swiftpm_call = ['swift', 'package', 'generate-xcodeproj']
27+
if config:
28+
swiftpm_call.extend(['--xcconfig-overrides', config])
29+
check_call(swiftpm_call)
30+
2131
### Generic helper functions
2232

2333
def printerr(message):
@@ -169,7 +179,6 @@ def get_swiftpm_invocation(spm_exec, build_dir, parser_header_dir,
169179
swiftpm_call.extend(['-Xswiftc', '-enforce-exclusivity=unchecked'])
170180
return swiftpm_call
171181

172-
173182
def build_swiftsyntax(swift_build_exec, swiftc_exec, build_dir,
174183
parser_header_dir, parser_lib_dir,
175184
build_test_util, release,
@@ -406,6 +415,14 @@ def main():
406415
help='''
407416
Install the build artifact to a specified toolchain directory.
408417
''')
418+
basic_group.add_argument('--generate-xcodeproj', action='store_true',
419+
help='''
420+
Generate an Xcode project for SwiftSyntax.
421+
''')
422+
basic_group.add_argument('--xcconfig-path',
423+
help='''
424+
The path to an xcconfig file for generating Xcode projct.
425+
''')
409426
basic_group.add_argument('--dylib-dir',
410427
help='''
411428
The directory to where the .dylib should be installed.
@@ -488,6 +505,10 @@ def main():
488505
printerr(e.output)
489506
sys.exit(1)
490507

508+
if args.generate_xcodeproj:
509+
xcode_gen(config=args.xcconfig_path)
510+
sys.exit(0)
511+
491512
try:
492513
build_swiftsyntax(swift_build_exec=args.swift_build_exec,
493514
swiftc_exec=args.swiftc_exec,

0 commit comments

Comments
 (0)