@@ -119,6 +119,10 @@ def add_build_args(parser):
119
119
"--release" ,
120
120
action = "store_true" ,
121
121
help = "enables building SwiftPM in release mode" )
122
+ parser .add_argument (
123
+ "--skip-cmake-bootstrap" ,
124
+ action = "store_true" ,
125
+ help = "build with existing package manager in toolchain if it exists" )
122
126
parser .add_argument (
123
127
"--libswiftpm-install-dir" ,
124
128
metavar = 'PATH' ,
@@ -198,6 +202,8 @@ def parse_build_args(args):
198
202
args .bootstrap_dir = os .path .join (args .target_dir , "bootstrap" )
199
203
args .conf = 'release' if args .release else 'debug'
200
204
args .bin_dir = os .path .join (args .target_dir , args .conf )
205
+ args .bootstrap = not args .skip_cmake_bootstrap or \
206
+ not os .path .exists (os .path .join (os .path .split (args .swiftc_path )[0 ], "swift-build" ))
201
207
202
208
def parse_test_args (args ):
203
209
"""Parses and cleans arguments necessary for the test action."""
@@ -296,10 +302,12 @@ def build(args):
296
302
if not args .llbuild_build_dir :
297
303
build_llbuild (args )
298
304
299
- build_tsc (args )
300
- build_yams (args )
301
- build_swift_argument_parser (args )
302
- build_swift_driver (args )
305
+ if args .bootstrap :
306
+ build_tsc (args )
307
+ build_yams (args )
308
+ build_swift_argument_parser (args )
309
+ build_swift_driver (args )
310
+
303
311
build_swiftpm_with_cmake (args )
304
312
build_swiftpm_with_swiftpm (args ,integrated_swift_driver = False )
305
313
@@ -433,7 +441,7 @@ def install_binary(args, binary, dest_dir):
433
441
# Build functions
434
442
# -----------------------------------------------------------
435
443
436
- def build_with_cmake (args , cmake_args , source_path , build_dir ):
444
+ def build_with_cmake (args , cmake_args , source_path , build_dir , targets = [] ):
437
445
"""Runs CMake if needed, then builds with Ninja."""
438
446
cache_path = os .path .join (build_dir , "CMakeCache.txt" )
439
447
if args .reconfigure or not os .path .isfile (cache_path ) or not args .swiftc_path in open (cache_path ).read ():
@@ -461,6 +469,8 @@ def build_with_cmake(args, cmake_args, source_path, build_dir):
461
469
if args .verbose :
462
470
ninja_cmd .append ("-v" )
463
471
472
+ ninja_cmd += targets
473
+
464
474
call (ninja_cmd , cwd = build_dir , verbose = args .verbose )
465
475
466
476
def build_llbuild (args ):
@@ -558,19 +568,25 @@ def build_swiftpm_with_cmake(args):
558
568
"""Builds SwiftPM using CMake."""
559
569
note ("Building SwiftPM (with CMake)" )
560
570
561
- cmake_flags = [
562
- get_llbuild_cmake_arg (args ),
563
- "-DTSC_DIR=" + os .path .join (args .tsc_build_dir , "cmake/modules" ),
564
- "-DYams_DIR=" + os .path .join (args .yams_build_dir , "cmake/modules" ),
565
- "-DArgumentParser_DIR=" + os .path .join (args .swift_argument_parser_build_dir , "cmake/modules" ),
566
- "-DSwiftDriver_DIR=" + os .path .join (args .swift_driver_build_dir , "cmake/modules" ),
567
- ]
571
+ if args .bootstrap :
572
+ cmake_flags = [
573
+ get_llbuild_cmake_arg (args ),
574
+ "-DTSC_DIR=" + os .path .join (args .tsc_build_dir , "cmake/modules" ),
575
+ "-DYams_DIR=" + os .path .join (args .yams_build_dir , "cmake/modules" ),
576
+ "-DArgumentParser_DIR=" + os .path .join (args .swift_argument_parser_build_dir , "cmake/modules" ),
577
+ "-DSwiftDriver_DIR=" + os .path .join (args .swift_driver_build_dir , "cmake/modules" ),
578
+ "-DFIND_PM_DEPS:BOOL=YES" ,
579
+ ]
580
+ else :
581
+ cmake_flags = [ "-DFIND_PM_DEPS:BOOL=NO" ]
568
582
569
583
if platform .system () == 'Darwin' :
570
584
cmake_flags .append ("-DCMAKE_C_FLAGS=-target %s%s" % (get_build_target (args ), g_macos_deployment_target ))
571
585
cmake_flags .append ("-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target )
572
586
573
- build_with_cmake (args , cmake_flags , args .project_root , args .bootstrap_dir )
587
+ targets = [] if args .bootstrap else ["PD4" , "PD4_2" ]
588
+
589
+ build_with_cmake (args , cmake_flags , args .project_root , args .bootstrap_dir , targets )
574
590
575
591
if args .llbuild_link_framework :
576
592
add_rpath_for_cmake_build (args , args .llbuild_build_dir )
@@ -582,15 +598,22 @@ def build_swiftpm_with_cmake(args):
582
598
583
599
def build_swiftpm_with_swiftpm (args , integrated_swift_driver ):
584
600
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
585
- note ("Building SwiftPM (with swift-build)" )
586
601
587
602
swiftpm_args = [
588
603
"SWIFT_EXEC=" + args .swiftc_path ,
589
604
"SWIFT_DRIVER_SWIFT_EXEC=" + args .swiftc_path ,
590
- "SWIFTPM_PD_LIBS=" + os .path .join (args .bootstrap_dir , "pm" ),
591
- os .path .join (args .bootstrap_dir , "bin/swift-build" ),
592
- "--disable-sandbox" ,
593
605
]
606
+
607
+ if args .bootstrap :
608
+ note ("Building SwiftPM (with a freshly built swift-build)" )
609
+ swiftpm_args .append ("SWIFTPM_PD_LIBS=" + os .path .join (args .bootstrap_dir , "pm" ))
610
+ swiftpm_args .append (os .path .join (args .bootstrap_dir , "bin/swift-build" ))
611
+ else :
612
+ note ("Building SwiftPM (with a prebuilt swift-build)" )
613
+ swiftpm_args .append (os .path .join (os .path .split (args .swiftc_path )[0 ], "swift-build" ))
614
+
615
+ swiftpm_args .append ("--disable-sandbox" )
616
+
594
617
if integrated_swift_driver :
595
618
swiftpm_args .append ("--use-integrated-swift-driver" )
596
619
@@ -660,19 +683,20 @@ def get_swiftpm_env_cmd(args):
660
683
env_cmd .append ("SWIFTCI_USE_LOCAL_DEPS=1" )
661
684
env_cmd .append ("SWIFTPM_MACOS_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target )
662
685
663
- libs_joined = ":" .join ([
664
- os .path .join (args .bootstrap_dir , "lib" ),
665
- os .path .join (args .tsc_build_dir , "lib" ),
666
- os .path .join (args .llbuild_build_dir , "lib" ),
667
- os .path .join (args .yams_build_dir , "lib" ),
668
- os .path .join (args .swift_argument_parser_build_dir , "lib" ),
669
- os .path .join (args .swift_driver_build_dir , "lib" ),
670
- ] + args .target_info ["paths" ]["runtimeLibraryPaths" ])
686
+ if args .bootstrap :
687
+ libs_joined = ":" .join ([
688
+ os .path .join (args .bootstrap_dir , "lib" ),
689
+ os .path .join (args .tsc_build_dir , "lib" ),
690
+ os .path .join (args .llbuild_build_dir , "lib" ),
691
+ os .path .join (args .yams_build_dir , "lib" ),
692
+ os .path .join (args .swift_argument_parser_build_dir , "lib" ),
693
+ os .path .join (args .swift_driver_build_dir , "lib" ),
694
+ ] + args .target_info ["paths" ]["runtimeLibraryPaths" ])
671
695
672
- if platform .system () == 'Darwin' :
673
- env_cmd .append ("DYLD_LIBRARY_PATH=%s" % libs_joined )
674
- else :
675
- env_cmd .append ("LD_LIBRARY_PATH=%s" % libs_joined )
696
+ if platform .system () == 'Darwin' :
697
+ env_cmd .append ("DYLD_LIBRARY_PATH=%s" % libs_joined )
698
+ else :
699
+ env_cmd .append ("LD_LIBRARY_PATH=%s" % libs_joined )
676
700
677
701
return env_cmd
678
702
0 commit comments