Feature(Go): Embed and serve web UI assets
This commit is contained in:
@@ -17,41 +17,49 @@ LDFLAGS=-ldflags "-s -w"
|
||||
MKDIR=if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
|
||||
RMDIR=if exist $(BUILD_DIR) rmdir /s /q $(BUILD_DIR)
|
||||
|
||||
.PHONY: all clean windows linux build help windows-386 linux-arm64 all-platforms test fmt deps
|
||||
.PHONY: all clean windows linux build help windows-386 linux-arm64 all-platforms test fmt deps sync
|
||||
|
||||
# Default target
|
||||
all: clean windows linux
|
||||
|
||||
# Sync web assets from server/web/ into web/assets/ for //go:embed.
|
||||
# Single source of truth is server/web/index.html; this just keeps a vendored copy.
|
||||
sync:
|
||||
@echo Syncing web assets from ../web/...
|
||||
@if not exist web\assets mkdir web\assets
|
||||
@copy /Y ..\web\index.html web\assets\index.html >nul
|
||||
@echo Done
|
||||
|
||||
# Build for current platform
|
||||
build:
|
||||
build: sync
|
||||
@echo Building for current platform...
|
||||
@$(MKDIR)
|
||||
go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME).exe $(MAIN_PACKAGE)
|
||||
@echo Done
|
||||
|
||||
# Build for Windows (amd64)
|
||||
windows:
|
||||
windows: sync
|
||||
@echo Building for Windows amd64...
|
||||
@$(MKDIR)
|
||||
set GOOS=windows&& set GOARCH=amd64&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_windows_amd64.exe $(MAIN_PACKAGE)
|
||||
@echo Done: $(BUILD_DIR)\$(BINARY_NAME)_windows_amd64.exe
|
||||
|
||||
# Build for Windows (386)
|
||||
windows-386:
|
||||
windows-386: sync
|
||||
@echo Building for Windows 386...
|
||||
@$(MKDIR)
|
||||
set GOOS=windows&& set GOARCH=386&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_windows_386.exe $(MAIN_PACKAGE)
|
||||
@echo Done: $(BUILD_DIR)\$(BINARY_NAME)_windows_386.exe
|
||||
|
||||
# Build for Linux (amd64)
|
||||
linux:
|
||||
linux: sync
|
||||
@echo Building for Linux amd64...
|
||||
@$(MKDIR)
|
||||
set GOOS=linux&& set GOARCH=amd64&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_linux_amd64 $(MAIN_PACKAGE)
|
||||
@echo Done: $(BUILD_DIR)\$(BINARY_NAME)_linux_amd64
|
||||
|
||||
# Build for Linux (arm64)
|
||||
linux-arm64:
|
||||
linux-arm64: sync
|
||||
@echo Building for Linux arm64...
|
||||
@$(MKDIR)
|
||||
set GOOS=linux&& set GOARCH=arm64&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_linux_arm64 $(MAIN_PACKAGE)
|
||||
@@ -89,6 +97,7 @@ help:
|
||||
@echo linux - Build for Linux amd64
|
||||
@echo linux-arm64 - Build for Linux arm64
|
||||
@echo all-platforms - Build for all platforms
|
||||
@echo sync - Sync web assets from ../web/ for //go:embed
|
||||
@echo clean - Clean build directory
|
||||
@echo test - Run tests
|
||||
@echo fmt - Format code
|
||||
|
||||
Reference in New Issue
Block a user