Skip to content

Commit 6df18bb

Browse files
Merge pull request #647 from swiftwasm/yt/detect-bjslink-change
PackageToJS: Rebuild bridge-js.js when BridgeJSLink is changed
2 parents 01c8404 + 969e696 commit 6df18bb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Plugins/PackageToJS/Sources/PackageToJS.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ struct PackagingPlanner {
422422
wasmFilename: String,
423423
configuration: String,
424424
triple: String,
425-
selfPath: BuildPath = BuildPath(absolute: #filePath),
425+
// NOTE: We should use `ProcessInfo.processInfo.arguments[0]` instead of `CommandLine.arguments[0]`
426+
// because the latter may not always be the full executable path (e.g. when invoked through PATH lookup).
427+
// https://github.com/swiftlang/swift-foundation/blob/f5143f96d01cdb6d280665de8221b75fc8631d95/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift#L47
428+
selfPath: BuildPath = BuildPath(absolute: ProcessInfo.processInfo.arguments[0]),
426429
system: any PackagingSystem
427430
) {
428431
self.options = options
@@ -592,7 +595,7 @@ struct PackagingPlanner {
592595
let bridgeJs = outputDir.appending(path: "bridge-js.js")
593596
let bridgeDts = outputDir.appending(path: "bridge-js.d.ts")
594597
packageInputs.append(
595-
make.addTask(inputFiles: skeletons, output: bridgeJs) { _, scope in
598+
make.addTask(inputFiles: skeletons + [selfPath], output: bridgeJs) { _, scope in
596599
var link = BridgeJSLink(
597600
sharedMemory: Self.isSharedMemoryEnabled(triple: triple)
598601
)

0 commit comments

Comments
 (0)