Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip debug symbols in WASM files #239

Merged
merged 3 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,31 @@ PUBLIC_DIR ?= $(UI)/public
WEBWORKER_PKG ?= ./cmd/webworker
INTERPRETER_PKG ?= ./cmd/go-repl

define build_wasm_worker
@echo ":: Building WebAssembly worker '$(1)' ..."
GOOS=js GOARCH=wasm $(GO) build -ldflags "-s -w" -trimpath \
$(3) -o $(PUBLIC_DIR)/$(2) $(1)
endef

define check_tool
@if ! command -v $(1) >/dev/null 2>&1 ; then\
echo "ERROR: '$(1)' binary not found. Please ensure that tool is installed or specify binary path with '$(2)' variable." && \
exit 1; \
fi;
endef


.PHONY: clean
clean:
@echo ":: Cleanup..." && rm -rf $(TARGET) && rm -rf $(UI)/build

.PHONY:check-go
check-go:
@if ! command -v $(GO) >/dev/null 2>&1 ; then\
echo "ERROR: '$(GO)' binary not found. Please ensure that Go is installed or specify binary path with 'GO' variable." && \
exit 1; \
fi;
$(call check_tool,$(GO),'GO')

.PHONY:check-yarn
check-yarn:
@if ! command -v $(YARN) >/dev/null 2>&1 ; then\
echo "ERROR: '$(YARN)' binary not found. Please ensure that Node.js and Yarn are installed or specify binary path with 'YARN' variable." && \
exit 1; \
fi;
$(call check_tool,$(YARN),'YARN')

# Build targets
.PHONY: collect-meta
Expand Down Expand Up @@ -51,13 +59,11 @@ copy-wasm-exec:

.PHONY:build-webworker
build-webworker:
@echo ":: Building Go Webworker module..." && \
GOOS=js GOARCH=wasm $(GO) build -o $(PUBLIC_DIR)/worker.wasm $(WEBWORKER_PKG)
$(call build_wasm_worker,$(WEBWORKER_PKG),'worker.wasm')

.PHONY:go-repl
go-repl:
@echo ":: Building Go interpreter module..." && \
GOOS=js GOARCH=wasm $(GO) build -o $(PUBLIC_DIR)/go-repl.wasm $(INTERPRETER_PKG)
$(call build_wasm_worker,$(INTERPRETER_PKG),'go-repl.wasm')

.PHONY:build-wasm
build-wasm: copy-wasm-exec build-webworker go-repl
Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ COPY go.sum .
ARG APP_VERSION=1.0.0
RUN echo "Building server with version $APP_VERSION" && \
go build -o server -ldflags="-X 'main.Version=$APP_VERSION'" ./cmd/playground && \
GOOS=js GOARCH=wasm go build -o ./go-repl.wasm ./cmd/go-repl && \
GOOS=js GOARCH=wasm go build -o ./worker.wasm ./cmd/webworker && \
GOOS=js GOARCH=wasm go build -ldflags "-s -w" -trimpath -o ./go-repl.wasm ./cmd/go-repl && \
GOOS=js GOARCH=wasm go build -ldflags "-s -w" -trimpath -o ./worker.wasm ./cmd/webworker && \
cp $(go env GOROOT)/misc/wasm/wasm_exec.js .

FROM golang:1.19-alpine as production
Expand Down
4 changes: 2 additions & 2 deletions build/release.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ COPY go.sum .
ARG APP_VERSION=1.0.0
RUN echo "Building server with version $APP_VERSION" && \
go build -o server -ldflags="-X 'main.Version=$APP_VERSION'" ./cmd/playground && \
GOOS=js GOARCH=wasm go build -o ./worker.wasm ./cmd/webworker && \
GOOS=js GOARCH=wasm go build -o ./go-repl.wasm ./cmd/go-repl && \
GOOS=js GOARCH=wasm go build -ldflags "-s -w" -trimpath -o ./worker.wasm ./cmd/webworker && \
GOOS=js GOARCH=wasm go build -ldflags "-s -w" -trimpath -o ./go-repl.wasm ./cmd/go-repl && \
cp $(go env GOROOT)/misc/wasm/wasm_exec.js .

FROM golang:1.19-alpine as production
Expand Down