2022-11-30 20:02:39 +00:00
|
|
|
# Copyright (c) 2022 Status Research & Development GmbH. Licensed under
|
2020-04-30 15:51:30 +00:00
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
|
2022-01-24 11:48:06 +00:00
|
|
|
EXCLUDED_NIM_PACKAGES := vendor/nim-dnsdisc/vendor
|
2021-06-15 07:51:09 +00:00
|
|
|
LINK_PCRE := 0
|
2023-05-23 08:44:57 +00:00
|
|
|
LOG_LEVEL := TRACE
|
2021-06-15 07:51:09 +00:00
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
|
2020-04-29 04:49:27 +00:00
|
|
|
|
2020-04-29 05:54:03 +00:00
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
ifeq ($(NIM_PARAMS),)
|
|
|
|
# "variables.mk" was not included, so we update the submodules.
|
|
|
|
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
|
|
|
|
.DEFAULT:
|
|
|
|
+@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \
|
|
|
|
$(GIT_SUBMODULE_UPDATE); \
|
|
|
|
echo
|
|
|
|
# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself:
|
|
|
|
# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles
|
|
|
|
#
|
|
|
|
# After restarting, it will execute its original goal, so we don't have to start a child Make here
|
|
|
|
# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great?
|
2020-05-01 05:00:00 +00:00
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
else # "variables.mk" was included. Business as usual until the end of this file.
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
##########
|
|
|
|
## Main ##
|
|
|
|
##########
|
2023-08-09 17:11:50 +00:00
|
|
|
.PHONY: all test update clean
|
2022-11-30 20:02:39 +00:00
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
# default target, because it's the first one that doesn't start with '.'
|
2023-09-25 06:15:43 +00:00
|
|
|
all: | wakunode2 example2 chat2 chat2bridge libwaku
|
2021-06-23 17:14:37 +00:00
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
test: | testcommon testwaku
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
waku.nims:
|
|
|
|
ln -s waku.nimble $@
|
|
|
|
|
|
|
|
update: | update-common
|
|
|
|
rm -rf waku.nims && \
|
|
|
|
$(MAKE) waku.nims $(HANDLE_OUTPUT)
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean:
|
|
|
|
rm -rf build
|
2020-04-30 15:51:30 +00:00
|
|
|
|
|
|
|
# must be included after the default target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
|
|
|
|
2023-04-25 15:54:28 +00:00
|
|
|
## Possible values: prod; debug
|
|
|
|
TARGET ?= prod
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
## Git version
|
|
|
|
GIT_VERSION ?= $(shell git describe --abbrev=6 --always --tags)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:git_version=\"$(GIT_VERSION)\"
|
|
|
|
|
2023-04-25 15:54:28 +00:00
|
|
|
## Heaptracker options
|
|
|
|
HEAPTRACKER ?= 0
|
|
|
|
HEAPTRACKER_INJECT ?= 0
|
|
|
|
ifeq ($(HEAPTRACKER), 1)
|
|
|
|
# Needed to make nimbus-build-system use the Nim's 'heaptrack_support' branch
|
|
|
|
DOCKER_NIM_COMMIT := NIM_COMMIT=heaptrack_support
|
|
|
|
TARGET := debug
|
|
|
|
|
|
|
|
ifeq ($(HEAPTRACKER_INJECT), 1)
|
|
|
|
# the Nim compiler will load 'libheaptrack_inject.so'
|
|
|
|
HEAPTRACK_PARAMS := -d:heaptracker -d:heaptracker_inject
|
|
|
|
else
|
|
|
|
# the Nim compiler will load 'libheaptrack_preload.so'
|
|
|
|
HEAPTRACK_PARAMS := -d:heaptracker
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
## end of Heaptracker options
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
##################
|
|
|
|
## Dependencies ##
|
|
|
|
##################
|
|
|
|
.PHONY: deps libbacktrace
|
|
|
|
|
|
|
|
deps: | deps-common nat-libs waku.nims
|
|
|
|
|
|
|
|
|
|
|
|
### nim-libbacktrace
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
# "-d:release" implies "--stacktrace:off" and it cannot be added to config.nims
|
|
|
|
ifeq ($(USE_LIBBACKTRACE), 0)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:debug -d:disable_libbacktrace
|
|
|
|
else
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:release
|
|
|
|
endif
|
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
libbacktrace:
|
|
|
|
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
|
2022-10-18 23:03:43 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean-libbacktrace:
|
|
|
|
+ $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
|
2022-03-30 15:17:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# Extend deps and clean targets
|
2020-04-30 15:51:30 +00:00
|
|
|
ifneq ($(USE_LIBBACKTRACE), 0)
|
|
|
|
deps: | libbacktrace
|
|
|
|
endif
|
|
|
|
|
2023-09-13 10:45:55 +00:00
|
|
|
ifeq ($(POSTGRES), 1)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:postgres -d:nimDebugDlOpen
|
|
|
|
endif
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean: | clean-libbacktrace
|
2022-11-07 08:14:21 +00:00
|
|
|
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
##################
|
2023-09-11 06:32:31 +00:00
|
|
|
## RLN ##
|
2022-11-30 20:02:39 +00:00
|
|
|
##################
|
|
|
|
.PHONY: librln
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2023-09-01 11:20:55 +00:00
|
|
|
LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
|
2023-09-18 05:26:58 +00:00
|
|
|
LIBRLN_VERSION := v0.3.4
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2022-12-05 23:33:03 +00:00
|
|
|
LIBRLN_FILE := rln.lib
|
2022-11-30 20:02:39 +00:00
|
|
|
else
|
2023-09-18 05:26:58 +00:00
|
|
|
LIBRLN_FILE := librln_$(LIBRLN_VERSION).a
|
2022-11-30 20:02:39 +00:00
|
|
|
endif
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2023-08-29 18:52:22 +00:00
|
|
|
$(LIBRLN_FILE):
|
2022-11-30 20:02:39 +00:00
|
|
|
echo -e $(BUILD_MSG) "$@" && \
|
2023-09-18 05:26:58 +00:00
|
|
|
./scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE)
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2023-08-29 10:06:22 +00:00
|
|
|
|
2023-09-11 06:32:31 +00:00
|
|
|
librln: | $(LIBRLN_FILE)
|
|
|
|
$(eval NIM_PARAMS += --passL:$(LIBRLN_FILE) --passL:-lm)
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean-librln:
|
|
|
|
cargo clean --manifest-path vendor/zerokit/rln/Cargo.toml
|
2023-08-29 18:52:22 +00:00
|
|
|
rm -f $(LIBRLN_FILE)
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# Extend clean target
|
|
|
|
clean: | clean-librln
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2020-10-03 05:26:49 +00:00
|
|
|
|
2023-03-31 13:24:04 +00:00
|
|
|
#################
|
|
|
|
## Waku Common ##
|
|
|
|
#################
|
|
|
|
.PHONY: testcommon
|
|
|
|
|
|
|
|
testcommon: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim testcommon $(NIM_PARAMS) waku.nims
|
|
|
|
|
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
##########
|
|
|
|
## Waku ##
|
|
|
|
##########
|
|
|
|
.PHONY: testwaku wakunode2 testwakunode2 example2 chat2 chat2bridge
|
2020-08-26 12:20:04 +00:00
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
testwaku: | build deps librln
|
2020-12-21 11:32:02 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim test -d:os=$(shell uname) $(NIM_PARAMS) waku.nims
|
2020-12-21 11:32:02 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
wakunode2: | build deps librln
|
2020-04-30 15:51:30 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim wakunode2 $(NIM_PARAMS) waku.nims
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2023-04-25 13:34:57 +00:00
|
|
|
testwakunode2: | build deps librln
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim testwakunode2 $(NIM_PARAMS) waku.nims
|
2023-04-25 13:34:57 +00:00
|
|
|
|
2023-09-11 06:32:31 +00:00
|
|
|
example2: | build deps librln
|
2022-11-07 08:14:21 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim example2 $(NIM_PARAMS) waku.nims
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
chat2: | build deps librln
|
2022-11-07 08:14:21 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim chat2 $(NIM_PARAMS) waku.nims
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2023-09-11 06:32:31 +00:00
|
|
|
rln-keystore-generator: | build deps librln
|
2023-08-22 14:23:05 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim rln_keystore_generator $(NIM_PARAMS) waku.nims
|
2023-08-22 14:23:05 +00:00
|
|
|
|
2023-09-11 06:32:31 +00:00
|
|
|
rln-db-inspector: | build deps librln
|
2023-09-07 12:45:25 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim rln_db_inspector $(NIM_PARAMS) waku.nims
|
2023-09-07 12:45:25 +00:00
|
|
|
|
2023-09-11 06:32:31 +00:00
|
|
|
chat2bridge: | build deps librln
|
2022-11-07 08:14:21 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim chat2bridge $(NIM_PARAMS) waku.nims
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
################
|
|
|
|
## Waku tools ##
|
|
|
|
################
|
2023-04-12 08:22:45 +00:00
|
|
|
.PHONY: tools wakucanary networkmonitor
|
|
|
|
|
|
|
|
tools: networkmonitor wakucanary
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2023-09-11 06:32:31 +00:00
|
|
|
wakucanary: | build deps librln
|
2022-10-11 03:58:44 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim wakucanary $(NIM_PARAMS) waku.nims
|
|
|
|
|
2023-09-11 06:32:31 +00:00
|
|
|
networkmonitor: | build deps librln
|
2022-11-10 09:29:34 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim networkmonitor $(NIM_PARAMS) waku.nims
|
2021-02-04 19:30:00 +00:00
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
###################
|
|
|
|
## Documentation ##
|
|
|
|
###################
|
|
|
|
.PHONY: docs
|
2020-10-08 09:10:45 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# TODO: Remove unused target
|
|
|
|
docs: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2022-12-12 11:22:46 +00:00
|
|
|
$(ENV_SCRIPT) nim doc --run --index:on --project --out:.gh-pages waku/waku.nim waku.nims
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
#####################
|
|
|
|
## Container image ##
|
|
|
|
#####################
|
|
|
|
# -d:insecure - Necessary to enable Prometheus HTTP endpoint for metrics
|
|
|
|
# -d:chronicles_colors:none - Necessary to disable colors in logs for Docker
|
2023-09-13 10:45:55 +00:00
|
|
|
DOCKER_IMAGE_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure -d:postgres
|
2023-04-25 15:54:28 +00:00
|
|
|
DOCKER_IMAGE_NIMFLAGS := $(DOCKER_IMAGE_NIMFLAGS) $(HEAPTRACK_PARAMS)
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2020-05-26 12:04:40 +00:00
|
|
|
# build a docker image for the fleet
|
2022-11-30 20:02:39 +00:00
|
|
|
docker-image: MAKE_TARGET ?= wakunode2
|
2023-03-17 14:04:26 +00:00
|
|
|
docker-image: DOCKER_IMAGE_TAG ?= $(MAKE_TARGET)-$(GIT_VERSION)
|
2020-09-09 18:14:07 +00:00
|
|
|
docker-image: DOCKER_IMAGE_NAME ?= statusteam/nim-waku:$(DOCKER_IMAGE_TAG)
|
2020-05-26 12:04:40 +00:00
|
|
|
docker-image:
|
|
|
|
docker build \
|
2020-09-09 18:14:07 +00:00
|
|
|
--build-arg="MAKE_TARGET=$(MAKE_TARGET)" \
|
2022-05-17 19:11:07 +00:00
|
|
|
--build-arg="NIMFLAGS=$(DOCKER_IMAGE_NIMFLAGS)" \
|
2023-04-25 15:54:28 +00:00
|
|
|
--build-arg="NIM_COMMIT=$(DOCKER_NIM_COMMIT)" \
|
2023-05-23 08:44:57 +00:00
|
|
|
--build-arg="LOG_LEVEL=$(LOG_LEVEL)" \
|
2022-11-30 20:02:39 +00:00
|
|
|
--label="commit=$(GIT_VERSION)" \
|
2023-04-25 15:54:28 +00:00
|
|
|
--target $(TARGET) \
|
2020-05-26 12:04:40 +00:00
|
|
|
--tag $(DOCKER_IMAGE_NAME) .
|
|
|
|
|
|
|
|
docker-push:
|
|
|
|
docker push $(DOCKER_IMAGE_NAME)
|
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2023-05-12 16:08:41 +00:00
|
|
|
################
|
|
|
|
## C Bindings ##
|
|
|
|
################
|
2023-05-19 06:20:12 +00:00
|
|
|
.PHONY: cbindings cwaku_example libwaku
|
2023-05-12 16:08:41 +00:00
|
|
|
|
2023-05-19 06:20:12 +00:00
|
|
|
STATIC ?= false
|
2021-06-13 12:50:10 +00:00
|
|
|
|
2023-09-19 15:01:32 +00:00
|
|
|
libwaku: | build deps librln
|
2023-05-19 06:20:12 +00:00
|
|
|
rm -f build/libwaku*
|
|
|
|
ifeq ($(STATIC), true)
|
|
|
|
echo -e $(BUILD_MSG) "build/$@.a" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim libwakuStatic $(NIM_PARAMS) waku.nims
|
2023-05-19 06:20:12 +00:00
|
|
|
else
|
|
|
|
echo -e $(BUILD_MSG) "build/$@.so" && \
|
2023-09-11 06:32:31 +00:00
|
|
|
$(ENV_SCRIPT) nim libwakuDynamic $(NIM_PARAMS) waku.nims
|
2023-05-19 06:20:12 +00:00
|
|
|
endif
|
2022-11-30 20:02:39 +00:00
|
|
|
|
2023-05-19 06:20:12 +00:00
|
|
|
cwaku_example: | build libwaku
|
2023-05-12 16:08:41 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
cc -o "build/$@" \
|
|
|
|
./examples/cbindings/waku_example.c \
|
2023-07-07 08:53:00 +00:00
|
|
|
./examples/cbindings/base64.c \
|
2023-05-19 06:20:12 +00:00
|
|
|
-lwaku -Lbuild/ \
|
|
|
|
-pthread -ldl -lm \
|
2023-05-12 16:08:41 +00:00
|
|
|
-lminiupnpc -Lvendor/nim-nat-traversal/vendor/miniupnp/miniupnpc/build/ \
|
|
|
|
-lnatpmp -Lvendor/nim-nat-traversal/vendor/libnatpmp-upstream/ \
|
|
|
|
vendor/nim-libbacktrace/libbacktrace_wrapper.o \
|
|
|
|
vendor/nim-libbacktrace/install/usr/lib/libbacktrace.a
|
2022-11-30 20:02:39 +00:00
|
|
|
|
2023-08-02 08:45:15 +00:00
|
|
|
nodejswaku: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
node-gyp build --directory=examples/nodejs/
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
endif # "variables.mk" was not included
|
2023-05-18 12:45:45 +00:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Release Targets #
|
|
|
|
###################
|
|
|
|
|
|
|
|
release-notes:
|
|
|
|
docker run \
|
|
|
|
-it \
|
|
|
|
--rm \
|
|
|
|
-v $${PWD}:/opt/sv4git/repo:z \
|
|
|
|
-u $(shell id -u) \
|
|
|
|
docker.io/wakuorg/sv4git:latest \
|
|
|
|
release-notes |\
|
|
|
|
sed -E 's@#([0-9]+)@[#\1](https://github.com/waku-org/nwaku/issues/\1)@g'
|
|
|
|
# I could not get the tool to replace issue ids with links, so using sed for now,
|
|
|
|
# asked here: https://github.com/bvieira/sv4git/discussions/101
|