@@ -18,7 +18,6 @@ import pipes
18
18
import platform
19
19
import re
20
20
import shlex
21
- import shutil
22
21
import sys
23
22
24
23
# FIXME: Instead of modifying the system path in order to enable imports from
@@ -31,7 +30,6 @@ from SwiftBuildSupport import (
31
30
HOME ,
32
31
SWIFT_BUILD_ROOT ,
33
32
SWIFT_SOURCE_ROOT ,
34
- WorkingDirectory ,
35
33
check_call ,
36
34
get_all_preset_names ,
37
35
get_preset_options ,
@@ -45,6 +43,8 @@ sys.path.append(os.path.join(os.path.dirname(__file__), 'swift_build_support'))
45
43
from swift_build_support .toolchain import host_toolchain # noqa (E402)
46
44
import swift_build_support .debug # noqa (E402)
47
45
from swift_build_support import migration # noqa (E402)
46
+ from swift_build_support import products # noqa (E402)
47
+ from swift_build_support import shell # noqa (E402)
48
48
import swift_build_support .tar # noqa (E402)
49
49
import swift_build_support .targets # noqa (E402)
50
50
from swift_build_support .cmake import CMake # noqa (E402)
@@ -393,6 +393,10 @@ details of the setups of other systems or automated environments.""")
393
393
help = "build libdispatch" ,
394
394
action = "store_true" ,
395
395
dest = "build_libdispatch" )
396
+ projects_group .add_argument (
397
+ "--build-ninja" ,
398
+ help = "build the Ninja tool" ,
399
+ action = "store_true" )
396
400
397
401
extra_actions_group = parser .add_argument_group (
398
402
title = "Extra actions to perform before or in addition to building" )
@@ -938,6 +942,27 @@ details of the setups of other systems or automated environments.""")
938
942
type = argparse_clang_compiler_version ,
939
943
metavar = "MAJOR.MINOR.PATCH" )
940
944
945
+ parser .add_argument (
946
+ "--darwin-deployment-version-osx" ,
947
+ help = "minimum deployment target version for OS X" ,
948
+ metavar = "MAJOR.MINOR" ,
949
+ default = "10.9" )
950
+ parser .add_argument (
951
+ "--darwin-deployment-version-ios" ,
952
+ help = "minimum deployment target version for iOS" ,
953
+ metavar = "MAJOR.MINOR" ,
954
+ default = "7.0" )
955
+ parser .add_argument (
956
+ "--darwin-deployment-version-tvos" ,
957
+ help = "minimum deployment target version for tvOS" ,
958
+ metavar = "MAJOR.MINOR" ,
959
+ default = "9.0" )
960
+ parser .add_argument (
961
+ "--darwin-deployment-version-watchos" ,
962
+ help = "minimum deployment target version for watchOS" ,
963
+ metavar = "MAJOR.MINOR" ,
964
+ default = "2.0" )
965
+
941
966
parser .add_argument (
942
967
"--extra-cmake-options" ,
943
968
help = "Pass through extra options to CMake in the form of comma "
@@ -1098,6 +1123,11 @@ details of the setups of other systems or automated environments.""")
1098
1123
if args .cmake_generator is None :
1099
1124
args .cmake_generator = "Ninja"
1100
1125
1126
+ ninja_required = (
1127
+ args .cmake_generator == 'Ninja' or args .build_foundation )
1128
+ if ninja_required and toolchain .ninja is None :
1129
+ args .build_ninja = True
1130
+
1101
1131
# SwiftPM and XCTest have a dependency on Foundation.
1102
1132
# On OS X, Foundation is built automatically using xcodebuild.
1103
1133
# On Linux, we must ensure that it is built manually.
@@ -1200,8 +1230,41 @@ details of the setups of other systems or automated environments.""")
1200
1230
source_root = SWIFT_SOURCE_ROOT ,
1201
1231
build_root = os .path .join (SWIFT_BUILD_ROOT , args .build_subdir ))
1202
1232
1203
- if args .clean and os .path .isdir (workspace .build_root ):
1204
- shutil .rmtree (workspace .build_root )
1233
+ if args .build_ninja :
1234
+ if not os .path .exists (workspace .source_dir ("ninja" )):
1235
+ print_with_argv0 ("Can't find source directory for ninja "
1236
+ "(tried %s)" % (workspace .source_dir ("ninja" )))
1237
+ return 1
1238
+
1239
+ # Unset environment variables that might affect how tools behave.
1240
+ for v in [
1241
+ 'MAKEFLAGS' ,
1242
+ 'SDKROOT' ,
1243
+ 'MACOSX_DEPLOYMENT_TARGET' ,
1244
+ 'IPHONEOS_DEPLOYMENT_TARGET' ,
1245
+ 'TVOS_DEPLOYMENT_TARGET' ,
1246
+ 'WATCHOS_DEPLOYMENT_TARGET' ]:
1247
+ os .environ .pop (v , None )
1248
+
1249
+ if args .show_sdks :
1250
+ swift_build_support .debug .print_xcodebuild_versions ()
1251
+
1252
+ # Clean build direcotry if requested.
1253
+ if args .clean :
1254
+ shell .rmtree (workspace .build_root )
1255
+
1256
+ # Create build directory.
1257
+ shell .makedirs (workspace .build_root )
1258
+
1259
+ # Build ninja if required.
1260
+ if args .build_ninja :
1261
+ ninja_build = products .Ninja (
1262
+ args = args ,
1263
+ toolchain = toolchain ,
1264
+ source_dir = workspace .source_dir ("ninja" ),
1265
+ build_dir = workspace .build_dir ("build" , "ninja" ))
1266
+ ninja_build .do_build ()
1267
+ toolchain .ninja = ninja_build .ninja_bin_path
1205
1268
1206
1269
cmake = CMake (args = args ,
1207
1270
toolchain = toolchain )
@@ -1216,6 +1279,14 @@ details of the setups of other systems or automated environments.""")
1216
1279
"--host-cc" , toolchain .cc ,
1217
1280
"--host-cxx" , toolchain .cxx ,
1218
1281
"--darwin-xcrun-toolchain" , args .darwin_xcrun_toolchain ,
1282
+ "--darwin-deployment-version-osx=%s" % (
1283
+ args .darwin_deployment_version_osx ),
1284
+ "--darwin-deployment-version-ios=%s" % (
1285
+ args .darwin_deployment_version_ios ),
1286
+ "--darwin-deployment-version-tvos=%s" % (
1287
+ args .darwin_deployment_version_tvos ),
1288
+ "--darwin-deployment-version-watchos=%s" % (
1289
+ args .darwin_deployment_version_watchos ),
1219
1290
"--cmake" , toolchain .cmake ,
1220
1291
"--cmark-build-type" , args .cmark_build_variant ,
1221
1292
"--llvm-build-type" , args .llvm_build_variant ,
@@ -1237,6 +1308,8 @@ details of the setups of other systems or automated environments.""")
1237
1308
pipes .quote (arg ) for arg in cmake .build_args ()),
1238
1309
]
1239
1310
1311
+ if toolchain .ninja :
1312
+ build_script_impl_args += ["--ninja-bin=%s" % toolchain .ninja ]
1240
1313
if args .distcc :
1241
1314
build_script_impl_args += [
1242
1315
"--distcc" ,
@@ -1256,8 +1329,6 @@ details of the setups of other systems or automated environments.""")
1256
1329
build_script_impl_args += [
1257
1330
"--install-symroot" , os .path .abspath (args .install_symroot )
1258
1331
]
1259
- if args .cmake_generator == 'Ninja' and toolchain .ninja is None :
1260
- build_script_impl_args += ["--build-ninja" ]
1261
1332
1262
1333
if args .skip_build :
1263
1334
build_script_impl_args += ["--skip-build-cmark" ,
@@ -1381,19 +1452,6 @@ details of the setups of other systems or automated environments.""")
1381
1452
1382
1453
build_script_impl_args += args .build_script_impl_args
1383
1454
1384
- # Unset environment variables that might affect how tools behave.
1385
- for v in [
1386
- 'MAKEFLAGS' ,
1387
- 'SDKROOT' ,
1388
- 'MACOSX_DEPLOYMENT_TARGET' ,
1389
- 'IPHONEOS_DEPLOYMENT_TARGET' ,
1390
- 'TVOS_DEPLOYMENT_TARGET' ,
1391
- 'WATCHOS_DEPLOYMENT_TARGET' ]:
1392
- os .environ .pop (v , None )
1393
-
1394
- if args .show_sdks :
1395
- swift_build_support .debug .print_xcodebuild_versions ()
1396
-
1397
1455
check_call ([build_script_impl ] + build_script_impl_args ,
1398
1456
disable_sleep = True )
1399
1457
@@ -1411,7 +1469,7 @@ details of the setups of other systems or automated environments.""")
1411
1469
# it is archiving. To stay safe, we change working directories, then
1412
1470
# run `tar` without the leading '/' (we remove it ourselves to keep
1413
1471
# `tar` from emitting a warning).
1414
- with WorkingDirectory (args .install_symroot ):
1472
+ with shell . pushd (args .install_symroot ):
1415
1473
swift_build_support .tar .tar (source = prefix .lstrip ('/' ),
1416
1474
destination = args .symbols_package )
1417
1475
0 commit comments