-
-
Notifications
You must be signed in to change notification settings - Fork 34
Home
xuri edited this page Oct 7, 2024
·
2 revisions
Build on Unix / Linux / macOS by following Makefile
:
DIST = ./dist
SRC = ./src
WASM = ${DIST}/excelize.wasm
make: install test build
install:
npm install
test:
cd cmd && GOOS=js GOARCH=wasm go test -v \
-exec="${GOROOT}/misc/wasm/go_js_wasm_exec" \
-coverprofile=c.out ./ && go tool cover -html=c.out
build:
rm -rf ${DIST} && mkdir ${DIST}
node ./node_modules/.bin/rollup -c
cd cmd && GOOS=js GOARCH=wasm CGO_ENABLED=0 \
go build -v -a -ldflags="-w -s" \
-gcflags=-trimpath=${GOPATH} \
-asmflags=-trimpath=${GOPATH} \
-o ../dist/excelize.wasm ./main.go
gzip -f --best ${WASM}
cd ..
cp LICENSE ${DIST}
cp README.md ${DIST}
cp package.json ${DIST}
cp ${SRC}/index.d.ts ${DIST}
Build on Windows by following Powershell build.ps1
:
$DIST = ".\dist"
$SRC = ".\src"
$WASM = "$DIST\excelize.wasm"
$GOPATH = go env GOPATH
npm install
if (Test-Path $DIST) {
Remove-Item -Recurse -Force $DIST
}
mkdir $DIST
.\node_modules\.bin\rollup -c
cd cmd
$env:GOOS="js"; $env:GOARCH="wasm"; $env:CGO_ENABLED=0; `
go build -v -a -ldflags="-w -s" `
-gcflags=-trimpath=$GOPATH `
-asmflags=-trimpath=$GOPATH `
-o ..\dist\excelize.wasm .\main.go
cd ..
gzip -f --best $WASM
Copy-Item LICENSE $DIST
Copy-Item README.md $DIST
Copy-Item package.json $DIST
Copy-Item $SRC\index.d.ts $DIST
Execute powershell script by the following command:
powershell -File build.ps1
Note that, due to the limited support of the Go's WebAssembly test, we need to run tests on Unix / Linux / macOS.