@@ -99,7 +99,7 @@ def add_build_args(parser):
99
99
"--llbuild-build-dir" ,
100
100
help = "path to llbuild build directory" )
101
101
parser .add_argument (
102
- "--llbuild_link_framework " ,
102
+ "--llbuild-link-framework " ,
103
103
action = "store_true" ,
104
104
help = "whether to link to the llbuild framework" )
105
105
parser .add_argument (
@@ -396,27 +396,36 @@ def build_swiftpm_with_swiftpm(args):
396
396
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
397
397
note ("Building SwiftPM (with swift-build)" )
398
398
399
- args .swiftc_path
400
399
call_swiftpm (args , [
400
+ "SWIFT_EXEC=" + args .swiftc_path ,
401
+ "SWIFTPM_PD_LIBS=" + os .path .join (args .bootstrap_dir , "pm" ),
402
+
401
403
os .path .join (args .bootstrap_dir , "bin/swift-build" ),
402
404
# Always build tests in stage2.
403
405
"--build-tests" ,
404
406
"--disable-sandbox" ,
405
407
])
406
408
409
+ # Setup symlinks that'll allow using swiftpm from the build directory.
410
+ symlink_force (args .swiftc_path , os .path .join (args .target_dir , args .conf , "swiftc" ))
411
+
412
+ lib_dir = os .path .join (args .target_dir , "lib" , "swift" )
413
+ mkdir_p (lib_dir )
414
+ symlink_force (os .path .join (args .bootstrap_dir , "pm" ), os .path .join (lib_dir , "pm" ))
415
+
407
416
def call_swiftpm (args , cmd ):
408
417
"""Calls a SwiftPM binary with the necessary environment variables and flags."""
409
418
full_cmd = get_swiftpm_env_cmd (args ) + cmd + get_swiftpm_flags (args )
410
419
call (full_cmd , cwd = args .project_root , verbose = True )
411
420
412
421
# -----------------------------------------------------------
413
- # Build-related helper functionss
422
+ # Build-related helper functions
414
423
# -----------------------------------------------------------
415
424
416
425
def get_llbuild_cmake_arg (args ):
417
426
"""Returns the CMake argument to the LLBuild framework/binary to use for bulding SwiftPM."""
418
427
if args .llbuild_link_framework :
419
- return "-DLLBuild_LIBRARY =%s" % os . path . join ( args .llbuild_build_dir )
428
+ return "-DCMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS =%s" % args .llbuild_build_dir
420
429
else :
421
430
llbuild_dir = os .path .join (args .llbuild_build_dir , "cmake/modules" )
422
431
return "-DLLBuild_DIR=" + llbuild_dir
@@ -431,12 +440,7 @@ def get_llbuild_source_path(args):
431
440
432
441
def get_swiftpm_env_cmd (args ):
433
442
"""Returns the environment variable command to run SwiftPM binaries."""
434
- env_cmd = [
435
- "env" ,
436
- "SWIFT_EXEC=" + args .swiftc_path ,
437
- "SWIFTPM_BUILD_DIR=" + args .build_dir ,
438
- "SWIFTPM_PD_LIBS=" + os .path .join (args .bootstrap_dir , "pm" ),
439
- ]
443
+ env_cmd = ["env" ]
440
444
441
445
if args .sysroot :
442
446
env_cmd .append ("SDKROOT=%s" % args .sysroot )
@@ -465,6 +469,7 @@ def get_swiftpm_flags(args):
465
469
build_flags = [
466
470
# No need for indexing while building.
467
471
"--disable-index-store" ,
472
+ "--build-path" , args .build_dir
468
473
]
469
474
470
475
if args .release :
@@ -476,6 +481,12 @@ def get_swiftpm_flags(args):
476
481
if args .verbose :
477
482
build_flags .append ("--verbose" )
478
483
484
+ if args .llbuild_link_framework :
485
+ build_flags .extend ([
486
+ "-Xswiftc" , "-F" + args .llbuild_build_dir ,
487
+ "-Xlinker" , "-F" + args .llbuild_build_dir ,
488
+ ])
489
+
479
490
return build_flags
480
491
481
492
# -----------------------------------------------------------
0 commit comments