Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Enhancement on building nph and made it available naturaly on the path #3152

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system
EXCLUDED_NIM_PACKAGES := vendor/nim-dnsdisc/vendor
LINK_PCRE := 0
LOG_LEVEL := TRACE
NPH := vendor/nph/src/nph
FORMAT_MSG := "\\x1B[95mFormatting:\\x1B[39m"
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
Expand All @@ -35,13 +34,13 @@ ifneq (,$(findstring MINGW,$(detected_OS)))
detected_OS := Windows
endif

ifeq ($(detected_OS),Windows)
ifeq ($(detected_OS),Windows)
# Define a new temporary directory for Windows
TMP_DIR := $(CURDIR)/tmp
$(shell mkdir -p $(TMP_DIR))
export TMP := $(TMP_DIR)
export TEMP := $(TMP_DIR)

# Add the necessary libraries to the linker flags
LIBS = -static -lws2_32 -lbcrypt -luserenv -lntdll -lminiupnpc
NIM_PARAMS += $(foreach lib,$(LIBS),--passL:"$(lib)")
Expand All @@ -63,6 +62,7 @@ waku.nims:
update: | update-common
rm -rf waku.nims && \
$(MAKE) waku.nims $(HANDLE_OUTPUT)
$(MAKE) build-nph

clean:
rm -rf build
Expand Down Expand Up @@ -287,8 +287,17 @@ networkmonitor: | build deps librln
############
.PHONY: build-nph install-nph clean-nph print-nph-path

build-nph:
$(ENV_SCRIPT) nim c vendor/nph/src/nph.nim
# Default location for nph binary shall be next to nim binary to make it available on the path.
NPH:=$(shell dirname $(NIM_BINARY))/nph

build-nph: | build deps
ifeq ("$(wildcard $(NPH))","")
$(ENV_SCRIPT) nim c vendor/nph/src/nph.nim && \
mv vendor/nph/src/nph $(shell dirname $(NPH))
echo "nph utility is available at " $(NPH)
else
echo "nph utility already exists at " $(NPH)
endif

GIT_PRE_COMMIT_HOOK := .git/hooks/pre-commit

Expand All @@ -300,7 +309,7 @@ else
exit 1
endif

nph/%: build-nph
nph/%: | build-nph
echo -e $(FORMAT_MSG) "nph/$*" && \
$(NPH) $*

Expand Down
Loading