Skip to content

Commit

Permalink
Fix build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Mar 16, 2024
1 parent 263a51b commit 845d191
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ let openSwiftUICompatibilityTestTarget = Target.testTarget(
swiftSettings: sharedSwiftSettings
)

let swiftBinPath = Context.environment["_"] ?? ""
let swiftBinURL = URL(fileURLWithPath: swiftBinPath)
let SDKPath = swiftBinURL.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().path
let includePath = SDKPath.appending("/usr/lib/swift_static")

let package = Package(
name: "OpenSwiftUI",
platforms: [
Expand All @@ -87,7 +92,11 @@ let package = Package(
]
),
.target(
name: "COpenSwiftUI"
name: "COpenSwiftUI",
cSettings: [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
]
),
.binaryTarget(name: "CoreServices", path: "PrivateFrameworks/CoreServices.xcframework"),
openSwiftUITarget,
Expand Down Expand Up @@ -196,3 +205,9 @@ if useLocalDeps {
.package(url: "https://github.com/OpenSwiftUIProject/OpenGraph", branch: "main"),
]
}

extension [Platform] {
static var nonDarwinPlatforms: [Platform] {
[.linux, .android, .wasi, .openbsd, .windows]
}
}
2 changes: 2 additions & 0 deletions Sources/COpenSwiftUI/MovableLock.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ void wait_for_lock(MovableLock lock, pthread_t thread);
void sync_main_callback();

MovableLock _MovableLockCreate() {
#if !OPENSWIFTUI_TARGET_CPU_WASM32
static_assert(sizeof(MovableLock_t) == 0x100, "MovebleLock size is not 0x100 bytes.");
#endif
MovableLock lock = calloc(1, sizeof(MovableLock_t));
if (!lock) {
abort();
Expand Down

0 comments on commit 845d191

Please sign in to comment.