diff --git a/Makefile b/Makefile index bd42273..f894e3f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: libsds +.PHONY: libsds deps export BUILD_SYSTEM_DIR := vendor/nimbus-build-system LINK_PCRE := 0 @@ -34,7 +34,7 @@ update: | update-common clean: rm -rf build -deps: | sds.nims +deps: | deps-common sds.nims # must be included after the default target -include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk @@ -52,11 +52,21 @@ endif STATIC ?= 0 -libsds: deps +detected_OS ?= Linux +ifeq ($(OS),Windows_NT) +detected_OS := Windows +else +detected_OS := $(shell uname -s) +endif + +libsds: | deps rm -f build/libsds* -ifeq ($(STATIC), 1) +ifeq ($(STATIC),1) echo -e $(BUILD_MSG) "build/$@.a" && \ $(ENV_SCRIPT) nim libsdsStatic $(NIM_PARAMS) sds.nims +else ifeq ($(detected_OS),Windows) + echo -e $(BUILD_MSG) "build/$@.dll" && \ + $(ENV_SCRIPT) nim libsdsDynamic $(NIM_PARAMS) sds.nims else echo -e $(BUILD_MSG) "build/$@.so" && \ $(ENV_SCRIPT) nim libsdsDynamic $(NIM_PARAMS) sds.nims diff --git a/scripts/build_windows.sh b/scripts/build_windows.sh new file mode 100644 index 0000000..24987ab --- /dev/null +++ b/scripts/build_windows.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +echo "- - - - - - - - - - Windows Setup Script - - - - - - - - - -" + +success_count=0 +failure_count=0 + +# Function to execute a command and check its status +execute_command() { + echo "Executing: $1" + if eval "$1"; then + echo -e "✓ Command succeeded \n" + ((success_count++)) + else + echo -e "✗ Command failed \n" + ((failure_count++)) + fi +} + +echo "1. -.-.-.-- Set PATH -.-.-.-" +export PATH="/c/msys64/usr/bin:/c/msys64/mingw64/bin:/c/msys64/usr/lib:/c/msys64/mingw64/lib:$PATH" + +echo "2. -.-.-.- Verify dependencies -.-.-.-" +execute_command "which gcc g++ make cmake cargo upx rustc python" + +echo "3. -.-.-.- Updating submodules -.-.-.-" +execute_command "git submodule update --init --recursive" + +echo "4. -.-.-.- Creating tmp directory -.-.-.-" +execute_command "mkdir -p tmp" + +echo "5. -.-.-.- Building Nim -.-.-.-" +cd vendor/nimbus-build-system/vendor/Nim +execute_command "./build_all.bat" +cd ../../../.. + +echo "6. -.-.-.- Building libsds -.-.-.- " +execute_command "make libsds STATIC=0 V=3 -j8" + +echo "Windows setup completed successfully!" +echo "✓ Successful commands: $success_count" +echo "✗ Failed commands: $failure_count" diff --git a/sds.nimble b/sds.nimble index ca300bf..305e96e 100644 --- a/sds.nimble +++ b/sds.nimble @@ -23,9 +23,15 @@ proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") = ".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:on " & extra_params & " " & srcDir & name & ".nim" else: - exec "nim c" & " --out:build/" & name & - ".so --threads:on --app:lib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:on " & - extra_params & " " & srcDir & name & ".nim" + let lib_name = (when defined(windows): toDll(name) else: name & ".so") + when defined(windows): + exec "nim c" & " --out:build/" & lib_name & + " --threads:on --app:lib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:off " & + extra_params & " " & srcDir & name & ".nim" + else: + exec "nim c" & " --out:build/" & lib_name & + " --threads:on --app:lib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:on " & + extra_params & " " & srcDir & name & ".nim" # Tasks task test, "Run the test suite": @@ -36,13 +42,7 @@ task libsdsDynamic, "Generate bindings": let name = "libsds" buildLibrary name, "library/", - """-d:chronicles_line_numbers \ - -d:chronicles_runtime_filtering=on \ - -d:chronicles_sinks="textlines,json" \ - -d:chronicles_default_output_device=Dynamic \ - --warning:Deprecated:off \ - --warning:UnusedImport:on \ - -d:chronicles_log_level=TRACE """, + """-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """, "dynamic" ### Mobile Android