-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
114 lines (83 loc) · 3.54 KB
/
Makefile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GOMODCORE := $(GOMODBASE)/zcncore
VERSION_FILE := $(ROOT_DIR)/core/version/version.go
MAJOR_VERSION := "1.0"
include _util/printer.mk
PLATFORM:=$(shell uname -s | tr "[:upper:]" "[:lower:]")
ifneq ($(filter $(GCC_MINOR),linux darwin),)
else
PLATFORM:=windows
endif
include _util/build_$(PLATFORM).mk
include _util/build_mobile.mk
.PHONY: build-tools install-all herumi-all gosdk-all sdkver help lint docs
default: help
#GO BUILD SDK
gomod-download:
go mod download -json
gomod-clean:
go clean -i -r -x -modcache ./...
clean-gosdk:
gosdk-build: gomod-download
go build -x -v -tags bn256 ./...
wasm-build: getrev
CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -ldflags="-s -w" -buildvcs=false -o ./zcn.wasm ./wasmsdk
wasm-test: wasm-build
env -i $(shell go env) PATH="$(shell go env GOROOT)/misc/wasm:$(PATH)" CGO_ENABLED=0 GOOS=js GOARCH=wasm go test -v ./wasmsdk/jsbridge/input_test.go ./wasmsdk/jsbridge/input.go ./wasmsdk/jsbridge/object.go ./wasmsdk/jsbridge/error.go ./wasmsdk/jsbridge/func.go ./wasmsdk/jsbridge/func_test.go ./wasmsdk/jsbridge/sync.go ./wasmsdk/jsbridge/async.go ./wasmsdk/jsbridge/output.go ./wasmsdk/jsbridge/vars.go
gosdk-mocks:
./generate_mocks.sh
gosdk-test:
go test -tags bn256 -p 1 ./...
install-gosdk: | gosdk-build wasm-build
$(GOPATH)/bin/modvendor:
@go get -u github.com/goware/modvendor
vendor: $(GOPATH)/bin/modvendor
@GO111MODULE=on go mod vendor -v
@modvendor -copy="**/*.c **/*.h **/*.a" -v
getrev:
$(eval VERSION_STR=$(shell git describe --tags --always))
@echo "" > $(VERSION_FILE)
@echo "//====== THIS IS AUTOGENERATED FILE. DO NOT MODIFY ========" >> $(VERSION_FILE)
@echo "" >> $(VERSION_FILE)
@echo "package version" >> $(VERSION_FILE)
@echo const VERSIONSTR = \"$(VERSION_STR)\" >> $(VERSION_FILE)
@echo "" >> $(VERSION_FILE)
install: install-gosdk sdkver
test: gosdk-test
clean: clean-gosdk clean-herumi
@rm -rf $(OUTDIR)
lint-wasm:
GOOS=js GOARCH=wasm CGO_ENABLED=0 golangci-lint run wasmsdk --disable-all -E errcheck
lint: lint-wasm
golangci-lint run --skip-dirs wasmsdk
build-windows: getrev
@echo "Building 0Chain Windows SDK. Please wait..."
@go build --buildmode=c-shared -ldflags="-s -w" -o ./winsdk/zcn.windows.dll ./winsdk
@echo " ./winsdk/zcn.windows.dll - [OK]"
help:
@echo "Environment: "
@echo "\tPLATFORM.......: $(PLATFORM)"
@echo "\tGOPATH.........: $(GOPATH)"
@echo "\tGOROOT.........: $(GOROOT)"
@echo ""
@echo "Supported commands:"
@echo "\tmake help - Display environment and make targets"
@echo "\tmake build-tools - Install go, jq and supporting tools required for build"
@echo "\tmake install - Install gosdk"
@echo "\tmake clean - Deletes all build output files"
@echo "\tmake lint - Runs the golangci-lint
install-herumi-ubuntu:
@cd /tmp && \
wget -O - https://github.com/herumi/mcl/archive/refs/tags/v1.57.tar.gz | tar xz && \
wget -O - https://github.com/herumi/bls/archive/refs/tags/v1.22.tar.gz | tar xz && \
rm -rf mcl && mv mcl* mcl && \
rm -rf bls &&mv bls* bls && \
make -C mcl -j $(nproc) lib/libmclbn256.so install && \
cp mcl/lib/libmclbn256.so /usr/local/lib && \
make MCL_DIR=/tmp/mcl -C bls -j $(nproc) install && \
rm -R /tmp/mcl && \
rm -R /tmp/bls
docs:
@gomarkdoc --exclude-dirs ./zcncore/sample --output '{{.Dir}}/README.md' --repository.default-branch doc/initial ./...
@sed -i '' -r 's/\\_/_/g' ./**/README.md
@sed -i '' -r 's/\\`/`/g' ./**/README.md