Skip to content

Commit

Permalink
build for embedded without external flags
Browse files Browse the repository at this point in the history
  • Loading branch information
sliemeobn committed Oct 30, 2024
1 parent 6d2d244 commit 78f142e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/ci-embedded.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,5 @@ jobs:

- name: Build
run: |
swift build -c release \
--triple wasm32-unknown-none-wasm \
-Xswiftc -enable-experimental-feature -Xswiftc Embedded \
-Xswiftc -enable-experimental-feature -Xswiftc Extern \
-Xswiftc -wmo -Xswiftc -disable-cmo \
-Xswiftc -cxx-interoperability-mode=default \
-Xcc -fdeclspec
JAVASCRIPTKIT_EXPERIMENTAL_EMBEDDED_WASM=true \
swift build --triple wasm32-unknown-none-wasm
12 changes: 7 additions & 5 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// swift-tools-version: 6.0
import Foundation
import PackageDescription

let shouldBuildForEmbedded = ProcessInfo.processInfo.environment["JAVASCRIPTKIT_EXPERIMENTAL_EMBEDDED_WASM"].flatMap(Bool.init) ?? false
let shouldBuildForEmbedded = Context.environment["JAVASCRIPTKIT_EXPERIMENTAL_EMBEDDED_WASM"].flatMap(Bool.init) ?? false

var featureFlags: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
Expand All @@ -11,11 +10,13 @@ var featureFlags: [SwiftSetting] = [
if shouldBuildForEmbedded {
// currently this work-around only works for SwiftPM package dependencies on branches, not version tags
// see https://github.com/swiftlang/swift-package-manager/issues/7612
featureFlags.append(
featureFlags.append(contentsOf: [
.enableExperimentalFeature("Embedded"),
.enableExperimentalFeature("Extern"),
.unsafeFlags([
"-Xfrontend", "-emit-empty-object-file",
])
)
]),
])
}

let package = Package(
Expand All @@ -35,6 +36,7 @@ let package = Package(
targets: [
.target(
name: "Elementary",
cSettings: shouldBuildForEmbedded ? [.unsafeFlags(["-fdeclspec"])] : nil,
swiftSettings: featureFlags
),
.testTarget(
Expand Down

0 comments on commit 78f142e

Please sign in to comment.