Skip to content

Commit 01e6126

Browse files
authored
Merge pull request #211 from lanza/skinnypaths.xctest
add a linker search path to account for changes in library paths on platforms without fat binaries
2 parents 8d87be4 + 27304cd commit 01e6126

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

build_script.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def build(args):
156156
build_dir = os.path.abspath(args.build_dir)
157157
static_lib_build_dir = GenericUnixStrategy.static_lib_build_dir(build_dir)
158158
foundation_build_dir = os.path.abspath(args.foundation_build_dir)
159+
swift_build_dir = os.path.abspath(args.swift_build_dir)
160+
arch = platform.machine()
159161
core_foundation_build_dir = GenericUnixStrategy.core_foundation_build_dir(
160162
foundation_build_dir, args.foundation_install_prefix)
161163
if args.libdispatch_build_dir:
@@ -200,15 +202,17 @@ def build(args):
200202
libdispatch_args=libdispatch_args,
201203
source_paths=" ".join(sourcePaths)))
202204
run("{swiftc} -emit-library {build_dir}/XCTest.o "
203-
"-L {dispatch_build_dir} -L {foundation_build_dir} -lswiftGlibc -lswiftCore -lFoundation -lm "
205+
"-L {dispatch_build_dir} -L {foundation_build_dir} -L {swift_build_dir} "
206+
"-lswiftGlibc -lswiftCore -lFoundation -lm "
204207
# We embed an rpath of `$ORIGIN` to ensure other referenced
205208
# libraries (like `Foundation`) can be found solely via XCTest.
206209
"-Xlinker -rpath=\\$ORIGIN "
207210
"-o {build_dir}/libXCTest.so".format(
208211
swiftc=swiftc,
209212
build_dir=build_dir,
210213
dispatch_build_dir=os.path.join(args.libdispatch_build_dir, 'src', '.libs'),
211-
foundation_build_dir=foundation_build_dir))
214+
foundation_build_dir=foundation_build_dir,
215+
swift_build_dir=os.path.join(args.swift_build_dir, 'lib', 'swift', 'linux', arch)))
212216

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

0 commit comments

Comments
 (0)