Skip to content

Commit be55379

Browse files
authored
Merge pull request #5551 from adamdecaf/fix-go1.24-wasm_exec-path
commands/package-web: check go1.24 ./lib/wasm/ for wasm_exec.js
2 parents 0574526 + 93ea670 commit be55379

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

cmd/fyne/internal/commands/package-web.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ func (w webData) packageWebInternal(appDir string, exeWasmSrc string, exeJSSrc s
7171
return err
7272
}
7373

74-
wasmExecSrc := filepath.Join(runtime.GOROOT(), "misc", "wasm", "wasm_exec.js")
74+
goroot := runtime.GOROOT()
75+
wasmExecSrc := filepath.Join(goroot, "lib", "wasm", "wasm_exec.js")
76+
if !util.Exists(wasmExecSrc) { // Fallback for Go < 1.24:
77+
wasmExecSrc = filepath.Join(goroot, "misc", "wasm", "wasm_exec.js")
78+
}
7579
wasmExecDst := filepath.Join(appDir, "wasm_exec.js")
7680
err = util.CopyFile(wasmExecSrc, wasmExecDst)
7781
if err != nil {

cmd/fyne/internal/commands/package_test.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,27 @@ func Test_PackageWasm(t *testing.T) {
238238
return expectedEnsureSubDirRuns.verifyExpectation(t, parent, name)
239239
}
240240

241+
// Handle lookup for wasm_exec.js from lib folder in Go 1.24 and newer:
242+
goroot := runtime.GOROOT()
243+
wasmExecJSPath := filepath.Join(goroot, "lib", "wasm", "wasm_exec.js")
244+
_, err := os.Stat(wasmExecJSPath)
245+
execJSLibExists := err == nil || !os.IsNotExist(err)
246+
241247
expectedExistRuns := mockExistRuns{
242248
expected: []mockExist{
243249
{"myTest.wasm", false},
244250
{"myTest.wasm", true},
251+
{wasmExecJSPath, execJSLibExists},
245252
},
246253
}
247254
utilExistsMock = func(path string) bool {
248255
return expectedExistRuns.verifyExpectation(t, path)
249256
}
250257

258+
if !execJSLibExists { // Expect location from Go < 1.24 to have been copied:
259+
wasmExecJSPath = filepath.Join(goroot, "misc", "wasm", "wasm_exec.js")
260+
}
261+
251262
expectedWriteFileRuns := mockWriteFileRuns{
252263
expected: []mockWriteFile{
253264
{filepath.Join("myTestTarget", "wasm", "index.html"), nil},
@@ -265,15 +276,15 @@ func Test_PackageWasm(t *testing.T) {
265276
expectedCopyFileRuns := mockCopyFileRuns{
266277
expected: []mockCopyFile{
267278
{source: "myTest.png", target: filepath.Join("myTestTarget", "wasm", "icon.png")},
268-
{source: filepath.Join(runtime.GOROOT(), "misc", "wasm", "wasm_exec.js"), target: filepath.Join("myTestTarget", "wasm", "wasm_exec.js")},
279+
{source: wasmExecJSPath, target: filepath.Join("myTestTarget", "wasm", "wasm_exec.js")},
269280
{source: "myTest.wasm", target: filepath.Join("myTestTarget", "wasm", "myTest.wasm")},
270281
},
271282
}
272283
utilCopyFileMock = func(source, target string) error {
273284
return expectedCopyFileRuns.verifyExpectation(t, false, source, target)
274285
}
275286

276-
err := p.doPackage(wasmBuildTest)
287+
err = p.doPackage(wasmBuildTest)
277288
assert.Nil(t, err)
278289
wasmBuildTest.verifyExpectation()
279290
expectedTotalCount(t, len(expectedEnsureSubDirRuns.expected), expectedEnsureSubDirRuns.current)

0 commit comments

Comments
 (0)