Skip to content

Commit 232c7e2

Browse files
marcpruxjakepetroules
authored andcommitted
Fixes for platforms that do not have RTLD_FIRST (e.g., Android)
1 parent 2c1ddf5 commit 232c7e2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sources/swiftpm-testing-helper/Entrypoint.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,24 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if canImport(Darwin)
1314
import Darwin.C
15+
#elseif canImport(Android)
16+
import Android
17+
#endif
1418

1519
@main
1620
struct Entrypoint {
1721
static func main() throws {
1822
let args = CommandLine.arguments
1923
if args.count >= 3, args[1] == "--test-bundle-path" {
2024
let bundlePath = args[2]
21-
guard let image = dlopen(bundlePath, RTLD_LAZY | RTLD_FIRST) else {
25+
#if canImport(Darwin)
26+
let flags = RTLD_LAZY | RTLD_FIRST
27+
#else
28+
let flags = RTLD_LAZY
29+
#endif
30+
guard let image = dlopen(bundlePath, flags) else {
2231
let errorMessage: String = dlerror().flatMap {
2332
String(validatingCString: $0)
2433
} ?? "An unknown error occurred."

0 commit comments

Comments
 (0)