From d1ebfa5fc6fadab9eb2cdfce44f3fc4aa40c2c96 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Wed, 7 Jan 2026 16:46:29 -0500 Subject: [PATCH] refactor(build): migrate from TinyGo to native Go for WASM build --- Makefile | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index f08ed28..af90bbb 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,8 @@ -.PHONY: all generate build build-debug build-opt test test-cover test-plugin lint fmt vet clean tidy deps verify help +.PHONY: all generate build build-debug build-opt test test-cover test-plugin test-browser lint fmt vet clean tidy deps verify serve help MODULE := enclave BINARY := enclave.wasm BUILD_DIR := build -TINYGO_FLAGS := -target=wasip1 -scheduler=none -gc=leaking all: generate build @@ -12,15 +11,15 @@ generate: build: @mkdir -p $(BUILD_DIR) - @tinygo build $(TINYGO_FLAGS) -o $(BUILD_DIR)/$(BINARY) . + @GOOS=wasip1 GOARCH=wasm go build -o $(BUILD_DIR)/$(BINARY) . build-debug: @mkdir -p $(BUILD_DIR) - @tinygo build $(TINYGO_FLAGS) -no-debug=false -o $(BUILD_DIR)/$(BINARY) . + @GOOS=wasip1 GOARCH=wasm go build -gcflags="all=-N -l" -o $(BUILD_DIR)/$(BINARY) . build-opt: @mkdir -p $(BUILD_DIR) - @tinygo build $(TINYGO_FLAGS) -opt=2 -o $(BUILD_DIR)/$(BINARY) . + @GOOS=wasip1 GOARCH=wasm go build -ldflags="-s -w" -o $(BUILD_DIR)/$(BINARY) . @wasm-opt -Os $(BUILD_DIR)/$(BINARY) -o $(BUILD_DIR)/$(BINARY) test: @@ -31,7 +30,15 @@ test-cover: @go tool cover -html=coverage.out -o coverage.html test-plugin: - @extism call $(BUILD_DIR)/$(BINARY) generate --input '{}' --wasi + @extism call $(BUILD_DIR)/$(BINARY) generate --input '{"credential":"dGVzdA=="}' --wasi + +test-browser: build + @echo "Open http://localhost:8080/example/ in your browser" + @python3 -m http.server 8080 + +serve: build + @echo "Open http://localhost:8080/example/ in your browser" + @python3 -m http.server 8080 lint: @golangci-lint run ./... @@ -54,24 +61,25 @@ deps: @go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest @go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest @go install mvdan.cc/gofumpt@latest - @echo "Install TinyGo: https://tinygo.org/getting-started/install/" @echo "Install Extism CLI: https://extism.org/docs/install" verify: fmt vet lint test help: - @echo "Motr Enclave - Extism Plugin (TinyGo/wasip1)" + @echo "Motr Enclave - Extism Plugin (Go 1.25/wasip1)" @echo "" @echo "Build targets:" - @echo " build - Build WASM plugin with TinyGo" + @echo " build - Build WASM plugin for wasip1" @echo " build-debug - Build with debug symbols" @echo " build-opt - Build optimized (requires wasm-opt)" @echo "" @echo "Development targets:" @echo " generate - Run sqlc to generate Go code" - @echo " test - Run tests with Go" + @echo " test - Run tests" @echo " test-cover - Run tests with coverage" @echo " test-plugin - Test plugin with Extism CLI" + @echo " test-browser- Build and serve for browser testing" + @echo " serve - Start local server for example/" @echo " lint - Run golangci-lint" @echo " fmt - Format code" @echo " vet - Run go vet"