Skip to content

Commit

Permalink
fix windows build
Browse files Browse the repository at this point in the history
We shouldn't be passing gcc params to MSVC

Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Apr 12, 2024
1 parent 434d302 commit 1be97dd
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 64 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Linux

on:
push:
branches:
- master
- ci
pull_request:
branches:
- master

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Initialize Submodules
run: git submodule update --init --recursive
- name: Build
run: cargo build --verbose
- name: Tests
run: cargo test --verbose
- name: Clippy
run: cargo clippy ${{ matrix.build-args }} -- -D warnings

55 changes: 0 additions & 55 deletions .github/workflows/rust.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Windows
on:
push:
branches:
- master
- ci
pull_request:

jobs:
test:
runs-on: windows-latest
name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
strategy:
fail-fast: false
matrix:
target: [
i686-pc-windows-gnu,
i686-pc-windows-msvc,
x86_64-pc-windows-gnu,
x86_64-pc-windows-msvc,
]
cfg_release_channel: [nightly, stable]

steps:
- name: checkout
uses: actions/checkout@v3

- name: Initialize Submodules
run: git submodule update --init --recursive

# Run build
- name: Install Rustup using win.rustup.rs
run: |
# Disable the download progress bar which can cause perf issues
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none
del rustup-init.exe
rustup target add ${{ matrix.target }}
shell: powershell

- name: Add mingw32 to path for i686-gnu
run: |
echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
if: matrix.target == 'i686-pc-windows-gnu' && matrix.channel == 'nightly'
shell: bash

- name: Add mingw64 to path for x86_64-gnu
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
shell: bash

- name: Build and Test
shell: cmd
run: ci\build_and_test.bat
27 changes: 18 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,24 @@ fn main() {
])
.include("nostrdb/deps/lmdb")
.include("nostrdb/deps/flatcc/include")
.include("nostrdb/deps/secp256k1/include")
// Add other include paths
//.flag("-Wall")
.flag("-Wno-sign-compare")
.flag("-Wno-misleading-indentation")
.flag("-Wno-unused-function")
.flag("-Wno-unused-parameter");
//.flag("-Werror")
//.flag("-g")
.include("nostrdb/deps/secp256k1/include");

// Detect the compiler being used: MSVC or GCC (like MinGW on Windows)
if env::var("TARGET").unwrap().contains("msvc") {
// MSVC-specific flags
// Example: build.flag("/W4"); // Set warning level to 4 for MSVC
// Suppress specific warnings in MSVC:
build.flag("/wd4100"); // unreferenced formal parameter
// Add more MSVC-specific flags as needed
} else {
// GCC-specific flags
build
.flag("-Wno-sign-compare")
.flag("-Wno-misleading-indentation")
.flag("-Wno-unused-function")
.flag("-Wno-unused-parameter");
// Add more GCC-specific flags as needed
}

if env::var("PROFILE").unwrap() == "debug" {
build.flag("-DDEBUG");
Expand Down
8 changes: 8 additions & 0 deletions ci/build_and_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set "RUSTFLAGS=-D warnings"

:: Print version information
rustc -Vv || exit /b 1
cargo -V || exit /b 1

cargo build || exit /b 1
cargo test || exit /b 1

0 comments on commit 1be97dd

Please sign in to comment.