Skip to content

Commit a1aa3db

Browse files
WebAssemblyRecipe:: Enable embedded target for wasip1-threads as well (#244)
There is no reason to limit Embedded Swift to only the non-threads variant. The limitation made some tests in JavaScriptKit a bit more complicated, see e.g. https://github.com/swiftwasm/JavaScriptKit/pull/443/files#diff-2c1174f0c456f8536c09dce2f943c43287a6a207ef08054d6aeddf5f00efa040R86 Co-authored-by: Max Desiatov <m_desiatov@apple.com>
1 parent b83c8ef commit a1aa3db

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ package struct WebAssemblyRecipe: SwiftSDKRecipe {
125125
? relativeToolchainDir.appending("usr/lib/swift").string
126126
: tripleProperties.swiftStaticResourcesPath
127127

128-
var finalTriple = targetTriple
129-
if isForEmbeddedSwift {
130-
metadata.targetTriples.removeValue(forKey: targetTriple.triple)
131-
finalTriple = Triple("wasm32-unknown-wasip1")
132-
}
133-
134-
metadata.targetTriples[finalTriple.triple] = tripleProperties
128+
metadata.targetTriples[targetTriple.triple] = tripleProperties
135129
}
136130

137131
package func makeSwiftSDK(

Tests/SwiftSDKGeneratorTests/SwiftSDKRecipes/WebAssemblyRecipe.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,31 @@ final class WebAssemblyRecipeTests: XCTestCase {
9999
]
100100
)
101101
}
102+
103+
func testMetadataWithEmbedded() {
104+
testMetadataWithEmbedded(targetTriple: Triple("wasm32-unknown-wasip1"))
105+
testMetadataWithEmbedded(targetTriple: Triple("wasm32-unknown-wasip1-threads"))
106+
}
107+
108+
func testMetadataWithEmbedded(targetTriple: Triple) {
109+
let recipe = self.createRecipe()
110+
var metadata = SwiftSDKMetadataV4(
111+
targetTriples: [
112+
targetTriple.triple: .init(sdkRootPath: "./WASI.sdk")
113+
]
114+
)
115+
let paths = PathsConfiguration(
116+
sourceRoot: "./",
117+
artifactID: "any-sdk-id",
118+
targetTriple: targetTriple
119+
)
120+
recipe.applyPlatformOptions(
121+
metadata: &metadata,
122+
paths: paths,
123+
targetTriple: targetTriple,
124+
isForEmbeddedSwift: true
125+
)
126+
// Should include the target we started with.
127+
XCTAssertNotNil(metadata.targetTriples[targetTriple.triple])
128+
}
102129
}

0 commit comments

Comments
 (0)