From 553c728970fb97db1c4ee2820ce49d0edc2b6501 Mon Sep 17 00:00:00 2001 From: DarshanBPatel Date: Thu, 17 Oct 2024 14:29:30 +0530 Subject: [PATCH] chore: give cross plateform support --- Makefile | 14 +++++++++++++- config.nims | 4 +++- scripts/build_rln.sh | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 33a5ac019b..e6d95cf346 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,19 @@ 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 -ifeq ($(OS),Windows_NT) +# Determine the OS +detected_OS := $(shell uname -s) +ifeq ($(detected_OS),Darwin) + detected_OS := Darwin +else ifeq ($(detected_OS),Linux) + detected_OS := Linux +else ifneq (,$(findstring MINGW,$(detected_OS))) + detected_OS := Windows +else + detected_OS := Unknown +endif + +ifeq ($(detected_OS),Windows) # Add the necessary libraries to the linker flags LIBS = -static -lws2_32 -lbcrypt -luserenv -lntdll NIM_PARAMS += $(foreach lib,$(LIBS),--passL:"$(lib)") diff --git a/config.nims b/config.nims index fd9a62888f..37a8d9a0d0 100644 --- a/config.nims +++ b/config.nims @@ -15,7 +15,9 @@ if defined(windows): for dir in walkDir("./vendor"): if dir.kind == pcDir: switch("path", dir.path) - # disable timestamps in Windows PE headers - https://wiki.debian.org/ReproducibleBuilds/TimestampsInPEBinaries + switch("path", dir.path / "src") + +# disable timestamps in Windows PE headers - https://wiki.debian.org/ReproducibleBuilds/TimestampsInPEBinaries switch("passL", "-Wl,--no-insert-timestamp") # increase stack size switch("passL", "-Wl,--stack,8388608") diff --git a/scripts/build_rln.sh b/scripts/build_rln.sh index b5e4da0b63..992c1f4347 100755 --- a/scripts/build_rln.sh +++ b/scripts/build_rln.sh @@ -43,7 +43,7 @@ else # first, check if submodule version = version in Makefile cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" - if [ "$os" = "windows" ]; then + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then submodule_version=$(cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" | sed -n 's/.*"name":"rln","version":"\([^"]*\)".*/\1/p') else submodule_version=$(cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml" | jq -r '.packages[] | select(.name == "rln") | .version')