Skip to content

Commit d7bf655

Browse files
Include as many target/product as possible
1 parent eb27bde commit d7bf655

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

Package.swift

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ let package = Package(
1515
name: "WasmParser",
1616
targets: ["WasmParser"]
1717
),
18+
.library(
19+
name: "WIT", targets: ["WIT"]
20+
),
1821
.executable(
1922
name: "wasmkit-cli",
2023
targets: ["CLI"]
2124
),
25+
.library(name: "_CabiShims", targets: ["_CabiShims"]),
2226
],
2327
targets: [
2428
.executableTarget(
@@ -59,6 +63,24 @@ let package = Package(
5963
.product(name: "SystemPackage", package: "swift-system"),
6064
]
6165
),
66+
.target(name: "WIT"),
67+
.testTarget(name: "WITTests", dependencies: ["WIT"]),
68+
.target(name: "WITOverlayGenerator", dependencies: ["WIT"]),
69+
.target(name: "_CabiShims"),
70+
.target(name: "WITExtractor"),
71+
.testTarget(
72+
name: "WITExtractorTests",
73+
dependencies: ["WITExtractor", "WIT"]
74+
),
75+
.executableTarget(
76+
name: "WITTool",
77+
dependencies: [
78+
"WIT",
79+
"WITOverlayGenerator",
80+
"WITExtractor",
81+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
82+
]
83+
),
6284
.testTarget(
6385
name: "WasmKitTests",
6486
dependencies: ["WasmKit"]
@@ -119,10 +141,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
119141
name: "WASITests",
120142
dependencies: ["WASI"]
121143
),
122-
.testTarget(
123-
name: "WASITests",
124-
dependencies: ["WASI"]
125-
),
126144
])
127145
let targetDependenciesToAdd = [
128146
"CLI": ["WasmKitWASI"],
@@ -136,19 +154,13 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
136154
}
137155
}
138156

139-
// Add WIT-related products and targets
157+
// Add build tool plugins only for non-Windows platforms
140158
package.products.append(contentsOf: [
141-
.library(name: "WIT", targets: ["WIT"]),
142-
.library(name: "_CabiShims", targets: ["_CabiShims"]),
143159
.plugin(name: "WITOverlayPlugin", targets: ["WITOverlayPlugin"]),
144160
.plugin(name: "WITExtractorPlugin", targets: ["WITExtractorPlugin"]),
145161
])
146162

147163
package.targets.append(contentsOf: [
148-
.target(name: "WIT"),
149-
.testTarget(name: "WITTests", dependencies: ["WIT"]),
150-
.target(name: "WITOverlayGenerator", dependencies: ["WIT"]),
151-
.target(name: "_CabiShims"),
152164
.plugin(name: "WITOverlayPlugin", capability: .buildTool(), dependencies: ["WITTool"]),
153165
.plugin(name: "GenerateOverlayForTesting", capability: .buildTool(), dependencies: ["WITTool"]),
154166
.testTarget(
@@ -157,11 +169,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
157169
exclude: ["Fixtures", "Compiled", "Generated"],
158170
plugins: [.plugin(name: "GenerateOverlayForTesting")]
159171
),
160-
.target(name: "WITExtractor"),
161-
.testTarget(
162-
name: "WITExtractorTests",
163-
dependencies: ["WITExtractor", "WIT"]
164-
),
165172
.plugin(
166173
name: "WITExtractorPlugin",
167174
capability: .command(
@@ -174,14 +181,5 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
174181
name: "WITExtractorPluginTests",
175182
exclude: ["Fixtures"]
176183
),
177-
.executableTarget(
178-
name: "WITTool",
179-
dependencies: [
180-
"WIT",
181-
"WITOverlayGenerator",
182-
"WITExtractor",
183-
.product(name: "ArgumentParser", package: "swift-argument-parser"),
184-
]
185-
),
186184
])
187185
#endif

Sources/CLI/Run/Run.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,14 @@ struct Run: ParsableCommand {
101101
)
102102
}
103103
#else
104+
// GuestTimeProfiler is not available without SystemExtras
104105
func deriveInterceptor() throws -> (interceptor: RuntimeInterceptor, finalize: () -> Void)? {
105106
nil
106107
}
107108
#endif
108109

109110
func instantiateWASI(module: Module, interceptor: RuntimeInterceptor?) throws -> () throws -> Void {
110-
#if os(Windows)
111-
fatalError("WASI is not supported on Windows")
112-
#else
111+
#if canImport(WasmKitWASI)
113112
// Flatten environment variables into a dictionary (Respect the last value if a key is duplicated)
114113
let environment = environment.reduce(into: [String: String]()) {
115114
$0[$1.key] = $1.value
@@ -124,6 +123,8 @@ struct Run: ParsableCommand {
124123
let exitCode = try wasi.start(moduleInstance, runtime: runtime)
125124
throw ExitCode(Int32(exitCode))
126125
}
126+
#else
127+
fatalError("WASI is not supported on this platform")
127128
#endif
128129
}
129130

Sources/WasmKit/ModuleParser.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import SystemPackage
22
import WasmParser
3+
#if os(Windows)
4+
import ucrt
5+
#endif
36

47
/// Parse a given file as a WebAssembly binary format file
58
/// > Note: <https://webassembly.github.io/spec/core/binary/index.html>

0 commit comments

Comments
 (0)