diff --git a/benchmark/scripts/build_script_helper.py b/benchmark/scripts/build_script_helper.py index 53bf7b19f6862..2d234b60bb291 100755 --- a/benchmark/scripts/build_script_helper.py +++ b/benchmark/scripts/build_script_helper.py @@ -53,7 +53,7 @@ def main(): if not os.path.isdir(bin_dir): os.makedirs(bin_dir) - swiftbuild_path = os.path.join(args.toolchain, "usr", "bin", "swift-build") + swiftbuild_path = os.path.join(args.toolchain, "bin", "swift-build") perform_build(args, swiftbuild_path, "debug", "Benchmark_Onone", "-Onone") perform_build(args, swiftbuild_path, "release", "Benchmark_Osize", "-Osize") perform_build(args, swiftbuild_path, "release", "Benchmark_O", "-O") diff --git a/tools/swift-inspect/build_script_helper.py b/tools/swift-inspect/build_script_helper.py index ae9b9c9747f2c..20f37227c6b91 100755 --- a/tools/swift-inspect/build_script_helper.py +++ b/tools/swift-inspect/build_script_helper.py @@ -19,11 +19,11 @@ def perform_build(args, swiftbuild_path): "-Xswiftc", "-I", "-Xswiftc", - os.path.join(args.toolchain, 'usr', 'include', 'swift'), + os.path.join(args.toolchain, 'include', 'swift'), "-Xswiftc", "-L", "-Xswiftc", - os.path.join(args.toolchain, 'usr', 'lib', 'swift', 'macosx'), + os.path.join(args.toolchain, 'lib', 'swift', 'macosx'), "-Xswiftc", "-lswiftRemoteMirror" ] @@ -49,7 +49,7 @@ def main(): if not os.path.isdir(bin_dir): os.makedirs(bin_dir) - swiftbuild_path = os.path.join(args.toolchain, "usr", "bin", "swift-build") + swiftbuild_path = os.path.join(args.toolchain, "bin", "swift-build") perform_build(args, swiftbuild_path) diff --git a/utils/swift_build_support/swift_build_support/products/benchmarks.py b/utils/swift_build_support/swift_build_support/products/benchmarks.py index 0ec3f4c897e28..ff8548bd58e80 100644 --- a/utils/swift_build_support/swift_build_support/products/benchmarks.py +++ b/utils/swift_build_support/swift_build_support/products/benchmarks.py @@ -100,11 +100,17 @@ def get_dependencies(cls): def _get_toolchain_path(host_target, product, args): - # TODO check if we should prefer using product.install_toolchain_path # this logic initially was inside run_build_script_helper # and was factored out so it can be used in testing as well - toolchain_path = product.host_install_destdir(host_target) + install_destdir = args.install_destdir + if swiftpm.SwiftPM.has_cross_compile_hosts(args): + install_destdir = swiftpm.SwiftPM.get_install_destdir(args, + host_target, + product.build_dir) + toolchain_path = targets.toolchain_path(install_destdir, + args.install_prefix) + if platform.system() == 'Darwin': # The prefix is an absolute path, so concatenate without os.path. toolchain_path += \ diff --git a/utils/swift_build_support/swift_build_support/products/swiftinspect.py b/utils/swift_build_support/swift_build_support/products/swiftinspect.py index be00b0e4cc2c0..2b0a24e5ece64 100644 --- a/utils/swift_build_support/swift_build_support/products/swiftinspect.py +++ b/utils/swift_build_support/swift_build_support/products/swiftinspect.py @@ -77,13 +77,29 @@ def get_dependencies(cls): swiftpm.SwiftPM] -def run_build_script_helper(host_target, product, args): - toolchain_path = args.install_destdir +def _get_toolchain_path(host_target, product, args): + # this logic initially was inside run_build_script_helper + # and was factored out so it can be used in testing as well + + install_destdir = args.install_destdir + if swiftpm.SwiftPM.has_cross_compile_hosts(args): + install_destdir = swiftpm.SwiftPM.get_install_destdir(args, + host_target, + product.build_dir) + toolchain_path = targets.toolchain_path(install_destdir, + args.install_prefix) + if platform.system() == 'Darwin': # The prefix is an absolute path, so concatenate without os.path. toolchain_path += \ targets.darwin_toolchain_prefix(args.install_prefix) + return toolchain_path + + +def run_build_script_helper(host_target, product, args): + toolchain_path = _get_toolchain_path(host_target, product, args) + # Our source_dir is expected to be './$SOURCE_ROOT/benchmarks'. That is due # the assumption that each product is in its own build directory. This # product is not like that and has its package/tools instead in