Kasianov Nikolai Alekseevich
6 months ago
3 changed files with 44 additions and 15 deletions
@ -1,14 +1,25 @@
|
||||
game:=capyclick
|
||||
bin:=bin
|
||||
desktopBin:=bin/desktop
|
||||
webBin:=bin/web
|
||||
wasmHtml:=build/capyclick.html
|
||||
wasmExec:=$(shell go env GOROOT)
|
||||
|
||||
all: clean |
||||
mkdir -p bin
|
||||
cd src && go build && mv $(game)* ../bin
|
||||
current: clean environment |
||||
cd src && go build && mv $(game)* ../$(desktopBin)
|
||||
|
||||
cross: clean |
||||
mkdir -p bin
|
||||
cd src && GOOS=windows GOARCH=amd64 go build && mv $(game)* ../bin
|
||||
|
||||
web: environment |
||||
cd src && env GOOS=js GOARCH=wasm go build -o $(game).wasm . && mv $(game).wasm ../$(webBin)
|
||||
cp $(wasmHtml) $(webBin)
|
||||
cp $(wasmExec)/misc/wasm/wasm_exec.js $(webBin)
|
||||
|
||||
desktop: clean environment |
||||
cd src && GOOS=windows GOARCH=amd64 go build && mv $(game)* ../$(desktopBin)
|
||||
cd src && GOOS=linux GOARCH=amd64 go build && mv $(game)* ../$(desktopBin)
|
||||
|
||||
cross: clean environment web desktop |
||||
|
||||
environment: |
||||
mkdir -p $(desktopBin) $(webBin)
|
||||
|
||||
clean: |
||||
rm -rf bin
|
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html> |
||||
<script src="wasm_exec.js"></script> |
||||
|
||||
<script> |
||||
if (!WebAssembly.instantiateStreaming) { |
||||
WebAssembly.instantiateStreaming = async (resp, importObject) => { |
||||
const source = await (await resp).arrayBuffer(); |
||||
return await WebAssembly.instantiate(source, importObject); |
||||
}; |
||||
} |
||||
|
||||
const go = new Go(); |
||||
WebAssembly.instantiateStreaming(fetch("capyclick.wasm"), go.importObject).then(result => { |
||||
go.run(result.instance); |
||||
}); |
||||
</script> |
Loading…
Reference in new issue