forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-script-impl
executable file
·3367 lines (3065 loc) · 152 KB
/
build-script-impl
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
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#===--- build-script-impl - Implementation details of build-script ---------===#
#
## This source file is part of the Swift.org open source project
##
## Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
## Licensed under Apache License v2.0 with Runtime Library Exception
##
## See https://swift.org/LICENSE.txt for license information
## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
#===------------------------------------------------------------------------===#
#
# This script is an implementation detail of other build scripts and should not
# be called directly.
#
# Note: This script will NOT auto-clean before building.
#
set -o pipefail
set -e
umask 0022
# Declare the set of known settings along with each one's description
#
# If you add a user-settable variable, add it to this list.
#
# A default value of "" indicates that the corresponding variable
# will remain unset unless set explicitly.
#
# skip-* parameters do not affect the configuration (CMake parameters).
# You can turn them on and off in different invocations of the script for the
# same build directory.
#
# build-* parameters affect the CMake configuration (enable/disable those
# components).
#
# Each variable name is re-exported into this script in uppercase, where dashes
# are substituted by underscores. For example, `swift-install-components` is
# referred to as `SWIFT_INSTALL_COMPONENTS` in the remainder of this script.
KNOWN_SETTINGS=(
# name default description
dry-run "" "print the commands that would be executed, but do not execute them"
build-args "" "arguments to the build tool; defaults to -j8 when CMake generator is \"Unix Makefiles\""
build-dir "" "out-of-tree build directory; default is in-tree. **This argument is required**"
host-cc "" "the path to CC, the 'clang' compiler for the host platform. **This argument is required**"
host-cxx "" "the path to CXX, the 'clang++' compiler for the host platform. **This argument is required**"
host-lipo "" "the path to lipo for creating universal binaries on Darwin"
host-libtool "" "the path to libtool"
darwin-xcrun-toolchain "default" "the name of the toolchain to use on Darwin"
ninja-bin "" "the path to Ninja tool"
cmark-build-type "Debug" "the CMake build variant for CommonMark (Debug, RelWithDebInfo, Release, MinSizeRel). Defaults to Debug."
lldb-extra-cmake-args "" "extra command line args to pass to lldb cmake"
lldb-extra-xcodebuild-args "" "extra command line args to pass to lldb xcodebuild"
lldb-test-cc "" "CC to use for building LLDB testsuite test inferiors. Defaults to just-built, in-tree clang. If set to 'host-toolchain', sets it to same as host-cc."
lldb-test-with-curses "" "run test lldb test runner using curses terminal control"
lldb-test-swift-only "" "when running lldb tests, only include Swift-specific tests"
lldb-no-debugserver "" "delete debugserver after building it, and don't try to codesign it"
lldb-use-system-debugserver "" "don't try to codesign debugserver, and use the system's debugserver instead"
llvm-build-type "Debug" "the CMake build variant for LLVM and Clang (Debug, RelWithDebInfo, Release, MinSizeRel). Defaults to Debug."
swift-build-type "Debug" "the CMake build variant for Swift"
swift-enable-assertions "1" "enable assertions in Swift"
swift-analyze-code-coverage "not-merged" "Code coverage analysis mode for Swift (false, not-merged, merged). Defaults to false if the argument is not present, and not-merged if the argument is present without a modifier."
swift-tools-enable-lto "" "enable LTO compilation of Swift tools. *NOTE* This does not include the swift standard library and runtime. Must be set to one of 'thin' or 'full'"
llvm-enable-lto "" "Must be set to one of 'thin' or 'full'"
llvm-enable-modules "0" "enable building llvm using modules"
swift-tools-num-parallel-lto-link-jobs "" "The number of parallel link jobs to use when compiling swift tools"
llvm-num-parallel-lto-link-jobs "" "The number of parallel link jobs to use when compiling llvm"
swift-stdlib-build-type "Debug" "the CMake build variant for Swift"
swift-stdlib-enable-assertions "1" "enable assertions in Swift"
swift-stdlib-enable-resilience "0" "build the Swift stdlib and overlays with resilience enabled"
swift-stdlib-use-nonatomic-rc "0" "build the Swift stdlib and overlays with nonatomic reference count operations enabled"
swift-stdlib-sil-serialize-all "1" "build the Swift stdlib and overlays with all method bodies serialized"
lldb-build-type "Debug" "the CMake build variant for LLDB"
llbuild-build-type "Debug" "the CMake build variant for llbuild"
foundation-build-type "Debug" "the build variant for Foundation"
libdispatch-build-type "Debug" "the build variant for libdispatch"
libicu-build-type "Debug" "the build variant for libicu"
playgroundlogger-build-type "Debug" "the build variant for PlaygroundLogger"
playgroundsupport-build-type "Debug" "the build variant for PlaygroundSupport"
xctest-build-type "Debug" "the build variant for xctest"
swiftpm-build-type "Debug" "the build variant for swiftpm"
llbuild-enable-assertions "1" "enable assertions in llbuild"
enable-asan "" "enable Address Sanitizer"
cmake "" "path to the cmake binary"
distcc "" "use distcc in pump mode"
distcc-pump "" "the path to distcc pump executable. This argument is required if distcc is set."
build-runtime-with-host-compiler "" "use the host c++ compiler to build everything"
cmake-generator "Unix Makefiles" "kind of build system to generate; see output of 'cmake --help' for choices"
verbose-build "" "print the commands executed during the build"
install-prefix "" "installation prefix"
toolchain-prefix "" "the path to the .xctoolchain directory that houses the install prefix path"
install-destdir "" "the path to use as the filesystem root for the installation"
install-symroot "" "the path to install debug symbols into"
swift-install-components "" "a semicolon-separated list of Swift components to install"
llvm-install-components "" "a semicolon-separated list of LLVM components to install"
installable-package "" "the path to the archive of the installation directory"
test-installable-package "" "whether to run post-packaging tests on the produced package"
reconfigure "" "force a CMake configuration run even if CMakeCache.txt already exists"
skip-reconfigure "" "set to skip reconfigure"
swift-primary-variant-sdk "" "default SDK for target binaries"
swift-primary-variant-arch "" "default arch for target binaries"
skip-build-cmark "" "set to skip building CommonMark"
skip-build-llvm "" "set to skip building LLVM/Clang"
skip-build-compiler-rt "" "set to skip building Compiler-RT"
skip-build-swift "" "set to skip building Swift"
skip-build-linux "" "set to skip building Swift stdlibs for Linux"
skip-build-freebsd "" "set to skip building Swift stdlibs for FreeBSD"
skip-build-cygwin "" "set to skip building Swift stdlibs for Cygwin"
skip-build-osx "" "set to skip building Swift stdlibs for OS X"
skip-build-ios-device "" "set to skip building Swift stdlibs for iOS devices (i.e. build simulators only)"
skip-build-ios-simulator "" "set to skip building Swift stdlibs for iOS simulators (i.e. build devices only)"
skip-build-tvos-device "" "set to skip building Swift stdlibs for tvOS devices (i.e. build simulators only)"
skip-build-tvos-simulator "" "set to skip building Swift stdlibs for tvOS simulators (i.e. build devices only)"
skip-build-watchos-device "" "set to skip building Swift stdlibs for Apple watchOS devices (i.e. build simulators only)"
skip-build-watchos-simulator "" "set to skip building Swift stdlibs for Apple watchOS simulators (i.e. build devices only)"
skip-build-android "" "set to skip building Swift stdlibs for Android"
skip-build-lldb "" "set to skip building LLDB"
skip-build-llbuild "" "set to skip building llbuild"
skip-build-swiftpm "" "set to skip building swiftpm"
skip-build-xctest "" "set to skip building xctest"
skip-build-foundation "" "set to skip building foundation"
skip-build-libdispatch "" "set to skip building libdispatch"
skip-build-libicu "" "set to skip building libicu"
skip-build-benchmarks "" "set to skip building Swift Benchmark Suite"
skip-build-playgroundlogger "" "set to skip building PlaygroundLogger"
skip-build-playgroundsupport "" "set to skip building PlaygroundSupport"
skip-test-cmark "" "set to skip testing CommonMark"
skip-test-lldb "" "set to skip testing lldb"
skip-test-swift "" "set to skip testing Swift"
skip-test-llbuild "" "set to skip testing llbuild"
skip-test-swiftpm "" "set to skip testing swiftpm"
skip-test-xctest "" "set to skip testing xctest"
skip-test-foundation "" "set to skip testing foundation"
skip-test-libdispatch "" "set to skip testing libdispatch"
skip-test-libicu "" "set to skip testing libicu"
skip-test-playgroundlogger "" "set to skip testing PlaygroundLogger"
skip-test-playgroundsupport "" "set to skip testing PlaygroundSupport"
skip-test-linux "" "set to skip testing Swift stdlibs for Linux"
skip-test-freebsd "" "set to skip testing Swift stdlibs for FreeBSD"
skip-test-cygwin "" "set to skip testing Swift stdlibs for Cygwin"
skip-test-osx "" "set to skip testing Swift stdlibs for OS X"
skip-test-ios-simulator "" "set to skip testing Swift stdlibs for iOS simulators (i.e. test devices only)"
skip-test-ios-host "" "set to skip testing the host parts of the iOS toolchain"
skip-test-tvos-simulator "" "set to skip testing Swift stdlibs for tvOS simulators (i.e. test devices only)"
skip-test-tvos-host "" "set to skip testing the host parts of the tvOS toolchain"
skip-test-watchos-simulator "" "set to skip testing Swift stdlibs for Apple watchOS simulators (i.e. test devices only)"
skip-test-watchos-host "" "set to skip testing the host parts of the watchOS toolchain"
skip-test-android-host "" "set to skip testing the host parts of the Android toolchain"
validation-test "0" "set to run the validation test suite"
long-test "0" "set to run the long test suite"
skip-test-benchmarks "" "set to skip running Swift Benchmark Suite"
skip-test-optimized "" "set to skip testing the test suite in optimized mode"
stress-test-sourcekit "" "set to run the stress-SourceKit target"
workspace "${HOME}/src" "source directory containing llvm, clang, swift"
enable-llvm-assertions "1" "set to enable llvm assertions"
build-llvm "1" "set to 1 to build LLVM and Clang"
build-swift-tools "1" "set to 1 to build Swift host tools"
build-swift-dynamic-stdlib "" "set to 1 to build dynamic variants of the Swift standard library"
build-swift-static-stdlib "" "set to 1 to build static variants of the Swift standard library"
build-swift-stdlib-unittest-extra "0" "set to 1 to build optional StdlibUnittest components"
build-swift-dynamic-sdk-overlay "" "set to 1 to build dynamic variants of the Swift SDK overlay"
build-swift-static-sdk-overlay "" "set to 1 to build static variants of the Swift SDK overlay"
build-swift-examples "1" "set to 1 to build examples"
build-swift-remote-mirror "1" "set to 1 to build the Swift Remote Mirror library"
build-serialized-stdlib-unittest "0" "set to 1 to build the StdlibUnittest module with -sil-serialize-all"
build-sil-debugging-stdlib "0" "set to 1 to build the Swift standard library with -gsil to enable debugging and profiling on SIL level"
check-incremental-compilation "0" "set to 1 to compile swift libraries multiple times to check if incremental compilation works"
llvm-include-tests "1" "Set to true to generate testing targets for LLVM. Set to true by default."
swift-include-tests "1" "Set to true to generate testing targets for Swift. This allows the build to proceed when 'test' directory is missing (required for B&I builds)"
native-llvm-tools-path "" "directory that contains LLVM tools that are executable on the build machine"
native-clang-tools-path "" "directory that contains Clang tools that are executable on the build machine"
native-swift-tools-path "" "directory that contains Swift tools that are executable on the build machine"
embed-bitcode-section "0" "embed an LLVM bitcode section in stdlib/overlay binaries for supported platforms"
darwin-crash-reporter-client "" "whether to enable CrashReporter integration"
darwin-stdlib-install-name-dir "" "the directory of the install_name for standard library dylibs"
install-cmark "" "whether to install cmark"
install-swift "" "whether to install Swift"
install-lldb "" "whether to install LLDB"
install-llbuild "" "whether to install llbuild"
install-swiftpm "" "whether to install swiftpm"
install-xctest "" "whether to install xctest"
install-foundation "" "whether to install foundation"
install-libdispatch "" "whether to install libdispatch"
install-libicu "" "whether to install libicu"
install-playgroundlogger "" "whether to install PlaygroundLogger"
install-playgroundsupport "" "whether to install PlaygroundSupport"
darwin-install-extract-symbols "" "whether to extract symbols with dsymutil during installations"
host-target "" "The host target. LLVM, Clang, and Swift will be built for this target. The built LLVM and Clang will be used to compile Swift for the cross-compilation targets. **This argument is required**"
stdlib-deployment-targets "" "space-separated list of targets to configure the Swift standard library to be compiled or cross-compiled for"
build-stdlib-deployment-targets "all" "space-separated list that filters which of the configured targets to build the Swift standard library for, or 'all'"
cross-compile-hosts "" "space-separated list of targets to cross-compile host Swift tools for"
cross-compile-with-host-tools "" "set to use the clang we build for the host to then build the cross-compile hosts"
cross-compile-install-prefixes "" "semicolon-separated list of install prefixes to use for the cross-compiled hosts. The list expands, so if there are more cross-compile hosts than prefixes, unmatched hosts use the last prefix in the list"
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
darwin-deployment-version-osx "10.9" "minimum deployment target version for OS X"
darwin-deployment-version-ios "7.0" "minimum deployment target version for iOS"
darwin-deployment-version-tvos "9.0" "minimum deployment target version for tvOS"
darwin-deployment-version-watchos "2.0" "minimum deployment target version for watchOS"
extra-cmake-options "" "Extra options to pass to CMake for all targets"
extra-swift-args "" "Extra arguments to pass to swift modules which match regex. Assumed to be a flattened cmake list consisting of [module_regexp, args, module_regexp, args, ...]"
sil-verify-all "0" "If enabled, run the SIL verifier after each transform when building Swift files during this build process"
swift-enable-ast-verifier "1" "If enabled, and the assertions are enabled, the built Swift compiler will run the AST verifier every time it is invoked"
swift-runtime-enable-leak-checker "0" "Enable leaks checking routines in the runtime"
use-gold-linker "" "Enable using the gold linker"
darwin-toolchain-bundle-identifier "" "CFBundleIdentifier for xctoolchain info plist"
darwin-toolchain-display-name "" "Display Name for xctoolcain info plist"
darwin-toolchain-display-name-short "" "Display Name with out date for xctoolchain info plist"
darwin-toolchain-name "" "Directory name for xctoolchain"
darwin-toolchain-version "" "Version for xctoolchain info plist and installer pkg"
darwin-toolchain-application-cert "" "Application Cert name to codesign xctoolchain"
darwin-toolchain-installer-cert "" "Installer Cert name to create installer pkg"
darwin-toolchain-installer-package "" "The path to installer pkg"
darwin-sdk-deployment-targets "xctest-ios-8.0" "semicolon-separated list of triples like 'fookit-ios-9.0;barkit-watchos-9.0'"
darwin-overlay-target "" "single overlay target to build, dependencies are computed later"
build-jobs "" "The number of parallel build jobs to use"
darwin-toolchain-alias "" "Swift alias for toolchain"
android-ndk "" "An absolute path to the NDK that will be used as a libc implementation for Android builds"
android-api-level "" "The Android API level to target when building for Android. Currently only 21 or above is supported"
android-ndk-gcc-version "" "The GCC version to use when building for Android. Currently only 4.9 is supported"
android-icu-uc "" "Path to a directory containing libicuuc.so"
android-icu-uc-include "" "Path to a directory containing headers for libicuuc"
android-icu-i18n "" "Path to a directory containing libicui18n.so"
android-icu-i18n-include "" "Path to a directory containing headers libicui18n"
android-deploy-device-path "" "Path on an Android device to which built Swift stdlib products will be deployed"
check-args-only "" "set to check all arguments are known. Exit with status 0 if success, non zero otherwise"
common-cmake-options "" "CMake options used for all targets, including LLVM/Clang"
cmark-cmake-options "" "CMake options used for all cmark targets"
ninja-cmake-options "" "CMake options used for all ninja targets"
foundation-cmake-options "" "CMake options used for all foundation targets"
libdispatch-cmake-options "" "CMake options used for all libdispatch targets"
libicu-cmake-options "" "CMake options used for all libicu targets"
llbuild-cmake-options "" "CMake options used for all llbuild targets"
lldb-cmake-options "" "CMake options used for all lldb targets"
llvm-cmake-options "" "CMake options used for all llvm targets"
ninja-cmake-options "" "CMake options used for all ninja targets"
swift-cmake-options "" "CMake options used for all swift targets"
swiftpm-cmake-options "" "CMake options used for all swiftpm targets"
xctest-cmake-options "" "CMake options used for all xctest targets"
playgroundsupport-cmake-options "" "CMake options used for all playgroundsupport targets"
playgroundlogger-cmake-options "" "CMake options used for all playgroundlogger targets"
# TODO: Remove this some time later.
user-config-args "" "**Renamed to --extra-cmake-options**: User-supplied arguments to cmake when used to do configuration."
only-execute "all" "Only execute the named action (see implementation)"
llvm-lit-args "" "If set, override the lit args passed to LLVM"
clang-profile-instr-use "" "If set, profile file to use for clang PGO"
coverage-db "" "If set, coverage database to use when prioritizing testing"
build-toolchain-only "" "If set, only build the necessary tools to build an external toolchain"
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
swift-runtime-enable-cow-existentials "1" "Enable the copy-on-write existential implementation"
)
# Centralized access point for traced command invocation.
# Every operation that might mutates file system should be called via
# these functions.
function call() {
if [[ ${DRY_RUN} ]]; then
echo "${PS4}"$(quoted_print "$@")
else
{ set -x; } 2>/dev/null
"$@"
{ set +x; } 2>/dev/null
fi
}
function with_pushd() {
local dir=$1
shift
if [[ "$1" == "call" ]]; then
shift
fi
if [[ ${DRY_RUN} ]]; then
echo ${PS4}pushd "${dir}"
echo "${PS4}"$(quoted_print "$@")
echo ${PS4}popd
else
set -x
pushd "${dir}"
"$@"
{ set -x; } 2>/dev/null # because $@ might includes { set +x; }
popd
{ set +x; } 2>/dev/null
fi
}
function quoted_print() {
python -c 'import pipes; import sys; print(" ".join(pipes.quote(arg) for arg in sys.argv[1:]))' "$@"
}
function toupper() {
echo "$@" | tr '[:lower:]' '[:upper:]'
}
function tolower() {
echo "$@" | tr '[:upper:]' '[:lower:]'
}
function true_false() {
case "$1" in
false | FALSE | 0 | "")
echo "FALSE"
;;
true | TRUE | 1)
echo "TRUE"
;;
*)
echo "true_false: unknown value: $1" >&2
exit 1
;;
esac
}
function to_varname() {
toupper "${1//-/_}"
}
function set_lldb_build_mode() {
LLDB_BUILD_MODE="CustomSwift-${LLDB_BUILD_TYPE}"
}
function is_llvm_lto_enabled() {
if [[ "${LLVM_ENABLE_LTO}" == "thin" ]] ||
[[ "${LLVM_ENABLE_LTO}" == "full" ]]; then
echo "TRUE"
else
echo "FALSE"
fi
}
function is_swift_lto_enabled() {
if [[ "${SWIFT_TOOLS_ENABLE_LTO}" == "thin" ]] ||
[[ "${SWIFT_TOOLS_ENABLE_LTO}" == "full" ]]; then
echo "TRUE"
else
echo "FALSE"
fi
}
# Enable module-builds of llvm only when asan is disabled.
# FIXME: rdar://problem/28356072
function is_llvm_module_build_enabled() {
if [[ "$(true_false ${LLVM_ENABLE_MODULES})" == "TRUE" ]] &&
[[ "$(true_false ${ENABLE_ASAN})" == "FALSE" ]]; then
echo "TRUE"
else
echo "FALSE"
fi
}
# Support for performing isolated actions.
#
# This is part of refactoring more work to be done or controllable via
# `build-script` itself. For additional information, see:
# https://bugs.swift.org/browse/SR-237
#
# To use this functionality, the script is invoked with:
# ONLY_EXECUTE=<action name>
# where <action name> is one of:
# all -- execute all actions
# ${host}-${product}-build -- the build of the product
# ${host}-${product}-test -- the test of the product
# ${host}-${product}-install -- the install of the product
# ${host}-package -- the package construction and test
# merged-hosts-lipo -- the lipo step, if used
# and if used, only the one individual action will be performed.
#
# If not set, the default is `all`.
# should_execute_action(name) -> 1 or nil
#
# Check if the named action should be run in the given script invocation.
function should_execute_action() {
local name="$1"
if [[ "${ONLY_EXECUTE}" = "all" ]] ||
[[ "${ONLY_EXECUTE}" = "${name}" ]]; then
echo 1
fi
}
# should_execute_host_actions_for_phase(host, phase-name) -> 1 or nil
#
# Check if the there are any actions to execute for this host and phase (i.e.,
# "build", "test", or "install")
function should_execute_host_actions_for_phase() {
local host="$1"
local phase_name="$2"
if [[ "${ONLY_EXECUTE}" = "all" ]] ||
[[ "${ONLY_EXECUTE}" == ${host}-*-${phase_name} ]]; then
echo 1
fi
}
function set_build_options_for_host() {
llvm_cmake_options=()
swift_cmake_options=()
cmark_cmake_options=()
lldb_cmake_options=()
swiftpm_bootstrap_options=()
SWIFT_HOST_VARIANT=
SWIFT_HOST_VARIANT_SDK=
SWIFT_HOST_VARIANT_ARCH=
SWIFT_HOST_TRIPLE=
USE_GOLD_LINKER=
local host="$1"
# Hosts which can be cross-compiled must specify:
# SWIFT_HOST_TRIPLE and llvm_target_arch (as well as usual HOST_VARIANT flags)
case ${host} in
freebsd-x86_64)
SWIFT_HOST_VARIANT="freebsd"
SWIFT_HOST_VARIANT_SDK="FREEBSD"
SWIFT_HOST_VARIANT_ARCH="x86_64"
USE_GOLD_LINKER=1
;;
cygwin-x86_64)
SWIFT_HOST_VARIANT="cygwin"
SWIFT_HOST_VARIANT_SDK="CYGWIN"
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
linux-*)
SWIFT_HOST_VARIANT="linux"
SWIFT_HOST_VARIANT_SDK="LINUX"
USE_GOLD_LINKER=1
case ${host} in
linux-x86_64)
SWIFT_HOST_VARIANT_ARCH="x86_64"
playgroundlogger_build_cmd="${PLAYGROUNDLOGGER_SOURCE_DIR}/build.py"
playgroundlogger_build_options=(
--swiftc "$(build_directory_bin ${host} swift)"
--foundation "$(build_directory ${host} foundation)"
--build-dir "$(build_directory ${host} playgroundlogger)"
--swift-build-dir "$(build_directory ${host} swift)"
--$(tolower "${PLAYGROUNDLOGGER_BUILD_TYPE}")
)
;;
linux-armv6)
SWIFT_HOST_VARIANT_ARCH="armv6"
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
llvm_target_arch="ARM"
;;
linux-armv7)
SWIFT_HOST_VARIANT_ARCH="armv7"
SWIFT_HOST_TRIPLE="armv7-unknown-linux-gnueabihf"
llvm_target_arch="ARM"
;;
linux-aarch64)
SWIFT_HOST_VARIANT_ARCH="aarch64"
;;
linux-powerpc64)
SWIFT_HOST_VARIANT_ARCH="powerpc64"
;;
linux-powerpc64le)
SWIFT_HOST_VARIANT_ARCH="powerpc64le"
;;
linux-s390x)
SWIFT_HOST_VARIANT_ARCH="s390x"
;;
esac
;;
macosx-* | iphoneos-* | iphonesimulator-* | \
appletvos-* | appletvsimulator-* | \
watchos-* | watchsimulator-*)
case ${host} in
macosx-x86_64)
xcrun_sdk_name="macosx"
llvm_target_arch=""
SWIFT_HOST_TRIPLE="x86_64-apple-macosx${DARWIN_DEPLOYMENT_VERSION_OSX}"
SWIFT_HOST_VARIANT="macosx"
SWIFT_HOST_VARIANT_SDK="OSX"
SWIFT_HOST_VARIANT_ARCH="x86_64"
cmake_osx_deployment_target="${DARWIN_DEPLOYMENT_VERSION_OSX}"
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
-DCMAKE_OSX_DEPLOYMENT_TARGET="${cmake_osx_deployment_target}"
)
swiftpm_bootstrap_options=(
--sysroot="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_TestDriver")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="MacOSX.platform"
;;
iphonesimulator-i386)
xcrun_sdk_name="iphonesimulator"
llvm_target_arch="X86"
SWIFT_HOST_TRIPLE="i386-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
SWIFT_HOST_VARIANT="iphonesimulator"
SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR"
SWIFT_HOST_VARIANT_ARCH="i386"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_iOS")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneSimulator.platform"
;;
iphonesimulator-x86_64)
xcrun_sdk_name="iphonesimulator"
llvm_target_arch="X86"
SWIFT_HOST_TRIPLE="x86_64-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
SWIFT_HOST_VARIANT="iphonesimulator"
SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR"
SWIFT_HOST_VARIANT_ARCH="x86_64"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_iOS")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneSimulator.platform"
;;
iphoneos-armv7)
xcrun_sdk_name="iphoneos"
llvm_target_arch="ARM"
SWIFT_HOST_TRIPLE="armv7-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
SWIFT_HOST_VARIANT="iphoneos"
SWIFT_HOST_VARIANT_SDK="IOS"
SWIFT_HOST_VARIANT_ARCH="armv7"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_iOS")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
;;
iphoneos-armv7s)
xcrun_sdk_name="iphoneos"
llvm_target_arch="ARM"
SWIFT_HOST_TRIPLE="armv7s-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
SWIFT_HOST_VARIANT="iphoneos"
SWIFT_HOST_VARIANT_SDK="IOS"
SWIFT_HOST_VARIANT_ARCH="armv7s"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_iOS")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
;;
iphoneos-arm64)
xcrun_sdk_name="iphoneos"
llvm_target_arch="AArch64"
SWIFT_HOST_TRIPLE="arm64-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
SWIFT_HOST_VARIANT="iphoneos"
SWIFT_HOST_VARIANT_SDK="IOS"
SWIFT_HOST_VARIANT_ARCH="arm64"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_iOS")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
;;
appletvsimulator-x86_64)
xcrun_sdk_name="appletvsimulator"
llvm_target_arch="X86"
SWIFT_HOST_TRIPLE="x86_64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_TVOS}"
SWIFT_HOST_VARIANT="appletvsimulator"
SWIFT_HOST_VARIANT_SDK="TVOS_SIMULATOR"
SWIFT_HOST_VARIANT_ARCH="x86_64"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="AppleTVSimulator.platform"
;;
appletvos-arm64)
xcrun_sdk_name="appletvos"
llvm_target_arch="AArch64"
SWIFT_HOST_TRIPLE="arm64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_TVOS}"
SWIFT_HOST_VARIANT="appletvos"
SWIFT_HOST_VARIANT_SDK="TVOS"
SWIFT_HOST_VARIANT_ARCH="arm64"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
playgroundlogger_build_cmd="xcodebuild"
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
PLAYGROUNDLOGGER_INSTALL_PLATFORM="AppleTVOS.platform"
;;
watchsimulator-i386)
xcrun_sdk_name="watchsimulator"
llvm_target_arch="X86"
SWIFT_HOST_TRIPLE="i386-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
SWIFT_HOST_VARIANT="watchsimulator"
SWIFT_HOST_VARIANT_SDK="WATCHOS_SIMULATOR"
SWIFT_HOST_VARIANT_ARCH="i386"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
;;
watchos-armv7k)
xcrun_sdk_name="watchos"
llvm_target_arch="ARM"
SWIFT_HOST_TRIPLE="armv7k-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
SWIFT_HOST_VARIANT="watchos"
SWIFT_HOST_VARIANT_SDK="WATCHOS"
SWIFT_HOST_VARIANT_ARCH="armv7k"
cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
;;
*)
echo "Unknown host for swift tools: ${host}"
exit 1
;;
esac
if [[ "${DARWIN_SDK_DEPLOYMENT_TARGETS}" != "" ]]; then
local IFS=";"; DARWIN_SDK_DEPLOYMENT_TARGETS=($DARWIN_SDK_DEPLOYMENT_TARGETS)
for target in "${DARWIN_SDK_DEPLOYMENT_TARGETS[@]}"; do
local IFS="-"; triple=($target)
sdk_target=$(toupper ${triple[0]}_${triple[1]})
swift_cmake_options+=(
"-DSWIFTLIB_DEPLOYMENT_VERSION_${sdk_target}=${triple[2]}"
)
done
fi
llvm_cmake_options=(
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${cmake_osx_deployment_target}"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
-DLLVM_ENABLE_LIBCXX:BOOL=TRUE
-DCOMPILER_RT_ENABLE_IOS:BOOL=FALSE
-DCOMPILER_RT_ENABLE_WATCHOS:BOOL=FALSE
-DCOMPILER_RT_ENABLE_TVOS:BOOL=FALSE
-DSANITIZER_MIN_OSX_VERSION="${cmake_osx_deployment_target}"
-DLLVM_ENABLE_MODULES:BOOL="$(is_llvm_module_build_enabled)"
)
if [[ $(is_llvm_lto_enabled) == "TRUE" ]]; then
if [[ $(cmake_needs_to_specify_standard_computed_defaults) == "TRUE" ]]; then
llvm_cmake_options+=(
"-DCMAKE_C_STANDARD_COMPUTED_DEFAULT=AppleClang"
"-DCMAKE_CXX_STANDARD_COMPUTED_DEFAULT=AppleClang"
)
fi
llvm_cmake_options+=(
"-DLLVM_PARALLEL_LINK_JOBS=${LLVM_NUM_PARALLEL_LTO_LINK_JOBS}"
)
fi
if [[ $(is_swift_lto_enabled) == "TRUE" ]]; then
if [[ $(cmake_needs_to_specify_standard_computed_defaults) = "TRUE" ]]; then
swift_cmake_options+=(
"-DCMAKE_C_STANDARD_COMPUTED_DEFAULT=AppleClang"
"-DCMAKE_CXX_STANDARD_COMPUTED_DEFAULT=AppleClang"
)
fi
llvm_cmake_options+=(
-DLLVM_ENABLE_MODULE_DEBUGGING:BOOL=NO
)
swift_cmake_options+=(
-DLLVM_ENABLE_MODULE_DEBUGGING:BOOL=NO
"-DSWIFT_PARALLEL_LINK_JOBS=${SWIFT_TOOLS_NUM_PARALLEL_LTO_LINK_JOBS}"
)
fi
swift_cmake_options+=(
-DSWIFT_DARWIN_DEPLOYMENT_VERSION_OSX="${DARWIN_DEPLOYMENT_VERSION_OSX}"
-DSWIFT_DARWIN_DEPLOYMENT_VERSION_IOS="${DARWIN_DEPLOYMENT_VERSION_IOS}"
-DSWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS="${DARWIN_DEPLOYMENT_VERSION_TVOS}"
-DSWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS="${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
-DLLVM_ENABLE_LIBCXX:BOOL=TRUE
)
;;
*)
echo "Unknown host tools target: ${host}"
exit 1
;;
esac
llvm_cmake_options+=(
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
)
# If we are asked to not generate test targets for LLVM and or Swift,
# disable as many LLVM tools as we can. This improves compile time when
# compiling with LTO.
#
# *NOTE* Currently we do not support testing LLVM via build-script. But in a
# future commit we will.
#for arg in "$(compute_cmake_llvm_tool_disable_flags)"; do
# llvm_cmake_options+=( ${arg} )
#done
if [[ "${llvm_target_arch}" ]] ; then
llvm_cmake_options+=(
-DLLVM_TARGET_ARCH="${llvm_target_arch}"
)
fi
# For cross-compilable hosts, we need to know the triple
# and it must be the same for both LLVM and Swift
if [[ "${SWIFT_HOST_TRIPLE}" ]] ; then
llvm_cmake_options+=(
-DLLVM_HOST_TRIPLE:STRING="${SWIFT_HOST_TRIPLE}"
)
swift_cmake_options+=(
-DSWIFT_HOST_TRIPLE:STRING="${SWIFT_HOST_TRIPLE}"
)
lldb_cmake_options+=(
-DLLVM_HOST_TRIPLE:STRING="${SWIFT_HOST_TRIPLE}"
)
fi
swift_cmake_options+=(
-DSWIFT_HOST_VARIANT="${SWIFT_HOST_VARIANT}"
-DSWIFT_HOST_VARIANT_SDK="${SWIFT_HOST_VARIANT_SDK}"
-DSWIFT_HOST_VARIANT_ARCH="${SWIFT_HOST_VARIANT_ARCH}"
)
if [[ "${LLVM_LIT_ARGS}" ]]; then
llvm_cmake_options+=(
-DLLVM_LIT_ARGS="${LLVM_LIT_ARGS}"
)
swift_cmake_options+=(
-DLLVM_LIT_ARGS="${LLVM_LIT_ARGS}"
)
fi
if [[ "${CLANG_PROFILE_INSTR_USE}" ]]; then
llvm_cmake_options+=(
-DLLVM_PROFDATA_FILE="${CLANG_PROFILE_INSTR_USE}"
)
fi
swift_cmake_options+=(
-DCOVERAGE_DB="${COVERAGE_DB}"
)
}
function configure_default_options() {
# Build a table of all of the known setting variables names.
#
# This is an optimization to do the argument to variable conversion (which is
# slow) in a single pass.
local all_settings=()
for ((i = 0; i < ${#KNOWN_SETTINGS[@]}; i += 3)); do
all_settings+=("${KNOWN_SETTINGS[i]}")
done
local known_setting_varnames=($(to_varname "${all_settings[*]}"))
# Build up an "associative array" mapping setting names to variable names
# (we use this for error checking to identify "known options", and as a fast
# way to map the setting name to a variable name). See the code for scanning
# command line arguments.
#
# This loop also sets (or unsets) each corresponding variable to its default
# value.
#
# NOTE: If the Mac's bash were not stuck in the past, we could "declare -A"
# an associative array, but instead we have to hack it by defining variables.
for ((i = 0; i < ${#KNOWN_SETTINGS[@]}; i += 3)); do
local setting="${KNOWN_SETTINGS[i]}"
local default_value="${KNOWN_SETTINGS[$((i+1))]}"
# Find the variable name in our lookup table.
local varname="${known_setting_varnames[$((i/3))]}"
# Establish the associative array mapping.
eval "${setting//-/_}_VARNAME=${varname}"
if [[ "${default_value}" ]] ; then
# For an explanation of the backslash see http://stackoverflow.com/a/9715377
eval ${varname}=$\default_value
else
unset ${varname}
fi
done
}
configure_default_options
COMMAND_NAME="$(basename "$0")"
# Print instructions for using this script to stdout
usage() {
echo "Usage: ${COMMAND_NAME} [--help|-h] [ --SETTING=VALUE | --SETTING VALUE | --SETTING ]*"
echo
echo " Available settings. Each setting corresponds to a variable,"
echo " obtained by upcasing its name, in this script. A variable"
echo " with no default listed here will be unset in the script if"
echo " not explicitly specified. A setting passed in the 3rd form"
echo " will set its corresponding variable to \"1\"."
echo
setting_list="
| |Setting| Default|Description
| |-------| -------|-----------
"
for ((i = 0; i < ${#KNOWN_SETTINGS[@]}; i += 3)); do
setting_list+="\
| |--${KNOWN_SETTINGS[i]}| ${KNOWN_SETTINGS[$((i+1))]}|${KNOWN_SETTINGS[$((i+2))]}
"
done
echo "${setting_list}" | column -x -s'|' -t
echo
echo "Note: when using the form --SETTING VALUE, VALUE must not begin "
echo " with a hyphen."
echo "Note: the \"--release\" option creates a pre-packaged combination"
echo " of settings used by the buildbot."
echo
echo "Cross-compiling Swift host tools"
echo " When building cross-compiled tools, it first builds for the native"
echo " build host machine. Then it proceeds to build the specified cross-compile"
echo " targets. It currently builds the requested variants of stdlib each"
echo " time around, so once for the native build, then again each time for"
echo " the cross-compile tool targets."
echo
echo " When installing cross-compiled tools, it first installs each target"
echo " arch into a separate subdirectory under install-destdir, since you"
echo " can cross-compile for multiple targets at the same time. It then runs"
echo " recursive-lipo to produce fat binaries by merging the cross-compiled"
echo " targets, installing the merged result into the expected location of"
echo " install-destdir. After that, any remaining steps to extract dsyms and"
echo " create an installable package operates on install-destdir as normal."
}
# Scan all command-line arguments
while [[ "$1" ]] ; do
case "$1" in
-h | --help )
usage
exit
;;
--* )
dashless="${1:2}"
# drop suffix beginning with the first "="
setting="${dashless%%=*}"
# compute the variable to set, using the cached map set up by
# configure_default_options().
varname_var="${setting//-/_}_VARNAME"
varname=${!varname_var}
# check to see if this is a known option
if [[ "${varname}" = "" ]] ; then
echo "error: unknown setting: ${setting}" 1>&2
usage 1>&2
exit 1
fi
# find the intended value
if [[ "${dashless}" == *=* ]] ; then # if there's an '=', the value
value="${dashless#*=}" # is everything after the first '='
elif [[ "$2" ]] && [[ "${2:0:1}" != "-" ]] ; then # else if the next parameter exists
value="$2" # but isn't an option, use that
shift
else # otherwise, the value is 1
value=1
fi
# For explanation of backslash see http://stackoverflow.com/a/9715377
eval ${varname}=$\value
;;
*)
echo "Error: Invalid argument: $1" 1>&2
usage 1>&2
exit 1
esac
shift
done
# TODO: Rename this argument
LOCAL_HOST=$HOST_TARGET
# TODO: Remove this some time later.
if [[ "${USER_CONFIG_ARGS}" ]]; then
echo "Error: --user-config-args is renamed to --extra-cmake-options." 1>&2
exit 1
fi
if [[ "${CHECK_ARGS_ONLY}" ]]; then
exit 0
fi
# FIXME: We currently do not support building compiler-rt with the
# Xcode generator.
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]]; then
SKIP_BUILD_COMPILER_RT=1
fi
# FIXME: We currently do not support cross-compiling swift with compiler-rt.
if [[ "${CROSS_COMPILE_HOSTS}" ]]; then
SKIP_BUILD_COMPILER_RT=1
fi
if [[ "${SKIP_RECONFIGURE}" ]]; then
RECONFIGURE=""
fi
# WORKSPACE, BUILD_DIR and INSTALLABLE_PACKAGE must be absolute paths
case "${WORKSPACE}" in
/*) ;;
*)
echo "workspace must be an absolute path (was '${WORKSPACE}')"
exit 1
;;
esac
case "${BUILD_DIR}" in
/*) ;;
"")
echo "the --build-dir option is required"
usage
exit 1
;;
*)
echo "build-dir must be an absolute path (was '${BUILD_DIR}')"
exit 1
;;
esac
case "${INSTALLABLE_PACKAGE}" in
/*) ;;
"") ;;
*)
echo "installable-package must be an absolute path (was '${INSTALLABLE_PACKAGE}')"
exit 1
;;
esac
# WORKSPACE must exist
if [ ! -e "${WORKSPACE}" ] ; then
echo "Workspace does not exist (tried ${WORKSPACE})"
exit 1
fi
# FIXME: HOST_CC and CMAKE are set, and their presence is validated by,
# utils/build-script. These checks are redundant, but must remain until
# build-script-impl is merged completely with utils/build-script.
# For additional information, see: https://bugs.swift.org/browse/SR-237
if [ -z "${HOST_CC}" ] ; then
echo "Can't find clang. Please install clang-3.5 or a later version."
exit 1
fi
if [ -z "${CMAKE}" ] ; then
echo "Environment variable CMAKE must be specified."
exit 1
fi
function xcrun_find_tool() {
xcrun --sdk macosx --toolchain "${DARWIN_XCRUN_TOOLCHAIN}" --find "$@"
}
function not() {
if [[ ! "$1" ]] ; then
echo 1