From 022fbd5c435969254f4b3616431cf0dc51efe7e0 Mon Sep 17 00:00:00 2001 From: Lukas Fittl Date: Mon, 1 Jan 2024 12:05:53 -0800 Subject: [PATCH] Add support for running on Windows --- .github/workflows/main.yml | 8 ++++++-- build.rs | 13 ++++++++++--- libpg_query | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 37595ea..39f2156 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,20 +5,24 @@ on: branches: - main - "[0-9].x" + - windows-support name: Continuous integration jobs: ci: env: - RUSTFLAGS: ${{ matrix.rust == 'nightly' && '-Z sanitizer=leak' || '' }} - runs-on: ubuntu-latest + RUSTFLAGS: ${{ matrix.rust == 'nightly' && matrix.os == 'ubuntu-latest' && '-Z sanitizer=leak' || '' }} strategy: fail-fast: false matrix: rust: - stable - nightly + os: + - ubuntu-latest + - windows-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/build.rs b/build.rs index 65765d0..0acba90 100644 --- a/build.rs +++ b/build.rs @@ -15,6 +15,7 @@ fn main() -> Result<(), Box> { let makefile_path = build_path.join("Makefile"); let out_header_path = out_dir.join(LIBRARY_NAME).with_extension("h"); let out_protobuf_path = out_dir.join("protobuf"); + let target = env::var("TARGET").unwrap(); // Configure cargo through stdout println!("cargo:rerun-if-changed={}", makefile_path.display()); // Includes version number @@ -37,10 +38,16 @@ fn main() -> Result<(), Box> { // Compile the C library. let mut make = Command::new("make"); - make.env_remove("PROFILE").arg("-C").arg(&out_dir).arg("build"); + if target.contains("msvc") { + make = Command::new("nmake"); + make.arg("/F Makefile.msvc"); + make.current_dir(&out_dir); + } else { + make.env_remove("PROFILE").arg("-C").arg(&out_dir).arg("build"); - if env::var("PROFILE").unwrap() == "debug" { - make.arg("DEBUG=1"); + if env::var("PROFILE").unwrap() == "debug" { + make.arg("DEBUG=1"); + } } let status = make.stdin(Stdio::null()).stdout(Stdio::inherit()).stderr(Stdio::inherit()).status()?; diff --git a/libpg_query b/libpg_query index 2a00188..31ee266 160000 --- a/libpg_query +++ b/libpg_query @@ -1 +1 @@ -Subproject commit 2a0018867c20011fc7166767083c05965241140b +Subproject commit 31ee2669a23663bd72158123db2b1b3691fceb97