From 2ae13d51a1a543167406fa3217b94f3b7dcdc801 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sat, 4 May 2024 10:04:08 -0400 Subject: [PATCH] more rectify build --- .github/workflows/build.yaml | 9 ++------- build.rs | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ef3f18f..9f469bb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,17 +38,14 @@ jobs: fail-fast: false matrix: include: - - target: x86_64-pc-windows-gnu + - target: x86_64-pc-windows-msvc runs-on: windows-latest - simd-def: RAPIDJSON_SSE42 # - target: x86_64-unknown-linux-musl # runs-on: ubuntu-latest - target: x86_64-unknown-linux-gnu runs-on: ubuntu-latest - simd-def: RAPIDJSON_SSE42 - - target: arm64e-apple-darwin + - target: aarch64-apple-darwin runs-on: macos-latest - simd-def: RAPIDJSON_NEON runs-on: ${{ matrix.runs-on }} steps: @@ -59,8 +56,6 @@ jobs: - run: rustup default nightly - name: compile run: cargo build --release - env: - ${{ matrix.simd-def }}: true - name: upload bin to release if: ${{ runner.os != 'Windows' }} diff --git a/build.rs b/build.rs index 68755c1..e5b8b85 100644 --- a/build.rs +++ b/build.rs @@ -13,6 +13,7 @@ fn main() { std::process::exit(1) } + // switch on simd for rapidjson if possible let wrapper_defs_dir = &env::var_os("OUT_DIR").unwrap(); let wrapper_defs_dir = Path::new(&wrapper_defs_dir); let dest_path = wrapper_defs_dir.join("wrapper_defs.h"); @@ -22,16 +23,17 @@ fn main() { let define_value = match target_env { // srsly. There must be a better way. Ok(s) if s == "x86_64-unknown-linux-gnu" => "#define RAPIDJSON_SSE42".into(), - Ok(s) if s == "x86_64-pc-windows-gnu" => "#define RAPIDJSON_SSE42".into(), - Ok(s) if s == "arm64e-apple-darwin"=> "#define RAPIDJSON_NEON".into(), - wut => format!("// whaddya mean {:?}", wut), + Ok(s) if s == "x86_64-pc-windows-msvc" => "#define RAPIDJSON_SSE42".into(), + Ok(s) if s == "aarch64-apple-darwin" => "#define RAPIDJSON_NEON".into(), + wut => { + let msg = format!("rapidjson SIMD not turned on because we don't know how to do that for target triple {:?}", wut); + println!("cargo::warning={msg}"); + format!("// whaddya mean {:?}", wut) + }, }; - if option_env!("RAPIDJSON_SSE42").is_some() { - std::fs::write(&dest_path, define_value).unwrap(); - } else { - std::fs::write(&dest_path, "").unwrap(); - } + std::fs::write(&dest_path, define_value).unwrap(); + // Now tell cxx.rs what to do cxx_build::bridge("src/rapid.rs") .include(rapidjson_include) .include(wrapper_defs_dir)