This repository has been archived on 2021-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
WasmConv/AdvMakefile

43 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2021-02-10 22:47:40 +00:00
defaultName = "wasmconv"
defaultTarget = "serve_dev"
def wasmconv_serve_dev():
shell.Exec("go run . -dev")
def wasmconv_dist():
distDir = "dist"
if file.Exists(distDir):
log.Warn("Found existing dist dir, replacing")
shell.Exec("rm -r " + distDir)
log.Info("Finding wasm_exec.js")
GOROOT = shell.Exec("go env GOROOT", output='return')
GOROOT = strings.TrimSpace(GOROOT)
WasmExecPath = GOROOT + "/misc/wasm/wasm_exec.js"
if not file.Exists(WasmExecPath):
log.Fatal("File wasm_exec.js not found")
log.Info("Found wasm_exec.js at " + WasmExecPath)
shell.Exec("mkdir " + distDir)
shell.Exec(fmt.Sprintf("cp -v %s %s/wasm_exec.js", WasmExecPath, distDir))
if shell.LookPath("vugugen") == -1:
log.Info("Command `vugugen` not found, installing")
shell.Exec("github.com/vugu/vugu/cmd/vugugen")
log.Info("Generating code and building wasm")
shell.Exec(fmt.Sprintf("""
go generate .
env GOOS=js GOARCH=wasm go build -o %s/main.wasm
""", distDir))
log.Info("Copying static assets")
shell.Exec("cp -rv assets/* " + distDir)
log.Info("Building server executables")
shell.Exec(fmt.Sprintf("""
env GOOS=linux GOARCH=amd64 go build -o %s/server-linux-x86_64
env GOOS=linux GOARCH=arm64 go build -o %s/server-linux-aarch64
""", distDir, distDir))
log.Info("Dist complete")