Skip to content

Commit 6e0af61

Browse files
committed
For testing on Android
1 parent 2e96829 commit 6e0af61

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Package.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
// swift-tools-version:4.0
2+
//
3+
// To build with auto-linking of the .swiftmodule use:
4+
// $ swift build -Xswiftc -module-link-name -Xswiftc XCTest
5+
//
6+
17
import PackageDescription
28

3-
let package = Package(name: "XCTest")
9+
let package = Package(
10+
name: "XCTest",
11+
products: [
12+
.library(
13+
name: "XCTest",
14+
type: .dynamic,
15+
targets: ["XCTest"]
16+
)
17+
],
18+
dependencies: [
19+
],
20+
targets: [
21+
.target(name: "XCTest", dependencies: [], path: "Sources"),
22+
]
23+
)

Sources/XCTest/Private/PrintObserver.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ internal class PrintObserver: XCTestObservation {
5959

6060
fileprivate func printAndFlush(_ message: String) {
6161
print(message)
62+
#if !os(Android)
6263
fflush(stdout)
64+
#endif
6365
}
6466

6567
private func formatTimeInterval(_ timeInterval: TimeInterval) -> String {

build_script.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,14 @@ def build(args):
200200
libdispatch_args=libdispatch_args,
201201
source_paths=" ".join(sourcePaths)))
202202
run("{swiftc} -emit-library {build_dir}/XCTest.o "
203-
"-L {foundation_build_dir} -lswiftGlibc -lswiftCore -lFoundation -lm "
203+
"-L {dispatch_build_dir} -L {foundation_build_dir} -lswiftGlibc -lswiftCore -lFoundation -lm "
204204
# We embed an rpath of `$ORIGIN` to ensure other referenced
205205
# libraries (like `Foundation`) can be found solely via XCTest.
206206
"-Xlinker -rpath=\\$ORIGIN "
207207
"-o {build_dir}/libXCTest.so".format(
208208
swiftc=swiftc,
209209
build_dir=build_dir,
210+
dispatch_build_dir=os.path.join(args.libdispatch_build_dir, 'src', '.libs'),
210211
foundation_build_dir=foundation_build_dir))
211212

212213
# Build the static library.

0 commit comments

Comments
 (0)