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

feat: remain windows support #3162

Merged
merged 32 commits into from
Mar 5, 2025
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
95681f4
feat: everuthing in one comments
darshankabariya Jan 20, 2025
dc83b2b
chore: remove command use
darshankabariya Jan 28, 2025
b0dd16d
chore: remove command use
darshankabariya Jan 28, 2025
c9f15da
chore: remove command use
darshankabariya Jan 28, 2025
9249c73
chore: remove command use
darshankabariya Jan 28, 2025
e05bd02
chore: msys2 to mingw migration
darshankabariya Feb 16, 2025
b606ca2
chore: on chronological order
darshankabariya Feb 16, 2025
7ddc590
chore: windows and unix command seperation
darshankabariya Feb 17, 2025
2798b33
chore: update build_rln
darshankabariya Feb 17, 2025
549a8d1
chore: update scripts with proper requirements
darshankabariya Feb 18, 2025
7a6403c
chore: update scripts with proper requirements
darshankabariya Feb 18, 2025
a46905e
chore: update scripts with proper requirements
darshankabariya Feb 19, 2025
23d112f
chore: remove unnecessory things
darshankabariya Feb 19, 2025
9941a45
chore: mask addReader and setReader
darshankabariya Feb 23, 2025
ab098dc
chore: improce guide
darshankabariya Feb 23, 2025
aab9af7
chore: improvise guide
darshankabariya Feb 24, 2025
b74b27f
chore: resolve static linking issue in end
darshankabariya Feb 24, 2025
0b700f7
chore: ignore failure
darshankabariya Feb 24, 2025
81b4d5a
chore: update scripts
darshankabariya Feb 24, 2025
2e64a4a
chore: will not stop execution
darshankabariya Feb 24, 2025
0983753
chore: space formating
darshankabariya Feb 24, 2025
6e86399
chore: counting
darshankabariya Feb 25, 2025
61a3e61
chore: set path expilictly
darshankabariya Feb 25, 2025
f9012da
chore: some chore
darshankabariya Feb 25, 2025
82dfefb
chore: update requirements
darshankabariya Feb 26, 2025
c74641a
chore: update requirements
darshankabariya Feb 26, 2025
949fab2
chore: update PATH
darshankabariya Feb 27, 2025
018ee68
chore: handle double quotes
darshankabariya Feb 27, 2025
32f2fed
feat: make more cleane and add instruction to readme.md
darshankabariya Mar 5, 2025
535bf2e
feat: delete instruction from scripts
darshankabariya Mar 5, 2025
130d5ff
feat: improve according to suggestion
darshankabariya Mar 5, 2025
3ede9f9
chore: some correction
darshankabariya Mar 5, 2025
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
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -34,14 +34,14 @@ ifneq (,$(findstring MINGW,$(detected_OS)))
endif

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
# Update MINGW_PATH to standard MinGW location
MINGW_PATH = /mingw64
NIM_PARAMS += --passC:"-I$(MINGW_PATH)/include"
NIM_PARAMS += --passL:"-L$(MINGW_PATH)/lib"
NIM_PARAMS += --passL:"-Lvendor/nim-nat-traversal/vendor/miniupnp/miniupnpc"
NIM_PARAMS += --passL:"-Lvendor/nim-nat-traversal/vendor/libnatpmp-upstream"

LIBS = -static -lws2_32 -lbcrypt -liphlpapi -luserenv -lntdll -lminiupnpc -lnatpmp -lpq
NIM_PARAMS += $(foreach lib,$(LIBS),--passL:"$(lib)")
endif

40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -52,14 +52,42 @@ If you encounter difficulties building the project on WSL, consider placing the

### How to Build & Run ( Windows )

Note: This is a work in progress. The current setup procedure is as follows:
Goal: Get rid of windows specific procedures and make the build process the same as linux/macos.
### Windows Build Instructions

The current setup procedure is as follows:
#### 1. Install Required Tools
- **Git Bash Terminal**: Download and install from https://git-scm.com/download/win
- **MSYS2**:
a. Download installer from https://www.msys2.org
b. Install at "C:\" (default location). Remove/rename the msys folder in case of previous installation.
c. Use the mingw64 terminal from msys64 directory for package installation.

