Skip to content

Commit

Permalink
build: update cgosling's build.rs to check for generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Pospesel committed Jan 28, 2024
1 parent d770e74 commit 28dc34a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 0 additions & 3 deletions source/gosling/crates/cgosling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ endif()
add_custom_command(
DEPENDS ${cgosling_sources}
OUTPUT ${cgosling_outputs}
# cargo test of this same project will also run build.rs, so we need to touch build.rs
# to force cargo to re-run it and generate cbindgen headers (cmake seems to delete the first output file)
COMMAND touch ${CMAKE_CURRENT_SOURCE_DIR}/build.rs
COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo build ${CARGO_FLAGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
Expand Down
2 changes: 2 additions & 0 deletions source/gosling/crates/cgosling/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ fn main() {
};

let header_file_path = target_dir.join("include").join("cgosling.h");
println!("cargo:rerun-if-changed={}",header_file_path.display());

// generate libgosling.h C header
match cbindgen::generate(&crate_dir) {
Expand All @@ -196,6 +197,7 @@ fn main() {

// convert generated header to json IDL
let json_file_path = target_dir.join("cgosling.json");
println!("cargo:rerun-if-changed={}",json_file_path.display());
let json_file = match File::create(json_file_path) {
Ok(file) => file,
Err(err) => panic!("{:?}", err),
Expand Down

0 comments on commit 28dc34a

Please sign in to comment.