forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-script
executable file
·768 lines (627 loc) · 26.6 KB
/
build-script
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
#!/usr/bin/env python
#===--- build-script - The ultimate tool for building Swift ----------------===#
#
## This source file is part of the Swift.org open source project
##
## Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
## Licensed under Apache License v2.0 with Runtime Library Exception
##
## See http://swift.org/LICENSE.txt for license information
## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
#===------------------------------------------------------------------------===#
from __future__ import print_function
import argparse
import os
import shutil
import sys
import textwrap
sys.path.append(os.path.dirname(__file__))
from SwiftBuildSupport import *
# Main entry point for the preset mode.
def main_preset():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""Builds Swift using a preset.""")
parser.add_argument("--preset-file",
help="load presets from the specified file",
metavar="PATH",
action="append",
dest="preset_file_names",
default=[])
parser.add_argument("--preset",
help="use the specified option preset",
metavar="NAME")
parser.add_argument("--show-presets",
help="list all presets and exit",
action="store_true")
parser.add_argument("--distcc",
help="use distcc",
action="store_true")
parser.add_argument("preset_substitutions_raw",
help="'name=value' pairs that are substituted in the preset",
nargs="*",
metavar="SUBSTITUTION")
args = parser.parse_args()
if len(args.preset_file_names) == 0:
args.preset_file_names = [
os.path.join(HOME, ".swift-build-presets"),
os.path.join(
SWIFT_SOURCE_ROOT, "swift", "utils", "build-presets.ini")
]
if args.show_presets:
for name in sorted(get_all_preset_names(args.preset_file_names),
key=str.lower):
print(name)
return 0
if not args.preset:
print_with_argv0("Missing --preset option")
return 1
args.preset_substitutions = {}
for arg in args.preset_substitutions_raw:
name, value = arg.split("=", 1)
args.preset_substitutions[name] = value
preset_args = get_preset_options(
args.preset_substitutions, args.preset_file_names, args.preset)
build_script_args = [ sys.argv[0] ]
build_script_args += preset_args
if args.distcc:
build_script_args += [ "--distcc" ]
print_with_argv0(
"using preset '" + args.preset + "', which expands to " +
quote_shell_command(build_script_args))
check_call(build_script_args)
return 0
# Main entry point for the normal mode.
def main_normal():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""
Use this tool to build, test, and prepare binary distribution archives of Swift
and related tools.
Builds Swift (and, optionally, LLDB), incrementally, optionally
testing it thereafter. Different build configurations are maintained in
parallel.""",
epilog="""
Using option presets:
--preset-file=PATH load presets from the specified file
--preset=NAME use the specified option preset
The preset mode is mutually exclusive with other options. It is not
possible to add ad-hoc customizations to a preset. This is a deliberate
design decision. (Rationale: a preset is a certain important set of
options that we want to keep in a centralized location. If you need to
customize it, you should create another preset in a centralized location,
rather than scattering the knowledge about the build across the system.)
Presets support substitutions for controlled customizations. Substitutions
are defined in the preset file. Values for substitutions are supplied
using the name=value syntax on the command line.
Any arguments passed after "--" are forwarded directly to Swift's
'build-script-impl'. See that script's help for details.
Environment variables
---------------------
This script respects a few environment variables, should you
choose to set them:
SWIFT_SOURCE_ROOT: a directory containing the source for LLVM, Clang, Swift.
If this script is located in a Swift
source directory, the location of SWIFT_SOURCE_ROOT will be
inferred if the variable is not set.
'build-script' expects the sources to be laid out in the following way:
$SWIFT_SOURCE_ROOT/llvm
/clang
/swift
/lldb (optional)
/llbuild (optional)
/swiftpm (optional, requires llbuild)
/swift-corelibs-xctest (optional)
/swift-corelibs-foundation (optional)
SWIFT_BUILD_ROOT: a directory in which to create out-of-tree builds.
Defaults to "$SWIFT_SOURCE_ROOT/build/".
Preparing to run this script
----------------------------
See README.md for instructions on cloning Swift subprojects.
If you intend to use the -l, -L, --lldb, or --lldb-debug options.
That's it; you're ready to go!
Examples
--------
Given the above layout of sources, the simplest invocation of 'build-script' is
just:
[~/src/s]$ ./swift/utils/build-script
This builds LLVM, Clang, Swift and Swift standard library in debug mode.
All builds are incremental. To incrementally build changed files, repeat the
same 'build-script' command.
Typical uses of 'build-script'
------------------------------
To build everything with optimization without debug information:
[~/src/s]$ ./swift/utils/build-script -R
To run tests, add '-t':
[~/src/s]$ ./swift/utils/build-script -R -t
To run normal tests and validation tests, add '-T':
[~/src/s]$ ./swift/utils/build-script -R -T
To build LLVM+Clang with optimization without debug information, and a
debuggable Swift compiler:
[~/src/s]$ ./swift/utils/build-script -R --debug-swift
To build a debuggable Swift standard library:
[~/src/s]$ ./swift/utils/build-script -R --debug-swift-stdlib
iOS build targets are always configured and present, but are not build by
default. To build the standard library for OS X, iOS simulator and iOS device:
[~/src/s]$ ./swift/utils/build-script -R -i
To run OS X and iOS tests that don't require a device:
[~/src/s]$ ./swift/utils/build-script -R -i -t
To use 'make' instead of 'ninja', use '-m':
[~/src/s]$ ./swift/utils/build-script -m -R
To create Xcode projects that can build Swift, use '-x':
[~/src/s]$ ./swift/utils/build-script -x -R
The Xcode IDE may have performance issues with this configuration. To create
slimmer Xcode projects that can edit Swift compiler source, but cannot build,
use '-X' instead:
[~/src/s]$ ./swift/utils/build-script -X -R
Preset mode in build-script
---------------------------
All buildbots and automated environments use 'build-script' in *preset mode*.
In preset mode, the command line only specifies the preset name and allows
limited customization (extra output paths). The actual options come from
the selected preset in 'utils/build-presets.ini'. For example, to build like
the incremental buildbot, run:
[~/src/s]$ ./swift/utils/build-script --preset=buildbot_incremental
To build with AddressSanitizer:
[~/src/s]$ ./swift/utils/build-script --preset=asan
To build a root for Xcode XYZ, '/tmp/xcode-xyz-root.tar.gz':
[~/src/s]$ ./swift/utils/build-script --preset=buildbot_BNI_internal_XYZ \\
install_destdir="/tmp/install"
install_symroot="/tmp/symroot"
installable_package="/tmp/xcode-xyz-root.tar.gz"
If you have your own favorite set of options, you can create your own, local,
preset. For example, let's create a preset called 'ds' (which stands for
Debug Swift):
$ cat > ~/.swift-build-presets
[preset: ds]
release
debug-swift
debug-swift-stdlib
test
build-subdir=ds
To use it, specify the '--preset=' argument:
[~/src/s]$ ./swift/utils/build-script --preset=ds
./swift/utils/build-script: using preset 'ds', which expands to
./swift/utils/build-script --release --debug-swift --debug-swift-stdlib --test
--build-subdir=ds --
...
Philosophy
----------
While you can invoke CMake directly to build Swift, this tool will save you
time by taking away the mechanical parts of the process, providing you controls
for the important options.
For all automated build environments, this tool is regarded as *the* *only* way
to build Swift. This is not a technical limitation of the Swift build system.
It is a policy decision aimed at making the builds uniform across all
environments and easily reproducible by engineers who are not familiar with the
details of the setups of other systems or automated environments.""")
projects_group = parser.add_argument_group(
title="Options to select projects")
projects_group.add_argument("-l", "--lldb",
help="build LLDB",
action="store_true",
dest="build_lldb")
projects_group.add_argument("-b", "--llbuild",
help="build llbuild",
action="store_true",
dest="build_llbuild")
projects_group.add_argument("-p", "--swiftpm",
help="build swiftpm",
action="store_true",
dest="build_swiftpm")
projects_group.add_argument("--xctest",
help="build xctest",
action="store_true",
dest="build_xctest")
projects_group.add_argument("--foundation",
help="build foundation",
action="store_true",
dest="build_foundation")
extra_actions_group = parser.add_argument_group(
title="Extra actions to perform before building")
extra_actions_group.add_argument("-c", "--clean",
help="do a clean build",
action="store_true")
build_variant_group = parser.add_mutually_exclusive_group(required=False)
build_variant_group.add_argument("-d", "--debug",
help="""
build the Debug variant of everything (LLVM, Clang, Swift host tools, target
Swift standard libraries, LLDB (if enabled)
(default)""",
action="store_const",
const="Debug",
dest="build_variant")
build_variant_group.add_argument("-r", "--release-debuginfo",
help="""
build the RelWithDebInfo variant of everything (default is Debug)""",
action="store_const",
const="RelWithDebInfo",
dest="build_variant")
build_variant_group.add_argument("-R", "--release",
help="build the Release variant of everything (default is Debug)",
action="store_const",
const="Release",
dest="build_variant")
build_variant_override_group = parser.add_argument_group(
title="Override build variant for a specific project")
build_variant_override_group.add_argument("--debug-llvm",
help="build the Debug variant of LLVM",
action="store_const",
const="Debug",
dest="llvm_build_variant")
build_variant_override_group.add_argument("--debug-swift",
help="build the Debug variant of Swift host tools",
action="store_const",
const="Debug",
dest="swift_build_variant")
build_variant_override_group.add_argument("--debug-swift-stdlib",
help="""
build the Debug variant of the Swift standard library and SDK overlay""",
action="store_const",
const="Debug",
dest="swift_stdlib_build_variant")
build_variant_override_group.add_argument("--debug-lldb",
help="build the Debug variant of LLDB",
action="store_const",
const="Debug",
dest="lldb_build_variant")
build_variant_override_group.add_argument("--debug-cmark",
help="build the Debug variant of CommonMark",
action="store_const",
const="Debug",
dest="cmark_build_variant")
build_variant_override_group.add_argument("--debug-foundation",
help="build the Debug variant of Foundation",
action="store_const",
const="Debug",
dest="foundation_build_variant")
assertions_group = parser.add_mutually_exclusive_group(required=False)
assertions_group.add_argument("--assertions",
help="enable assertions in all projects",
action="store_const",
const=True,
dest="assertions")
assertions_group.add_argument("--no-assertions",
help="disable assertions in all projects",
action="store_const",
const=False,
dest="assertions")
assertions_override_group = parser.add_argument_group(
title="Control assertions in a specific project")
assertions_override_group.add_argument("--cmark-assertions",
help="enable assertions in CommonMark",
action="store_const",
const=True,
dest="cmark_assertions")
assertions_override_group.add_argument("--llvm-assertions",
help="enable assertions in LLVM",
action="store_const",
const=True,
dest="llvm_assertions")
assertions_override_group.add_argument("--no-llvm-assertions",
help="disable assertions in LLVM",
action="store_const",
const=False,
dest="llvm_assertions")
assertions_override_group.add_argument("--swift-assertions",
help="enable assertions in Swift",
action="store_const",
const=True,
dest="swift_assertions")
assertions_override_group.add_argument("--no-swift-assertions",
help="disable assertions in Swift",
action="store_const",
const=False,
dest="swift_assertions")
assertions_override_group.add_argument("--swift-stdlib-assertions",
help="enable assertions in the Swift standard library",
action="store_const",
const=True,
dest="swift_stdlib_assertions")
assertions_override_group.add_argument("--no-swift-stdlib-assertions",
help="disable assertions in the Swift standard library",
action="store_const",
const=False,
dest="swift_stdlib_assertions")
assertions_override_group.add_argument("--lldb-assertions",
help="enable assertions in LLDB",
action="store_const",
const=True,
dest="lldb_assertions")
assertions_override_group.add_argument("--no-lldb-assertions",
help="disable assertions in LLDB",
action="store_const",
const=False,
dest="lldb_assertions")
cmake_generator_group = parser.add_argument_group(
title="Select the CMake generator")
cmake_generator_group.add_argument("-x", "--xcode",
help="use CMake's Xcode generator (default is Ninja)",
action="store_const",
const="Xcode",
dest="cmake_generator")
cmake_generator_group.add_argument("-X", "--xcode-ide-only",
help="use CMake's Xcode generator, with only IDE support (no build)",
action="store_const",
const="XcodeIDEOnly",
dest="cmake_generator")
cmake_generator_group.add_argument("-m", "--make",
help="use CMake's Makefile generator (default is Ninja)",
action="store_const",
const="Unix Makefiles",
dest="cmake_generator")
cmake_generator_group.add_argument("-e", "--eclipse",
help="use CMake's Eclipse generator (default is Ninja)",
action="store_const",
const="Eclipse CDT4 - Ninja",
dest="cmake_generator")
run_tests_group = parser.add_argument_group(
title="Run tests")
run_tests_group.add_argument("-t", "--test",
help="test Swift after building",
action="store_true")
run_tests_group.add_argument("-T", "--validation-test",
help="run the validation test suite (implies --test)",
action="store_true")
parser.add_argument("-o", "--test-optimized",
help="run the test suite in optimized mode too (implies --test)",
action="store_true")
run_build_group = parser.add_argument_group(
title="Run build")
run_build_group.add_argument("-S", "--skip-build",
help="generate build directory only without building",
action="store_true")
parser.add_argument("-i", "--ios",
help="""
also build for iOS, but disallow tests that require an iOS device""",
action="store_true")
parser.add_argument("--tvos",
help="""
also build for tvOS, but disallow tests that require an tvos device""",
action="store_true")
parser.add_argument("--watchos",
help="""
also build for Apple watchos, but disallow tests that require an watchOS device""",
action="store_true")
parser.add_argument("--build-subdir",
help="""
name of the directory under $SWIFT_BUILD_ROOT where the build products will be
placed""",
metavar="PATH")
parser.add_argument("--extra-swift-args", help=textwrap.dedent("""
Pass through extra flags to swift in the form of a cmake list 'module_regexp;flag'. Can
be called multiple times to add multiple such module_regexp flag pairs. All semicolons
in flags must be scaped with a '\'"""),
action="append", dest="extra_swift_args", default=[])
parser.add_argument("build_script_impl_args",
help="",
nargs="*")
args = parser.parse_args()
# Build cmark if any cmark-related options were specified.
if (args.cmark_build_variant is not None):
args.build_cmark = True
# Build LLDB if any LLDB-related options were specified.
if (args.lldb_build_variant is not None or
args.lldb_assertions is not None):
args.build_lldb = True
# Set the default build variant.
if args.build_variant is None:
args.build_variant = "Debug"
if args.cmark_build_variant is None:
args.cmark_build_variant = args.build_variant
# Propagate the default build variant.
if args.llvm_build_variant is None:
args.llvm_build_variant = args.build_variant
if args.swift_build_variant is None:
args.swift_build_variant = args.build_variant
if args.swift_stdlib_build_variant is None:
args.swift_stdlib_build_variant = args.build_variant
if args.lldb_build_variant is None:
args.lldb_build_variant = args.build_variant
if args.foundation_build_variant is None:
args.foundation_build_variant = args.build_variant
# Assertions are enabled by default.
if args.assertions is None:
args.assertions = True
# Propagate the default assertions setting.
if args.cmark_assertions is None:
args.cmark_assertions = args.assertions
if args.llvm_assertions is None:
args.llvm_assertions = args.assertions
if args.swift_assertions is None:
args.swift_assertions = args.assertions
if args.swift_stdlib_assertions is None:
args.swift_stdlib_assertions = args.assertions
# Set the default CMake generator.
if args.cmake_generator is None:
args.cmake_generator = "Ninja"
# --validation-test implies --test.
if args.validation_test:
args.test = True
# --test-optimized implies --test.
if args.test_optimized:
args.test = True
build_script_impl_inferred_args = []
if args.cmake_generator == "XcodeIDEOnly":
args.cmake_generator = "Xcode"
build_script_impl_inferred_args += [
"--xcode-ide-only"
]
if not args.test:
build_script_impl_inferred_args += [
"--skip-test-cmark",
"--skip-test-lldb",
"--skip-test-swift",
"--skip-test-llbuild",
"--skip-test-swiftpm",
"--skip-test-xctest",
"--skip-test-foundation",
"--skip-test-ios",
"--skip-test-tvos",
"--skip-test-watchos",
]
if not args.validation_test:
build_script_impl_inferred_args += [
"--skip-test-validation"
]
if not args.test_optimized:
build_script_impl_inferred_args += [
"--skip-test-optimized"
]
if not args.ios:
build_script_impl_inferred_args += [
"--skip-build-ios",
"--skip-test-ios"
]
if not args.tvos:
build_script_impl_inferred_args += [
"--skip-build-tvos",
"--skip-test-tvos",
]
if not args.watchos:
build_script_impl_inferred_args += [
"--skip-build-watchos",
"--skip-test-watchos",
]
if not args.build_lldb:
build_script_impl_inferred_args += [
"--skip-build-lldb"
]
else:
import platform
if platform.system() == "Darwin":
# Validate the LLDB build variant, exiting the
# build if it is not supported.
supported_variants = [
"Debug",
"Release"
]
if args.lldb_build_variant is not None:
lldb_build_variant = args.lldb_build_variant
else:
lldb_build_variant = args.build_variant
if lldb_build_variant not in supported_variants:
sys.stderr.write(
"The Swift LLDB build does not support build variant %s\n"
% lldb_build_variant)
sys.stderr.write(
"Please select one of the following variants: %s\n" %
", ".join(supported_variants))
sys.exit(1)
if not args.build_llbuild:
build_script_impl_inferred_args += [
"--skip-build-llbuild"
]
if not args.build_swiftpm:
build_script_impl_inferred_args += [
"--skip-build-swiftpm"
]
if not args.build_xctest:
build_script_impl_inferred_args += [
"--skip-build-xctest"
]
if not args.build_foundation:
build_script_impl_inferred_args += [
"--skip-build-foundation"
]
if args.skip_build:
build_script_impl_inferred_args += [
"--skip-build"
]
if args.build_subdir is None:
# Create a name for the build directory.
args.build_subdir = args.cmake_generator.replace(" ", "_")
cmark_build_dir_label = args.cmark_build_variant
if args.cmark_assertions:
cmark_build_dir_label += "Assert"
llvm_build_dir_label = args.llvm_build_variant
if args.llvm_assertions:
llvm_build_dir_label += "Assert"
swift_build_dir_label = args.swift_build_variant
if args.swift_assertions:
swift_build_dir_label += "Assert"
swift_stdlib_build_dir_label = args.swift_stdlib_build_variant
if args.swift_stdlib_assertions:
swift_stdlib_build_dir_label += "Assert"
# FIXME: mangle LLDB build configuration into the directory name.
if (llvm_build_dir_label == swift_build_dir_label and
llvm_build_dir_label == swift_stdlib_build_dir_label and
llvm_build_dir_label == cmark_build_dir_label):
# Use a simple directory name if all projects use the same build type.
args.build_subdir += "-" + llvm_build_dir_label
elif (llvm_build_dir_label != swift_build_dir_label and
llvm_build_dir_label == swift_stdlib_build_dir_label and
llvm_build_dir_label == cmark_build_dir_label):
# Swift build type differs.
args.build_subdir += "-" + llvm_build_dir_label
args.build_subdir += "+swift-" + swift_build_dir_label
elif (llvm_build_dir_label == swift_build_dir_label and
llvm_build_dir_label != swift_stdlib_build_dir_label and
llvm_build_dir_label == cmark_build_dir_label):
# Swift stdlib build type differs.
args.build_subdir += "-" + llvm_build_dir_label
args.build_subdir += "+stdlib-" + swift_stdlib_build_dir_label
elif (llvm_build_dir_label == swift_build_dir_label and
llvm_build_dir_label == swift_stdlib_build_dir_label and
llvm_build_dir_label != cmark_build_dir_label):
# cmark build type differs.
args.build_subdir += "-" + llvm_build_dir_label
args.build_subdir += "+cmark-" + cmark_build_dir_label
else:
# We don't know how to create a short name, so just mangle in all
# the information.
args.build_subdir += "+cmark-" + cmark_build_dir_label
args.build_subdir += "+llvm-" + llvm_build_dir_label
args.build_subdir += "+swift-" + swift_build_dir_label
args.build_subdir += "+stdlib-" + swift_stdlib_build_dir_label
build_dir = os.path.join(SWIFT_BUILD_ROOT, args.build_subdir)
if args.clean:
shutil.rmtree(build_dir)
build_script_impl_args = [
os.path.join(SWIFT_SOURCE_ROOT, "swift", "utils", "build-script-impl"),
"--build-dir", build_dir,
"--cmark-build-type", args.cmark_build_variant,
"--llvm-build-type", args.llvm_build_variant,
"--swift-build-type", args.swift_build_variant,
"--swift-stdlib-build-type", args.swift_stdlib_build_variant,
"--lldb-build-type", args.lldb_build_variant,
"--llvm-enable-assertions", str(args.llvm_assertions).lower(),
"--swift-enable-assertions", str(args.swift_assertions).lower(),
"--swift-stdlib-enable-assertions", str(args.swift_stdlib_assertions).lower(),
"--cmake-generator", args.cmake_generator,
"--workspace", SWIFT_SOURCE_ROOT
]
if args.build_foundation:
build_script_impl_args += [
"--foundation-build-type", args.foundation_build_variant
]
build_script_impl_args += build_script_impl_inferred_args
# If we have extra_swift_args, combine all of them together and then add
# them as one command.
if args.extra_swift_args:
build_script_impl_args += ["--extra-swift-args", ";".join(args.extra_swift_args)]
build_script_impl_args += args.build_script_impl_args
# Unset environment variables that might affect how tools behave.
for v in [ 'MAKEFLAGS', 'SDKROOT', 'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET' ]:
os.environ.pop(v, None)
check_call(build_script_impl_args)
return 0
def main():
if not SWIFT_SOURCE_ROOT:
print_with_argv0("Could not infer source root directory. " +
"Forgot to set $SWIFT_SOURCE_ROOT environment variable?")
return 1
if not os.path.isdir(SWIFT_SOURCE_ROOT):
print_with_argv0("Source root directory \'" + SWIFT_SOURCE_ROOT +
"\' does not exist. " +
"Forgot to set $SWIFT_SOURCE_ROOT environment variable?")
return 1
# Determine if we are invoked in the preset mode and dispatch accordingly.
if any([ (opt.startswith("--preset") or opt == "--show-presets")
for opt in sys.argv[1:] ]):
return main_preset()
else:
return main_normal()
if __name__ == "__main__":
sys.exit(main())