Skip to content

Commit

Permalink
For testing on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
johnno1962 committed Sep 14, 2017
1 parent 2e96829 commit 6e0af61
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
22 changes: 21 additions & 1 deletion Package.swift
@@ -1,3 +1,23 @@
// swift-tools-version:4.0
//
// To build with auto-linking of the .swiftmodule use:
// $ swift build -Xswiftc -module-link-name -Xswiftc XCTest
//

import PackageDescription

let package = Package(name: "XCTest")
let package = Package(
name: "XCTest",
products: [
.library(
name: "XCTest",
type: .dynamic,
targets: ["XCTest"]
)
],
dependencies: [
],
targets: [
.target(name: "XCTest", dependencies: [], path: "Sources"),
]
)
2 changes: 2 additions & 0 deletions Sources/XCTest/Private/PrintObserver.swift
Expand Up @@ -59,7 +59,9 @@ internal class PrintObserver: XCTestObservation {

fileprivate func printAndFlush(_ message: String) {
print(message)
#if !os(Android)
fflush(stdout)
#endif
}

private func formatTimeInterval(_ timeInterval: TimeInterval) -> String {
Expand Down
3 changes: 2 additions & 1 deletion build_script.py
Expand Up @@ -200,13 +200,14 @@ def build(args):
libdispatch_args=libdispatch_args,
source_paths=" ".join(sourcePaths)))
run("{swiftc} -emit-library {build_dir}/XCTest.o "
"-L {foundation_build_dir} -lswiftGlibc -lswiftCore -lFoundation -lm "
"-L {dispatch_build_dir} -L {foundation_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))

# Build the static library.
Expand Down

0 comments on commit 6e0af61

Please sign in to comment.