-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
59 lines (41 loc) · 2.23 KB
/
makefile
File metadata and controls
59 lines (41 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
BUILD_DIR := ./build
.PHONY: all build_android build_ios build_web prod production_build_android production_build_web create_build_dir clean
# -------------------------------------------------------------------------------------------
# Regular builds
# -------------------------------------------------------------------------------------------
all: build_android build_ios build_web
build_android: create_build_dir
gomobile bind -target=android -androidapi=35 -o ${BUILD_DIR}/android/core.aar ./pkg/api
# requires Xcode installed (mac only)
#build_ios: create_build_dir
# gomobile bind -target=ios ./pkg/api # TODO
build_web: create_build_dir
GOOS=js GOARCH=wasm go build -o ${BUILD_DIR}/web/core.wasm ./cmd/wasm # build the wasm
cp $$(go env GOROOT)/lib/wasm/wasm_exec.js ${BUILD_DIR}/web/wasm_exec.js # copy wasm_exec.js "glue"
# -------------------------------------------------------------------------------------------
# Production builds (ldflags make the binary smaller)
# -------------------------------------------------------------------------------------------
prod: production_build_android production_build_web
production_build_android: create_build_dir
gomobile bind -target=android -androidapi=35 -ldflags="-s -w" -o ${BUILD_DIR}/android/core.aar ./pkg/api
production_build_web: create_build_dir
GOOS=js GOARCH=wasm go build -ldflags="-w -s" -o ${BUILD_DIR}/web/core.wasm ./cmd/wasm # build the wasm
cp $$(go env GOROOT)/lib/wasm/wasm_exec.js ${BUILD_DIR}/web/wasm_exec.js # copy wasm_exec.js "glue"
# -------------------------------------------------------------------------------------------
# Other
# -------------------------------------------------------------------------------------------
create_build_dir:
mkdir -p ${BUILD_DIR}/android
mkdir -p ${BUILD_DIR}/ios
mkdir -p ${BUILD_DIR}/web
clean:
rm -rf ${BUILD_DIR}
gomobile clean
help:
@echo "Available targets:"
@echo " all - build Android + iOS + Web"
@echo " build_android - Android AAR"
@echo " build_ios - iOS XCFramework (works on MacOS only)"
@echo " build_web - WASM module + wasm_exec.js"
@echo " prod - production (stripped) builds"
@echo " clean - remove build artifacts"