Skip to content

Commit

Permalink
more rectify build
Browse files Browse the repository at this point in the history
  • Loading branch information
djellemah committed May 4, 2024
1 parent 1c65e0a commit 2ae13d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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' }}
Expand Down
18 changes: 10 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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)
Expand Down

0 comments on commit 2ae13d5

Please sign in to comment.