Skip to content

Commit

Permalink
Merge pull request #211 from lanza/skinnypaths.xctest
Browse files Browse the repository at this point in the history
add a linker search path to account for changes in library paths on platforms without fat binaries
  • Loading branch information
compnerd authored Feb 28, 2018
2 parents 8d87be4 + 27304cd commit 01e6126
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def build(args):
build_dir = os.path.abspath(args.build_dir)
static_lib_build_dir = GenericUnixStrategy.static_lib_build_dir(build_dir)
foundation_build_dir = os.path.abspath(args.foundation_build_dir)
swift_build_dir = os.path.abspath(args.swift_build_dir)
arch = platform.machine()
core_foundation_build_dir = GenericUnixStrategy.core_foundation_build_dir(
foundation_build_dir, args.foundation_install_prefix)
if args.libdispatch_build_dir:
Expand Down Expand Up @@ -200,15 +202,17 @@ def build(args):
libdispatch_args=libdispatch_args,
source_paths=" ".join(sourcePaths)))
run("{swiftc} -emit-library {build_dir}/XCTest.o "
"-L {dispatch_build_dir} -L {foundation_build_dir} -lswiftGlibc -lswiftCore -lFoundation -lm "
"-L {dispatch_build_dir} -L {foundation_build_dir} -L {swift_build_dir} "
"-lswiftGlibc -lswiftCore -lFoundation -lm "
# We embed an rpath of `$ORIGIN` to ensure other referenced
# libraries (like `Foundation`) can be found solely via XCTest.
"-Xlinker -rpath=\\$ORIGIN "
"-o {build_dir}/libXCTest.so".format(
swiftc=swiftc,
build_dir=build_dir,
dispatch_build_dir=os.path.join(args.libdispatch_build_dir, 'src', '.libs'),
foundation_build_dir=foundation_build_dir))
foundation_build_dir=foundation_build_dir,
swift_build_dir=os.path.join(args.swift_build_dir, 'lib', 'swift', 'linux', arch)))

# Build the static library.
run("mkdir -p {static_lib_build_dir}".format(static_lib_build_dir=static_lib_build_dir))
Expand Down Expand Up @@ -431,6 +435,10 @@ def main(args=sys.argv[1:]):
"dependencies are expected to be found under "
"FOUNDATION_BUILD_DIR/FOUNDATION_INSTALL_PREFIX.",
default="/usr")
build_parser.add_argument(
"--swift-build-dir",
help="Path to swift build products, which the built XCTest.so "
"will be linked against.")
build_parser.add_argument(
"--libdispatch-build-dir",
help="Path to swift-corelibs-libdispatch build products, which "
Expand Down

0 comments on commit 01e6126

Please sign in to comment.