@@ -68,10 +68,55 @@ def call_without_sleeping(command, dry_run=False):
68
68
class BuildScriptInvocation (object ):
69
69
"""Represent a single build script invocation."""
70
70
71
+ @staticmethod
72
+ def validate_arguments (toolchain , args ):
73
+ if toolchain .cc is None or toolchain .cxx is None :
74
+ diagnostics .fatal (
75
+ "can't find clang (please install clang-3.5 or a "
76
+ "later version)" )
77
+
78
+ if toolchain .cmake is None :
79
+ diagnostics .fatal ("can't find CMake (please install CMake)" )
80
+
81
+ if args .distcc :
82
+ if toolchain .distcc is None :
83
+ diagnostics .fatal (
84
+ "can't find distcc (please install distcc)" )
85
+ if toolchain .distcc_pump is None :
86
+ diagnostics .fatal (
87
+ "can't find distcc-pump (please install distcc-pump)" )
88
+
89
+ if args .host_target is None or args .stdlib_deployment_targets is None :
90
+ diagnostics .fatal ("unknown operating system" )
91
+
92
+ if args .symbols_package :
93
+ if not os .path .isabs (args .symbols_package ):
94
+ print (
95
+ '--symbols-package must be an absolute path '
96
+ '(was \' {}\' )' .format (args .symbols_package ))
97
+ return 1
98
+ if not args .install_symroot :
99
+ diagnostics .fatal (
100
+ "--install-symroot is required when specifying "
101
+ "--symbols-package." )
102
+
103
+ if args .android :
104
+ if args .android_ndk is None or \
105
+ args .android_api_level is None or \
106
+ args .android_icu_uc is None or \
107
+ args .android_icu_uc_include is None or \
108
+ args .android_icu_i18n is None or \
109
+ args .android_icu_i18n_include is None :
110
+ diagnostics .fatal (
111
+ "when building for Android, --android-ndk, "
112
+ "--android-ndk-version, --android-icu-uc, "
113
+ "--android-icu-uc-include, --android-icu-i18n, "
114
+ "and --android-icu-i18n-include must be specified" )
115
+
71
116
@staticmethod
72
117
def apply_default_arguments (toolchain , args ):
73
118
"""Preprocess an argument set to apply default behaviors."""
74
-
119
+
75
120
# Build cmark if any cmark-related options were specified.
76
121
if (args .cmark_build_variant is not None ):
77
122
args .build_cmark = True
@@ -237,7 +282,7 @@ class BuildScriptInvocation(object):
237
282
if args .android :
238
283
args .stdlib_deployment_targets .append (
239
284
StdlibDeploymentTarget .Android .armv7 )
240
-
285
+
241
286
def __init__ (self , toolchain , args ):
242
287
self .toolchain = toolchain
243
288
self .args = args
@@ -286,7 +331,7 @@ class BuildScriptInvocation(object):
286
331
# Create local shadows, for convenience.
287
332
args = self .args
288
333
toolchain = self .toolchain
289
-
334
+
290
335
cmake = CMake (args = args ,
291
336
toolchain = self .toolchain )
292
337
@@ -454,8 +499,8 @@ class BuildScriptInvocation(object):
454
499
args .install_prefix ),
455
500
]
456
501
457
- # If we have extra_swift_args, combine all of them together and then add
458
- # them as one command.
502
+ # If we have extra_swift_args, combine all of them together and then
503
+ # add them as one command.
459
504
if args .extra_swift_args :
460
505
impl_args += [
461
506
"--extra-swift-args" ,
@@ -468,7 +513,7 @@ class BuildScriptInvocation(object):
468
513
"--extra-cmake-options=%s" % ' ' .join (
469
514
pipes .quote (opt ) for opt in args .extra_cmake_options )
470
515
]
471
-
516
+
472
517
if args .lto :
473
518
impl_args += [
474
519
"--llvm-enable-lto" ,
@@ -493,13 +538,12 @@ class BuildScriptInvocation(object):
493
538
494
539
return impl_args
495
540
541
+
496
542
# Main entry point for the preset mode.
497
543
def main_preset ():
498
544
parser = argparse .ArgumentParser (
499
545
formatter_class = argparse .RawDescriptionHelpFormatter ,
500
- description =
501
-
502
- """Builds Swift using a preset.""" )
546
+ description = """Builds Swift using a preset.""" )
503
547
parser .add_argument (
504
548
"-n" , "--dry-run" ,
505
549
help = "print the commands that would be executed, but do not execute "
@@ -1469,51 +1513,12 @@ details of the setups of other systems or automated environments.""")
1469
1513
if args .cmake is not None :
1470
1514
toolchain .cmake = args .cmake
1471
1515
1472
- if toolchain .cc is None or toolchain .cxx is None :
1473
- diagnostics .fatal (
1474
- "can't find clang (please install clang-3.5 or a later version)" )
1475
-
1476
- if toolchain .cmake is None :
1477
- diagnostics .fatal ("can't find CMake (please install CMake)" )
1478
-
1479
- if args .distcc :
1480
- if toolchain .distcc is None :
1481
- diagnostics .fatal (
1482
- "can't find distcc (please install distcc)" )
1483
- if toolchain .distcc_pump is None :
1484
- diagnostics .fatal (
1485
- "can't find distcc-pump (please install distcc-pump)" )
1486
-
1487
- if args .host_target is None or args .stdlib_deployment_targets is None :
1488
- diagnostics .fatal ("unknown operating system" )
1489
-
1490
- if args .symbols_package :
1491
- if not os .path .isabs (args .symbols_package ):
1492
- print (
1493
- '--symbols-package must be an absolute path '
1494
- '(was \' {}\' )' .format (args .symbols_package ))
1495
- return 1
1496
- if not args .install_symroot :
1497
- diagnostics .fatal (
1498
- "--install-symroot is required when specifying "
1499
- "--symbols-package." )
1500
-
1501
- if args .android :
1502
- if args .android_ndk is None or \
1503
- args .android_api_level is None or \
1504
- args .android_icu_uc is None or \
1505
- args .android_icu_uc_include is None or \
1506
- args .android_icu_i18n is None or \
1507
- args .android_icu_i18n_include is None :
1508
- diagnostics .fatal ("when building for Android, --android-ndk, "
1509
- "--android-ndk-version, --android-icu-uc, "
1510
- "--android-icu-uc-include, --android-icu-i18n, "
1511
- "and --android-icu-i18n-include must be "
1512
- "specified" )
1516
+ # Validate the arguments.
1517
+ BuildScriptInvocation .validate_arguments (toolchain , args )
1513
1518
1514
1519
# Preprocess the arguments to apply defaults.
1515
1520
BuildScriptInvocation .apply_default_arguments (toolchain , args )
1516
-
1521
+
1517
1522
# Create the build script invocation.
1518
1523
invocation = BuildScriptInvocation (toolchain , args )
1519
1524
0 commit comments