You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am building rust bindings to a c library which is built using the cmake crate. cargo build runs successfully, however on running cargo package, the following error is shown:
error: failed to verify package tarball
Caused by:
Source directory was modified by build.rs during cargo publish. Build scripts should not modify anything outside of OUT_DIR.
Added: /home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.all-contributorsrc
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.appveyor.yml
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.ci
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.ci/azure-build.yml
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.ci/azure-cmake.yml
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.ci/azure-test.yml
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.ci/build_doxygen.sh
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.ci/build_lcov.sh
/home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0/hailort/hailort/external/cli11-src/.ci/make_and_test.sh
...
My understanding is that <crate>/target and is not the source directory.
My build.rs file looks like this:
use cmake;use std::env;use std::path::PathBuf;fnmain(){let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());let dst = cmake::Config::new("hailort").build();let obj_path = dst.join("build/hailort/libhailort/src/libhailort.so");let lib_path = out_dir.clone().join("libhailort.a");let headers_path = dst.join("include/hailo/hailort.h");let headers_path_str = headers_path
.to_str().expect("Header path is not a valid string");// Link to the hailort libraryprintln!("cargo:rustc-link-search=native={}", dst.display());println!("cargo:rustc-link-lib=static=hailort");// Generate .a filelet ar_output = std::process::Command::new("ar").arg("rcs").arg(lib_path).arg(obj_path).output().expect("could not spawn ar");if !ar_output.status.success(){panic!("Failed to generate libhailort.a: {:?}", ar_output);}let bindings = bindgen::Builder::default().header(headers_path_str).parse_callbacks(Box::new(bindgen::CargoCallbacks::new())).generate().expect("Unable to generate bindings");
bindings
.write_to_file(out_dir.join("bindings.rs")).expect("Couldn't write bindings!");}
The generated .crate was extracted to /home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0. A build is then performed inside of that with changes found to hailort/hailort/external/** which is part of the "source".
As far as I can tell, the error is reporting correctly.
Based on the output, it isn't directly hailort that is causing problems but an external dependency on cli11
I'm not too sure what is causing it, whether its cmake pulling in cli11 directly into that location (which should then have more files) or if cli11 is generating those (which I'm not seeing inside of their repo.
The generated .crate was extracted to /home/ejex/code/libhailort-sys/target/package/libhailort-sys-0.1.0. A build is then performed inside of that with changes found to hailort/hailort/external/** which is part of the "source".
As far as I can tell, the error is reporting correctly.
Based on the output, it isn't directly hailort that is causing problems but an external dependency on cli11
I'm not too sure what is causing it, whether its cmake pulling in cli11 directly into that location (which should then have more files) or if cli11 is generating those (which I'm not seeing inside of their repo.
That would make sense, I didn't realise that it copies the source to /target/package, the files are probably being modified by cmake as part of the build. Would this be a bug with the cmake crate then?
Problem
I am building rust bindings to a c library which is built using the
cmake
crate.cargo build
runs successfully, however on runningcargo package
, the following error is shown:My understanding is that
<crate>/target
and is not the source directory.My
build.rs
file looks like this:Steps
git clone https://github.com/Jex-y/libhailort-sys.git
cd libhailort-sys
cargo package
Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: