refactor(build): update Makefile to use example build directory and simplify serve target

This commit is contained in:
2026-01-07 17:09:43 -05:00
parent 8073405b7f
commit dd05304177
3 changed files with 14 additions and 15 deletions

View File

@@ -1,8 +1,8 @@
.PHONY: all generate build build-debug build-opt test test-cover test-plugin test-browser lint fmt vet clean tidy deps verify serve help
.PHONY: all generate build build-debug build-opt test test-cover test-plugin lint fmt vet clean tidy deps verify serve help
MODULE := enclave
BINARY := enclave.wasm
BUILD_DIR := build
BUILD_DIR := example
all: generate build
@@ -10,15 +10,12 @@ generate:
@sqlc generate
build:
@mkdir -p $(BUILD_DIR)
@GOOS=wasip1 GOARCH=wasm go build -o $(BUILD_DIR)/$(BINARY) .
build-debug:
@mkdir -p $(BUILD_DIR)
@GOOS=wasip1 GOARCH=wasm go build -gcflags="all=-N -l" -o $(BUILD_DIR)/$(BINARY) .
build-opt:
@mkdir -p $(BUILD_DIR)
@GOOS=wasip1 GOARCH=wasm go build -ldflags="-s -w" -o $(BUILD_DIR)/$(BINARY) .
@wasm-opt -Os $(BUILD_DIR)/$(BINARY) -o $(BUILD_DIR)/$(BINARY)
@@ -32,13 +29,9 @@ test-cover:
test-plugin:
@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
@python3 -m http.server 8080 -d example
lint:
@golangci-lint run ./...
@@ -51,7 +44,7 @@ vet:
@go vet ./...
clean:
@rm -rf $(BUILD_DIR)
@rm -f $(BUILD_DIR)/$(BINARY)
@rm -f coverage.out coverage.html
tidy:
@@ -78,8 +71,7 @@ help:
@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 " serve - Build and serve example/ for browser testing"
@echo " lint - Run golangci-lint"
@echo " fmt - Format code"
@echo " vet - Run go vet"