Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

popm/wasm: improve and tidy up Go code #144

Merged
merged 7 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/popmd/popmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
"POPM_BTC_CHAIN_NAME": config.Config{
Value: &cfg.BTCChainName,
DefaultValue: popm.NewDefaultConfig().BTCChainName,
Help: "the name of the bitcoing chain to connect to (ex. \"mainnet\", \"testnet3\")",
Help: "the name of the bitcoin chain to connect to (ex. \"mainnet\", \"testnet3\")",
Print: config.PrintAll,
},
"POPM_PROMETHEUS_ADDRESS": config.Config{
Expand Down
35 changes: 21 additions & 14 deletions web/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,33 @@
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

PROJECTPATH = $(abspath $(dir $(realpath $(firstword $(MAKEFILE_LIST)))))

GOROOT=$(shell go env GOROOT)
GITVERSION=$(shell git rev-parse --short HEAD)
WEBAPP=webapp
WEBAPP=$(PROJECTPATH)/webapp
WWW_DIR=$(PROJECTPATH)/www
WASM_BINARY=$(WEBAPP)/popminer.wasm

version = $(patsubst v%,%,$(shell git describe --tags 2>/dev/null || echo "v0.0.0"))
commit = $(shell git rev-parse --short HEAD)

.PHONY: all clean prepare wasm www
.PHONY: all clean wasm www

all: wasm www

clean:
rm -rf ${WEBAPP}
rm -rf ${WASM_BINARY}

prepare:
mkdir -p ${WEBAPP}
# TODO(joshuasing): research using binaryen (wasm-opt) to optimise output binary
wasm:
CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -tags "$(BUILD_TAGS)" \
-ldflags "-s -w -X main.version=${version} -X main.gitCommit=${commit}" \
-o ${WASM_BINARY} ${PROJECTPATH}/popminer/...

wasm: prepare
GOOS=js GOARCH=wasm go build -trimpath -ldflags "-X main.gitVersion=${GITVERSION}" \
-o ${WEBAPP}/popminer.wasm ./popminer/popminer.go

www: prepare
cp www/index.html ${WEBAPP}
cp www/index.js ${WEBAPP}
cp www/popminer.js ${WEBAPP}
cp ${GOROOT}/misc/wasm/wasm_exec.js ${WEBAPP}/wasm_exec.js
www: wasm
mkdir -p ${WEBAPP}
cp ${WWW_DIR}/index.html ${WEBAPP}
cp ${WWW_DIR}/index.js ${WEBAPP}
cp ${WWW_DIR}/popminer.js ${WEBAPP}
cp ${WWW_DIR}/wasm_exec.js ${WEBAPP}
Loading