Skip to content

Commit

Permalink
Added rust tests to windows CI
Browse files Browse the repository at this point in the history
Also made the number of threads passed to make in build.rs configurable
  • Loading branch information
benjaminwinger committed Jun 22, 2023
1 parent 9f35dd2 commit 87b39fc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ jobs:
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
make test NUM_THREADS=18
- name: Rust test
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
make rusttest NUM_THREADS=18
clang-formatting-check:
name: clang-format check
runs-on: kuzu-self-hosted-testing
Expand Down
31 changes: 24 additions & 7 deletions tools/rust_api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,44 @@ fn link_mode() -> &'static str {
}
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
fn main() {
// There is a kuzu-src symlink pointing to the root of the repo since Cargo
// only looks at the files within the rust project when packaging crates.
// Using a symlink the library can both be built in-source and from a crate.
let kuzu_root = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("kuzu-src");
let kuzu_root = {
let root = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("kuzu-src");
if root.is_dir() {
root
} else {
// If the path is not directory, this is probably an in-source build on windows where the
// symlink is unreadable.
Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("../..")
}
};
// Windows fails to link on windows unless CFLAGS and CXXFLAGS are overridden
// If they are, assume the user knows what they are doing. Otherwise just link against the
// release version of kuzu even in debug mode.
let target = if cfg!(windows) && std::env::var("CXXFLAGS").is_err() {
"release".to_string()
} else {
env::var("PROFILE")?
env::var("PROFILE").unwrap()
};
let kuzu_cmake_root = kuzu_root.join(format!("build/{target}"));
let mut command = std::process::Command::new("make");
let threads = env::var("NUM_THREADS")
.map(|x| x.parse::<usize>())
.unwrap_or_else(|_| Ok(num_cpus::get()))
.unwrap();
command
.args(&[&target, &format!("NUM_THREADS={}", num_cpus::get())])
.args(&[&target, &format!("NUM_THREADS={}", threads)])
.current_dir(&kuzu_root);
let make_status = command.status()?;
let make_status = command.status().unwrap_or_else(|_| {
panic!(
"Running make {} on {}/Makefile failed!",
&target,
&kuzu_root.display()
)
});
assert!(make_status.success());

let kuzu_lib_path = kuzu_cmake_root.join("src");
Expand Down Expand Up @@ -118,6 +137,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
build.flag_if_supported("-std=c++20");
}
build.compile("kuzu_rs");

Ok(())
}

0 comments on commit 87b39fc

Please sign in to comment.