2021-11-09 09:21:31 +00:00
|
|
|
|
|
|
|
CC_TEST_REPORTER_ID := 343d0af350b29aaf08d1e5bb4465d0e21df6298a27240acd2434457a9984c74a
|
|
|
|
GO_HTML_COV := ./coverage.html
|
|
|
|
GO_TEST_OUTFILE := ./c.out
|
|
|
|
CC_PREFIX := github.com/status-im/go-waku
|
|
|
|
|
2022-03-21 23:15:53 +00:00
|
|
|
SHELL := bash # the shell used internally by Make
|
|
|
|
|
2022-04-14 15:41:44 +00:00
|
|
|
.PHONY: all build lint test coverage build-example static-library dynamic-library test-c test-c-template mobile-android mobile-ios
|
2022-03-21 23:15:53 +00:00
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
|
|
|
|
detected_OS := Windows
|
|
|
|
else
|
|
|
|
detected_OS := $(strip $(shell uname))
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(detected_OS),Darwin)
|
|
|
|
GOBIN_SHARED_LIB_EXT := dylib
|
|
|
|
ifeq ("$(shell sysctl -nq hw.optional.arm64)","1")
|
|
|
|
# Building on M1 is still not supported, so in the meantime we crosscompile to amd64
|
|
|
|
GOBIN_SHARED_LIB_CFLAGS=CGO_ENABLED=1 GOOS=darwin GOARCH=amd64
|
|
|
|
endif
|
|
|
|
else ifeq ($(detected_OS),Windows)
|
|
|
|
# on Windows need `--export-all-symbols` flag else expected symbols will not be found in libgowaku.dll
|
|
|
|
GOBIN_SHARED_LIB_CGO_LDFLAGS := CGO_LDFLAGS="-Wl,--export-all-symbols"
|
|
|
|
GOBIN_SHARED_LIB_EXT := dll
|
|
|
|
else
|
|
|
|
GOBIN_SHARED_LIB_EXT := so
|
|
|
|
GOBIN_SHARED_LIB_CGO_LDFLAGS := CGO_LDFLAGS="-Wl,-soname,libgowaku.so.0"
|
|
|
|
endif
|
2021-04-13 18:54:15 +00:00
|
|
|
|
2022-05-05 18:12:11 +00:00
|
|
|
GIT_COMMIT = $(shell git rev-parse --short HEAD)
|
|
|
|
|
|
|
|
BUILD_FLAGS ?= $(shell echo "-ldflags='\
|
|
|
|
-X github.com/status-im/go-waku/waku/v2/node.GitCommit=$(GIT_COMMIT)'")
|
|
|
|
|
2021-04-13 18:54:15 +00:00
|
|
|
all: build
|
|
|
|
|
2021-08-16 09:48:11 +00:00
|
|
|
deps: lint-install
|
|
|
|
|
2021-04-13 18:54:15 +00:00
|
|
|
build:
|
2022-05-05 18:12:11 +00:00
|
|
|
go build $(BUILD_FLAGS) -o build/waku waku.go
|
2021-07-29 12:40:54 +00:00
|
|
|
|
2021-09-27 17:52:56 +00:00
|
|
|
vendor:
|
|
|
|
go mod tidy
|
|
|
|
|
2021-08-16 09:48:11 +00:00
|
|
|
lint-install:
|
|
|
|
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
|
|
|
|
bash -s -- -b $(shell go env GOPATH)/bin v1.41.1
|
|
|
|
|
2021-07-29 12:40:54 +00:00
|
|
|
lint:
|
|
|
|
@echo "lint"
|
2021-08-13 11:56:09 +00:00
|
|
|
@golangci-lint --exclude=SA1019 run ./... --deadline=5m
|
2021-10-13 12:48:29 +00:00
|
|
|
|
2021-08-13 11:56:09 +00:00
|
|
|
test:
|
2021-11-09 13:18:36 +00:00
|
|
|
go test ./waku/... -coverprofile=${GO_TEST_OUTFILE}.tmp
|
|
|
|
cat ${GO_TEST_OUTFILE}.tmp | grep -v ".pb.go" > ${GO_TEST_OUTFILE}
|
2021-11-09 09:21:31 +00:00
|
|
|
go tool cover -html=${GO_TEST_OUTFILE} -o ${GO_HTML_COV}
|
|
|
|
|
|
|
|
_before-cc:
|
|
|
|
CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} ./coverage/cc-test-reporter before-build
|
|
|
|
|
|
|
|
_after-cc:
|
|
|
|
CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} ./coverage/cc-test-reporter after-build --prefix ${CC_PREFIX}
|
|
|
|
|
|
|
|
test-ci: _before-cc test _after-cc
|
2021-10-14 09:03:25 +00:00
|
|
|
|
|
|
|
generate:
|
2021-10-15 10:47:23 +00:00
|
|
|
go generate ./waku/v2/protocol/pb/generate.go
|
2022-05-30 19:13:27 +00:00
|
|
|
go generate ./waku/persistence/migrations/sql
|
2021-10-15 10:47:23 +00:00
|
|
|
|
2021-11-01 16:23:00 +00:00
|
|
|
coverage:
|
|
|
|
go test -count 1 -coverprofile=coverage.out ./...
|
|
|
|
go tool cover -html=coverage.out -o=coverage.html
|
|
|
|
|
2021-10-15 10:47:23 +00:00
|
|
|
# build a docker image for the fleet
|
|
|
|
docker-image: DOCKER_IMAGE_TAG ?= latest
|
|
|
|
docker-image: DOCKER_IMAGE_NAME ?= statusteam/go-waku:$(DOCKER_IMAGE_TAG)
|
|
|
|
docker-image:
|
|
|
|
docker build --tag $(DOCKER_IMAGE_NAME) \
|
|
|
|
--build-arg="GIT_COMMIT=$(shell git rev-parse HEAD)" .
|
2021-11-01 16:23:00 +00:00
|
|
|
|
|
|
|
build-example-basic2:
|
2021-11-02 00:05:55 +00:00
|
|
|
cd examples/basic2 && $(MAKE)
|
2021-11-01 16:23:00 +00:00
|
|
|
|
|
|
|
build-example-chat-2:
|
2021-11-02 00:05:55 +00:00
|
|
|
cd examples/chat2 && $(MAKE)
|
2021-11-01 16:23:00 +00:00
|
|
|
|
|
|
|
build-example-filter2:
|
2021-11-02 00:05:55 +00:00
|
|
|
cd examples/filter2 && $(MAKE)
|
2021-11-01 16:23:00 +00:00
|
|
|
|
2022-03-22 16:30:14 +00:00
|
|
|
build-example-c-bindings:
|
|
|
|
cd examples/c-bindings && $(MAKE)
|
|
|
|
|
|
|
|
build-example: build-example-basic2 build-example-chat-2 build-example-filter2 build-example-c-bindings
|
2022-03-21 23:15:53 +00:00
|
|
|
|
2022-04-12 12:12:14 +00:00
|
|
|
static-library:
|
2022-03-21 23:15:53 +00:00
|
|
|
@echo "Building static library..."
|
|
|
|
go build \
|
|
|
|
-buildmode=c-archive \
|
|
|
|
-o ./build/lib/libgowaku.a \
|
|
|
|
./library/
|
|
|
|
@echo "Static library built:"
|
|
|
|
@ls -la ./build/lib/libgowaku.*
|
|
|
|
|
2022-04-12 12:12:14 +00:00
|
|
|
dynamic-library:
|
2022-03-21 23:15:53 +00:00
|
|
|
@echo "Building shared library..."
|
|
|
|
$(GOBIN_SHARED_LIB_CFLAGS) $(GOBIN_SHARED_LIB_CGO_LDFLAGS) go build \
|
|
|
|
-buildmode=c-shared \
|
|
|
|
-o ./build/lib/libgowaku.$(GOBIN_SHARED_LIB_EXT) \
|
|
|
|
./library/
|
|
|
|
ifeq ($(detected_OS),Linux)
|
|
|
|
cd ./build/lib && \
|
|
|
|
ls -lah . && \
|
|
|
|
mv ./libgowaku.$(GOBIN_SHARED_LIB_EXT) ./libgowaku.$(GOBIN_SHARED_LIB_EXT).0 && \
|
|
|
|
ln -s ./libgowaku.$(GOBIN_SHARED_LIB_EXT).0 ./libgowaku.$(GOBIN_SHARED_LIB_EXT)
|
|
|
|
endif
|
|
|
|
@echo "Shared library built:"
|
|
|
|
@ls -la ./build/lib/libgowaku.*
|
2022-04-12 12:12:14 +00:00
|
|
|
|
|
|
|
mobile-android:
|
|
|
|
gomobile init && \
|
2022-05-05 18:12:11 +00:00
|
|
|
gomobile bind -target=android -ldflags="-s -w" $(BUILD_FLAGS) -o ./build/lib/gowaku.aar ./mobile
|
2022-04-12 12:12:14 +00:00
|
|
|
@echo "Android library built:"
|
2022-04-14 15:41:44 +00:00
|
|
|
@ls -la ./build/lib/*.aar ./build/lib/*.jar
|
|
|
|
|
|
|
|
mobile-ios:
|
|
|
|
gomobile init && \
|
|
|
|
gomobile bind -target=ios -ldflags="-s -w" -o ./build/lib/Gowaku.xcframework ./mobile
|
|
|
|
@echo "IOS library built:"
|
|
|
|
@ls -la ./build/lib/*.xcframework
|