1. Clone the repository and checkout master branch
2. Ensure prerequisites are installed (Make, GCC, MSYS2/MinGW)
3. Run scripts/windows_setup.sh
#### 2. Install Dependencies
Open MSYS2 mingw64 terminal and run the following one-by-one :
```bash
pacman -Syu --noconfirm
pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain
pacman -S --noconfirm --needed base-devel make cmake upx
pacman -S --noconfirm --needed mingw-w64-x86_64-rust
pacman -S --noconfirm --needed mingw-w64-x86_64-postgresql
pacman -S --noconfirm --needed mingw-w64-x86_64-gcc
pacman -S --noconfirm --needed mingw-w64-x86_64-gcc-libs
pacman -S --noconfirm --needed mingw-w64-x86_64-libwinpthread-git
pacman -S --noconfirm --needed mingw-w64-x86_64-zlib
pacman -S --noconfirm --needed mingw-w64-x86_64-openssl
pacman -S --noconfirm --needed mingw-w64-x86_64-python
```

#### 3. Build Wakunode
- Open Git Bash as administrator
- clone nwaku and cd nwaku
- Execute: `./scripts/build_wakunode_windows.sh`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Execute: `./scripts/build_wakunode_windows.sh`
- cd to the `nwaku` folder
- Execute: `./scripts/build_wakunode_windows.sh`


#### 4. Troubleshooting
If `wakunode2.exe` isn't generated:
- **Missing Dependencies**: Verify with:
`which make cmake gcc g++ rustc cargo python3 upx`
If missing, revisit Step 2 or ensure MSYS2 is at `C:\`
- **Installation Conflicts**: Remove existing MinGW/MSYS2/Git Bash installations and perform fresh install

### Developing

1 change: 1 addition & 0 deletions config.nims
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ else:

if defined(windows):
switch("passL", "rln.lib")
switch("define", "postgres=false")

# Automatically add all vendor subdirectories
for dir in walkDir("./vendor"):
5 changes: 3 additions & 2 deletions scripts/build_rln.sh
Original file line number Diff line number Diff line change
@@ -43,12 +43,13 @@ else
# first, check if submodule version = version in Makefile
cargo metadata --format-version=1 --no-deps --manifest-path "${build_dir}/rln/Cargo.toml"

if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
detected_OS=$(uname -s)
if [[ "$detected_OS" == MINGW* || "$detected_OS" == MSYS* ]]; 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')
fi

if [[ "v${submodule_version}" != "${rln_version}" ]]; then
echo "Submodule version (v${submodule_version}) does not match version in Makefile (${rln_version})"
echo "Please update the submodule to ${rln_version}"
60 changes: 60 additions & 0 deletions scripts/build_wakunode_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/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 libunwind -.-.-.-"
cd vendor/nim-libbacktrace
execute_command "make all V=1"
execute_command "make install/usr/lib/libunwind.a V=1"
cp ./vendor/libunwind/build/lib/libunwind.a install/usr/lib
cd ../../

echo "7. -.-.-.- Building miniupnpc -.-.-.- "
cd vendor/nim-nat-traversal/vendor/miniupnp/miniupnpc
execute_command "git checkout little_chore_windows_support"
execute_command "make -f Makefile.mingw CC=gcc CXX=g++ libminiupnpc.a V=1"
cd ../../../../..

echo "8. -.-.-.- Building libnatpmp -.-.-.- "
cd ./vendor/nim-nat-traversal/vendor/libnatpmp-upstream
make CC="gcc -fPIC -D_WIN32_WINNT=0x0600 -DNATPMP_STATICLIB" libnatpmp.a V=1
cd ../../../../

echo "9. -.-.-.- Building wakunode2 -.-.-.- "
execute_command "make wakunode2 LOG_LEVEL=DEBUG V=1 -j8"

echo "Windows setup completed successfully!"
echo "✓ Successful commands: $success_count"
echo "✗ Failed commands: $failure_count"
68 changes: 0 additions & 68 deletions scripts/windows_setup.sh

This file was deleted.

15 changes: 9 additions & 6 deletions waku/common/databases/db_postgres/dbconn.nim
Original file line number Diff line number Diff line change
@@ -182,12 +182,15 @@ proc waitQueryToFinish(

let asyncFd = cast[asyncengine.AsyncFD](pqsocket(dbConnWrapper.dbConn))

asyncengine.addReader2(asyncFd, onDataAvailable).isOkOr:
dbConnWrapper.futBecomeFree.fail(newException(ValueError, $error))
return err("failed to add event reader in waitQueryToFinish: " & $error)
defer:
asyncengine.removeReader2(asyncFd).isOkOr:
return err("failed to remove event reader in waitQueryToFinish: " & $error)
when not defined(windows):
asyncengine.addReader2(asyncFd, onDataAvailable).isOkOr:
dbConnWrapper.futBecomeFree.fail(newException(ValueError, $error))
return err("failed to add event reader in waitQueryToFinish: " & $error)
defer:
asyncengine.removeReader2(asyncFd).isOkOr:
return err("failed to remove event reader in waitQueryToFinish: " & $error)
else:
return err("Postgres not supported on Windows")

await futDataAvailable