Skip to content

Commit

Permalink
build: help mingw reformat paths for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Feb 13, 2025
1 parent d058853 commit c42d882
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
16 changes: 15 additions & 1 deletion docs/webui/assets/wasm_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if (!globalThis.fs) {
let outputBuf = "";
globalThis.fs = {
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused
writeSync(fd, buf) {
outputBuf += decoder.decode(buf);
const nl = outputBuf.lastIndexOf("\n");
Expand Down Expand Up @@ -73,6 +73,14 @@
}
}

if (!globalThis.path) {
globalThis.path = {
resolve(...pathSegments) {
return pathSegments.join("/");
}
}
}

if (!globalThis.crypto) {
throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");
}
Expand Down Expand Up @@ -208,10 +216,16 @@
return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
}

const testCallExport = (a, b) => {
this._inst.exports.testExport0();
return this._inst.exports.testExport(a, b);
}

const timeOrigin = Date.now() - performance.now();
this.importObject = {
_gotest: {
add: (a, b) => a + b,
callExport: testCallExport,
},
gojs: {
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
Expand Down
Binary file modified docs/webui/assets/wire.wasm
Binary file not shown.
13 changes: 9 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ VERSION := $(shell grep -Eo '(v[0-9]+[\.][0-9]+[\.][0-9]+(-[a-zA-Z0-9]*)?)' vers
build:
CGO_ENABLED=0 go build -o ./bin/server github.com/moov-io/wire/cmd/server

GOROOT_PATH=$(shell go env GOROOT)
WASM_124=$(GOROOT_PATH)/lib/wasm/wasm_exec.js
WASM_123=$(GOROOT_PATH)/misc/wasm/wasm_exec.js
TARGET_DIR=./docs/webui/assets

build-webui:
@if [ -f "$(shell go env GOROOT)/lib/wasm/wasm_exec.js" ]; then \
cp $(shell go env GOROOT)/lib/wasm/wasm_exec.js ./docs/webui/assets/wasm_exec.js; \
@if [ -f "$(WASM_124)" ]; then \
cp "$(WASM_124)" "$(TARGET_DIR)/wasm_exec.js"; \
else \
cp $(shell go env GOROOT)/misc/wasm/wasm_exec.js ./docs/webui/assets/wasm_exec.js; \
cp "$(WASM_123)" "$(TARGET_DIR)/wasm_exec.js"; \
fi
GOOS=js GOARCH=wasm go build -o ./docs/webui/assets/wire.wasm github.com/moov-io/wire/docs/webui/
GOOS=js GOARCH=wasm go build -o $(TARGET_DIR)/wire.wasm github.com/moov-io/wire/docs/webui/

.PHONY: check
check:
Expand Down

0 comments on commit c42d882

Please sign in to comment.