2021-11-09 09:21:31 +00:00
|
|
|
|
2022-12-10 16:05:01 +00:00
|
|
|
CC_TEST_REPORTER_ID := c09efa7c67c269bfdc6f8a356785d8f7ed55c9dc2b9a1d07b78c384f55c4e527
|
2021-11-09 09:21:31 +00:00
|
|
|
GO_HTML_COV := ./coverage.html
|
|
|
|
GO_TEST_OUTFILE := ./c.out
|
2022-11-09 19:53:01 +00:00
|
|
|
CC_PREFIX := github.com/waku-org/go-waku
|
2021-11-09 09:21:31 +00:00
|
|
|
|
2022-03-21 23:15:53 +00:00
|
|
|
SHELL := bash # the shell used internally by Make
|
|
|
|
|
2022-06-03 01:55:11 +00:00
|
|
|
GOBIN ?= $(shell which go)
|
|
|
|
|
2023-09-11 14:24:05 +00:00
|
|
|
.PHONY: all build lint lint-full 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
|
2023-06-28 14:59:15 +00:00
|
|
|
TEST_REPORTER_URL := https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64
|
2022-03-21 23:15:53 +00:00
|
|
|
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
|
2023-06-28 14:59:15 +00:00
|
|
|
TEST_REPORTER_URL := https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
|
2022-03-21 23:15:53 +00:00
|
|
|
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)
|
2022-06-19 21:47:39 +00:00
|
|
|
VERSION = $(shell cat ./VERSION)
|
2022-11-26 15:57:11 +00:00
|
|
|
UID := $(shell id -u)
|
|
|
|
GID := $(shell id -g)
|
|
|
|
|
2022-05-05 18:12:11 +00:00
|
|
|
|
|
|
|
BUILD_FLAGS ?= $(shell echo "-ldflags='\
|
2022-11-25 21:24:34 +00:00
|
|
|
-X github.com/waku-org/go-waku/waku/v2/node.GitCommit=$(GIT_COMMIT) \
|
|
|
|
-X github.com/waku-org/go-waku/waku/v2/node.Version=$(VERSION)'")
|
2022-05-05 18:12:11 +00:00
|
|
|
|
2022-12-12 18:04:15 +00:00
|
|
|
ANDROID_TARGET ?= 23
|
2022-08-12 12:44:13 +00:00
|
|
|
|
|
|
|
# control rln code compilation
|
2023-09-12 19:14:08 +00:00
|
|
|
ifeq ($(NO_RLN), true)
|
|
|
|
BUILD_TAGS := gowaku_no_rln
|
2022-08-12 12:44:13 +00:00
|
|
|
endif
|
|
|
|
|
2023-08-21 17:04:35 +00:00
|
|
|
all: build
|
2021-04-13 18:54:15 +00:00
|
|
|
|
2021-08-16 09:48:11 +00:00
|
|
|
deps: lint-install
|
|
|
|
|
2023-08-04 11:07:45 +00:00
|
|
|
build-with-race:
|
|
|
|
${GOBIN} build -race -tags="${BUILD_TAGS}" $(BUILD_FLAGS) -o build/waku ./cmd/waku
|
|
|
|
|
2021-04-13 18:54:15 +00:00
|
|
|
build:
|
2022-11-26 15:57:11 +00:00
|
|
|
${GOBIN} build -tags="${BUILD_TAGS}" $(BUILD_FLAGS) -o build/waku ./cmd/waku
|
2021-07-29 12:40:54 +00:00
|
|
|
|
2022-08-15 23:29:19 +00:00
|
|
|
chat2:
|
|
|
|
pushd ./examples/chat2 && \
|
2023-09-12 19:14:08 +00:00
|
|
|
${GOBIN} build -o ../../build/chat2 . && \
|
2022-08-15 23:29:19 +00:00
|
|
|
popd
|
|
|
|
|
2021-09-27 17:52:56 +00:00
|
|
|
vendor:
|
2022-06-03 01:55:11 +00:00
|
|
|
${GOBIN} mod tidy
|
2021-09-27 17:52:56 +00:00
|
|
|
|
2021-08-16 09:48:11 +00:00
|
|
|
lint-install:
|
|
|
|
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
|
2023-04-03 13:48:07 +00:00
|
|
|
bash -s -- -b $(shell ${GOBIN} env GOPATH)/bin v1.52.2
|
2021-08-16 09:48:11 +00:00
|
|
|
|
2021-07-29 12:40:54 +00:00
|
|
|
lint:
|
|
|
|
@echo "lint"
|
2023-09-11 14:24:05 +00:00
|
|
|
@golangci-lint run ./... --deadline=5m
|
|
|
|
|
|
|
|
lint-full:
|
|
|
|
@echo "lint"
|
|
|
|
@golangci-lint run ./... --config=./.golangci.full.yaml --deadline=5m
|
2021-10-13 12:48:29 +00:00
|
|
|
|
2023-08-07 15:50:36 +00:00
|
|
|
test-with-race:
|
2023-11-07 14:56:48 +00:00
|
|
|
${GOBIN} test -race -timeout 300s ./waku/... ./cmd/waku/server/...
|
2023-08-07 15:50:36 +00:00
|
|
|
|
2021-08-13 11:56:09 +00:00
|
|
|
test:
|
2023-11-07 14:56:48 +00:00
|
|
|
${GOBIN} test -timeout 300s ./waku/... ./cmd/waku/server/... -coverprofile=${GO_TEST_OUTFILE}.tmp -coverpkg ./...
|
2021-11-09 13:18:36 +00:00
|
|
|
cat ${GO_TEST_OUTFILE}.tmp | grep -v ".pb.go" > ${GO_TEST_OUTFILE}
|
2022-06-03 01:55:11 +00:00
|
|
|
${GOBIN} tool cover -html=${GO_TEST_OUTFILE} -o ${GO_HTML_COV}
|
2021-11-09 09:21:31 +00:00
|
|
|
|
2023-04-13 20:41:22 +00:00
|
|
|
COVERAGE_FILE := ./coverage/cc-test-reporter
|
|
|
|
$(COVERAGE_FILE):
|
2023-06-28 14:59:15 +00:00
|
|
|
curl -sfL $(TEST_REPORTER_URL) --output ./coverage/cc-test-reporter #TODO: Support windows
|
2023-04-13 20:41:22 +00:00
|
|
|
chmod +x ./coverage/cc-test-reporter
|
|
|
|
|
|
|
|
_before-cc: $(COVERAGE_FILE)
|
|
|
|
|
2021-11-09 09:21:31 +00:00
|
|
|
CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} ./coverage/cc-test-reporter before-build
|
|
|
|
|
|
|
|
_after-cc:
|
2022-09-12 14:13:38 +00:00
|
|
|
GIT_COMMIT=$(git log | grep -m1 -oE '[^ ]+$') CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} ./coverage/cc-test-reporter after-build --prefix ${CC_PREFIX}
|
2021-11-09 09:21:31 +00:00
|
|
|
|
|
|
|
test-ci: _before-cc test _after-cc
|
2021-10-14 09:03:25 +00:00
|
|
|
|
|
|
|
generate:
|
2023-02-06 22:16:20 +00:00
|
|
|
${GOBIN} generate ./...
|
2022-07-05 21:28:34 +00:00
|
|
|
|
2021-11-01 16:23:00 +00:00
|
|
|
coverage:
|
2022-08-15 17:13:45 +00:00
|
|
|
${GOBIN} test -count 1 -coverprofile=coverage.out ./...
|
2022-06-03 01:55:11 +00:00
|
|
|
${GOBIN} tool cover -html=coverage.out -o=coverage.html
|
2021-11-01 16:23:00 +00:00
|
|
|
|
2021-10-15 10:47:23 +00:00
|
|
|
# build a docker image for the fleet
|
|
|
|
docker-image: DOCKER_IMAGE_TAG ?= latest
|
2023-09-20 10:44:01 +00:00
|
|
|
docker-image: DOCKER_IMAGE_NAME ?= wakuorg/go-waku:$(DOCKER_IMAGE_TAG)
|
2021-10-15 10:47:23 +00:00
|
|
|
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
|
|
|
|
2024-01-03 15:14:59 +00:00
|
|
|
build-example-basic-relay:
|
|
|
|
cd examples/basic-relay && $(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)
|
|
|
|
|
2023-10-30 16:30:25 +00:00
|
|
|
build-example-noise:
|
|
|
|
cd examples/noise && $(MAKE)
|
|
|
|
|
2023-09-13 23:08:14 +00:00
|
|
|
build-example-rln:
|
|
|
|
cd examples/rln && $(MAKE)
|
|
|
|
|
2024-01-03 15:14:59 +00:00
|
|
|
build-example: build-example-basic-relay build-example-chat-2 build-example-filter2 build-example-c-bindings build-example-noise build-example-rln
|
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..."
|
2022-06-03 01:55:11 +00:00
|
|
|
${GOBIN} build \
|
2022-03-21 23:15:53 +00:00
|
|
|
-buildmode=c-archive \
|
2023-09-12 19:14:08 +00:00
|
|
|
-tags="${BUILD_TAGS} gowaku_no_rln" \
|
2022-03-21 23:15:53 +00:00
|
|
|
-o ./build/lib/libgowaku.a \
|
2023-08-10 13:30:38 +00:00
|
|
|
./library/c/
|
2022-03-21 23:15:53 +00:00
|
|
|
@echo "Static library built:"
|
2023-08-21 14:08:31 +00:00
|
|
|
ifeq ($(detected_OS),Darwin)
|
|
|
|
sed -i '' -e "s/#include <cgo_utils.h>//gi" ./build/lib/libgowaku.h
|
|
|
|
else
|
2023-08-10 13:30:38 +00:00
|
|
|
sed -i "s/#include <cgo_utils.h>//gi" ./build/lib/libgowaku.h
|
2023-08-21 14:08:31 +00:00
|
|
|
endif
|
2022-03-21 23:15:53 +00:00
|
|
|
@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..."
|
2023-08-10 13:30:38 +00:00
|
|
|
rm -f ./build/lib/libgowaku.$(GOBIN_SHARED_LIB_EXT)*
|
2022-06-03 01:55:11 +00:00
|
|
|
$(GOBIN_SHARED_LIB_CFLAGS) $(GOBIN_SHARED_LIB_CGO_LDFLAGS) ${GOBIN} build \
|
2022-03-21 23:15:53 +00:00
|
|
|
-buildmode=c-shared \
|
2023-09-12 19:14:08 +00:00
|
|
|
-tags="${BUILD_TAGS} gowaku_no_rln" \
|
2022-03-21 23:15:53 +00:00
|
|
|
-o ./build/lib/libgowaku.$(GOBIN_SHARED_LIB_EXT) \
|
2023-08-10 13:30:38 +00:00
|
|
|
./library/c/
|
2023-08-21 14:08:31 +00:00
|
|
|
ifeq ($(detected_OS),Darwin)
|
|
|
|
sed -i '' -e "s/#include <cgo_utils.h>//gi" ./build/lib/libgowaku.h
|
|
|
|
else
|
2023-08-10 13:30:38 +00:00
|
|
|
sed -i "s/#include <cgo_utils.h>//gi" ./build/lib/libgowaku.h
|
2023-08-21 14:08:31 +00:00
|
|
|
endif
|
2022-03-21 23:15:53 +00:00
|
|
|
ifeq ($(detected_OS),Linux)
|
|
|
|
cd ./build/lib && \
|
|
|
|
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:
|
2022-12-12 18:04:15 +00:00
|
|
|
@echo "Android target: ${ANDROID_TARGET} (override with ANDROID_TARGET var)"
|
2022-04-12 12:12:14 +00:00
|
|
|
gomobile init && \
|
2022-09-21 13:22:22 +00:00
|
|
|
${GOBIN} get -d golang.org/x/mobile/cmd/gomobile && \
|
2023-09-12 19:14:08 +00:00
|
|
|
CGO=1 gomobile bind -v -target=android -androidapi=${ANDROID_TARGET} -ldflags="-s -w" -tags="${BUILD_TAGS} gowaku_no_rln" $(BUILD_FLAGS) -o ./build/lib/gowaku.aar ./library/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 && \
|
2022-09-21 13:22:22 +00:00
|
|
|
${GOBIN} get -d golang.org/x/mobile/cmd/gomobile && \
|
2023-09-12 19:14:08 +00:00
|
|
|
gomobile bind -target=ios -ldflags="-s -w" -tags="nowatchdog ${BUILD_TAGS} gowaku_no_rln" $(BUILD_FLAGS) -o ./build/lib/Gowaku.xcframework ./library/mobile
|
2022-04-14 15:41:44 +00:00
|
|
|
@echo "IOS library built:"
|
2022-06-03 01:55:11 +00:00
|
|
|
@ls -la ./build/lib/*.xcframework
|
2022-06-19 21:50:37 +00:00
|
|
|
|
|
|
|
install-xtools:
|
2022-09-21 13:22:22 +00:00
|
|
|
${GOBIN} install golang.org/x/tools/...@v0.1.10
|
|
|
|
|
|
|
|
install-bindata:
|
|
|
|
${GOBIN} install github.com/kevinburke/go-bindata/go-bindata@v3.13.0
|
2022-06-19 21:50:37 +00:00
|
|
|
|
|
|
|
install-gomobile: install-xtools
|
2022-09-21 13:22:22 +00:00
|
|
|
${GOBIN} install golang.org/x/mobile/cmd/gomobile@v0.0.0-20220518205345-8578da9835fd
|
|
|
|
${GOBIN} install golang.org/x/mobile/cmd/gobind@v0.0.0-20220518205345-8578da9835fd
|
2022-06-19 21:50:37 +00:00
|
|
|
|
|
|
|
build-linux-pkg:
|
2023-09-20 10:44:01 +00:00
|
|
|
docker build --build-arg UID=${UID} --build-arg GID=${GID} -f ./scripts/linux/Dockerfile -t wakuorg/gowaku-linux-pkgs:latest .
|
2022-06-19 21:50:37 +00:00
|
|
|
./scripts/linux/docker-run.sh
|
|
|
|
ls -la ./build/*.rpm ./build/*.deb
|
2022-08-10 13:03:25 +00:00
|
|
|
|
|
|
|
TEST_MNEMONIC="swim relax risk shy chimney please usual search industry board music segment"
|
|
|
|
|
|
|
|
start-ganache:
|
|
|
|
docker run -p 8545:8545 --name ganache-cli --rm -d trufflesuite/ganache-cli:latest -m ${TEST_MNEMONIC}
|
|
|
|
|
|
|
|
stop-ganache:
|
|
|
|
docker stop ganache-cli
|
|
|
|
|
2022-08-12 12:44:13 +00:00
|
|
|
test-onchain: BUILD_TAGS += include_onchain_tests
|
2022-08-10 17:10:23 +00:00
|
|
|
test-onchain:
|
2022-11-09 19:53:01 +00:00
|
|
|
${GOBIN} test -v -count 1 -tags="${BUILD_TAGS}" github.com/waku-org/go-waku/waku/v2/protocol/rln
|
2022-08-10 17:10:23 +00:00
|
|
|
|
2023-08-07 15:50:36 +00:00
|
|
|
test-onchain-with-race:
|
2023-09-21 04:01:13 +00:00
|
|
|
${GOBIN} test -race -v -count 1 -tags="${BUILD_TAGS}" github.com/waku-org/go-waku/waku/v2/protocol/rln
|
|
|
|
|
|
|
|
test-postgres: PG_BUILD_TAGS = ${BUILD_TAGS} include_postgres_tests
|
|
|
|
test-postgres:
|
2023-11-20 12:51:29 +00:00
|
|
|
${GOBIN} test -p 1 -v -count 1 -tags="${PG_BUILD_TAGS}" github.com/waku-org/go-waku/waku/persistence/...
|
2023-09-21 04:01:13 +00:00
|
|
|
|
|
|
|
test-postgres-with-race:
|
2023-11-20 12:51:29 +00:00
|
|
|
${GOBIN} test -race -p 1 -v -count 1 -tags="${PG_BUILD_TAGS}" github.com/waku-org/go-waku/waku/persistence/...
|
2023-09-21 04:01:13 +00:00
|
|
|
|