Skip to content

Commit 20a5da7

Browse files
committed
Use --clang instead of --clangc; Polish variable names and update comments
1 parent e8c9b6e commit 20a5da7

File tree

3 files changed

+41
-36
lines changed

3 files changed

+41
-36
lines changed

project_future.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def add_arguments(parser):
584584
parser.add_argument("--report-time-path",
585585
help='export time for building each xcode build target to the specified json file',
586586
type=os.path.abspath)
587-
parser.add_argument("--clangc",
587+
parser.add_argument("--clang",
588588
help='clang executable to build Xcode projects',
589589
type=os.path.abspath)
590590
parser.add_argument("--job-type",

run

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ def main():
3737
if not args.skip_build:
3838
build_swift_toolchain(workspace, args)
3939

40-
clang_flags = []
41-
if args.clang_source_path or args.clangc:
42-
clangc = args.clangc
40+
additional_runner_args = []
41+
if args.clang_source_path or args.clang:
42+
clang = args.clang
4343
if args.clang_source_path:
44-
clangc = build_clang(workspace, args.clang_source_path)
45-
if clangc:
46-
clang_flags = ['--clangc', clangc]
44+
clang = build_clang(workspace, args)
45+
if clang:
46+
additional_runner_args = ['--clang', clang]
4747

4848
if not args.skip_runner:
4949
if args.test_incremental:
50-
execute_build_incremental(workspace, args, clang_flags)
50+
execute_build_incremental(workspace, args, additional_runner_args)
5151
else:
52-
execute_runner(workspace, args, clang_flags)
52+
execute_runner(workspace, args, additional_runner_args)
5353

5454
return 0
5555

@@ -65,10 +65,10 @@ def parse_args():
6565
parser.add_argument("--verbose",
6666
action='store_true')
6767
parser.add_argument("--assertions",
68-
help='Build Swift with asserts',
68+
help='Build Swift and/or Clang with asserts',
6969
action='store_true')
7070
parser.add_argument("--debug",
71-
help='Build Swift in debug mode',
71+
help='Build Swift and/or Clang in debug mode',
7272
action='store_true')
7373
parser.add_argument("--filter-by-tag",
7474
metavar='TAG',
@@ -89,9 +89,9 @@ def parse_args():
8989
'executable from the given path and uses it to '
9090
'build Xcode projects',
9191
type=os.path.abspath)
92-
clang_arguments.add_argument('--clangc',
92+
clang_arguments.add_argument('--clang',
9393
metavar="PATH",
94-
help='clang executable',
94+
help='clang executable to build Xcode projects',
9595
type=os.path.abspath)
9696
parser.add_argument('--skip-build',
9797
action='store_true')
@@ -180,7 +180,7 @@ def get_sandbox_profile_flags_test():
180180
return sandbox_flags
181181

182182

183-
def execute_runner(workspace, args, clang_flags):
183+
def execute_runner(workspace, args, additional_runner_args):
184184
swiftc_path = get_swiftc_path(workspace, args.swiftc)
185185
if args.test:
186186
action_filter = 'action.startswith("TestSwiftPackage")'
@@ -212,12 +212,12 @@ def execute_runner(workspace, args, clang_flags):
212212
if args.build_config:
213213
runner_command += ['--build-config=%s' % args.build_config]
214214

215-
runner_command += clang_flags
215+
runner_command += additional_runner_args
216216

217217
common.check_execute(runner_command, timeout=9999999)
218218

219219

220-
def execute_build_incremental(workspace, args, clang_flags):
220+
def execute_build_incremental(workspace, args, additional_runner_args):
221221
swiftc_path = get_swiftc_path(workspace, args.swiftc)
222222
runner_command = [
223223
'./build_incremental.py',
@@ -232,7 +232,7 @@ def execute_build_incremental(workspace, args, clang_flags):
232232
]
233233
if args.sandbox:
234234
runner_command += get_sandbox_profile_flags()
235-
runner_command += clang_flags
235+
runner_command += additional_runner_args
236236
common.check_execute(runner_command, timeout=9999999)
237237

238238
def get_preset_name(args):
@@ -292,26 +292,31 @@ def build_swift_toolchain(workspace, args):
292292
raise common.UnsupportedPlatform
293293
common.check_execute(build_command, timeout=9999999)
294294

295-
def build_clang(workspace, source_path):
295+
def build_clang(workspace, args):
296296
build_path = os.path.join(workspace, 'build_clang_source_compat')
297-
source_path = os.path.join(source_path, 'llvm')
297+
source_path = os.path.join(args.clang_source_path, 'llvm')
298298
common.check_execute(['mkdir', '-p', build_path])
299299

300300
with common.DirectoryContext(build_path):
301-
try:
302-
ninja_path = common.check_execute_output(['xcrun', '--find', 'ninja']).strip().decode("utf-8")
303-
cmake_command = [
304-
'xcrun', 'cmake', '-G', 'Ninja',
305-
'-DCMAKE_MAKE_PROGRAM={}'.format(ninja_path),
306-
'-DLLVM_ENABLE_PROJECTS=clang;llvm',
307-
'-DCMAKE_BUILD_TYPE=Release',
308-
'-DCLANG_APPLE_BUILD_VERSION_STRING=13000000',
309-
'-DLLVM_TARGETS_TO_BUILD=X86;AArch64;ARM',
310-
source_path]
311-
common.check_execute(cmake_command)
312-
common.check_execute(['xcrun', 'ninja'])
313-
except:
314-
raise
301+
# Get path to the ninja binary
302+
ninja_path = common.check_execute_output(['xcrun', '--find', 'ninja']).strip().decode("utf-8")
303+
304+
build_type = "Debug" if args.debug else "Release"
305+
assert_on = "True" if args.assertions or args.debug else "False"
306+
307+
# Generate a Ninja project with CMake
308+
cmake_command = [
309+
'xcrun', 'cmake', '-G', 'Ninja',
310+
'-DCMAKE_MAKE_PROGRAM={}'.format(ninja_path),
311+
'-DLLVM_ENABLE_PROJECTS=clang;llvm',
312+
'-DCMAKE_BUILD_TYPE={}'.format(build_type),
313+
'-DLLVM_ENABLE_ASSERTIONS={}'.format(assert_on),
314+
'-DLLVM_TARGETS_TO_BUILD=X86;AArch64;ARM',
315+
source_path]
316+
common.check_execute(cmake_command)
317+
318+
# Build the Ninja project to produce the clang executable
319+
common.check_execute(['xcrun', 'ninja'])
315320

316321
return os.path.join(build_path, 'bin', 'clang')
317322

runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def main():
4242
xcodebuild_flags = args.add_xcodebuild_flags
4343
xcodebuild_flags += (' ' if xcodebuild_flags else '') + 'DEBUG_INFORMATION_FORMAT=dwarf'
4444

45-
# Use clangc for building xcode projects.
46-
if args.clangc:
47-
xcodebuild_flags += ' CC=%s' % args.clangc
45+
# Use clang for building xcode projects.
46+
if args.clang:
47+
xcodebuild_flags += ' CC=%s' % args.clang
4848

4949
swift_flags = args.add_swift_flags
5050

0 commit comments

Comments
 (0)