Skip to content

Commit f1ae5ed

Browse files
committed
[new-bootstrap] Misc fixes
1 parent 5f0d6b6 commit f1ae5ed

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

Utilities/new-bootstrap

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def add_build_args(parser):
9999
"--llbuild-build-dir",
100100
help="path to llbuild build directory")
101101
parser.add_argument(
102-
"--llbuild_link_framework",
102+
"--llbuild-link-framework",
103103
action="store_true",
104104
help="whether to link to the llbuild framework")
105105
parser.add_argument(
@@ -396,27 +396,36 @@ def build_swiftpm_with_swiftpm(args):
396396
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
397397
note("Building SwiftPM (with swift-build)")
398398

399-
args.swiftc_path
400399
call_swiftpm(args, [
400+
"SWIFT_EXEC=" + args.swiftc_path,
401+
"SWIFTPM_PD_LIBS=" + os.path.join(args.bootstrap_dir, "pm"),
402+
401403
os.path.join(args.bootstrap_dir, "bin/swift-build"),
402404
# Always build tests in stage2.
403405
"--build-tests",
404406
"--disable-sandbox",
405407
])
406408

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+
407416
def call_swiftpm(args, cmd):
408417
"""Calls a SwiftPM binary with the necessary environment variables and flags."""
409418
full_cmd = get_swiftpm_env_cmd(args) + cmd + get_swiftpm_flags(args)
410419
call(full_cmd, cwd=args.project_root, verbose=True)
411420

412421
# -----------------------------------------------------------
413-
# Build-related helper functionss
422+
# Build-related helper functions
414423
# -----------------------------------------------------------
415424

416425
def get_llbuild_cmake_arg(args):
417426
"""Returns the CMake argument to the LLBuild framework/binary to use for bulding SwiftPM."""
418427
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
420429
else:
421430
llbuild_dir = os.path.join(args.llbuild_build_dir, "cmake/modules")
422431
return "-DLLBuild_DIR=" + llbuild_dir
@@ -431,12 +440,7 @@ def get_llbuild_source_path(args):
431440

432441
def get_swiftpm_env_cmd(args):
433442
"""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"]
440444

441445
if args.sysroot:
442446
env_cmd.append("SDKROOT=%s" % args.sysroot)
@@ -465,6 +469,7 @@ def get_swiftpm_flags(args):
465469
build_flags = [
466470
# No need for indexing while building.
467471
"--disable-index-store",
472+
"--build-path", args.build_dir
468473
]
469474

470475
if args.release:
@@ -476,6 +481,12 @@ def get_swiftpm_flags(args):
476481
if args.verbose:
477482
build_flags.append("--verbose")
478483

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+
479490
return build_flags
480491

481492
# -----------------------------------------------------------

0 commit comments

Comments
 (0)