fix(rust): fetch CARGO_MANIFEST_DIR at runtime in build script

The `CARGO_MANIFEST_DIR` environment variable should be accessed by
`build.rs` at run time rather than compile time. This was for example
causing issues when importing `tree-sitter` via
[`rules_rust`](https://github.com/bazelbuild/rules_rust) in bazel,
where compilation and running happen in separate environments.
This commit is contained in:
Paolo Tranquilli 2024-05-13 16:09:58 +02:00 committed by GitHub
parent 8e8648afa9
commit d35e40185a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,4 @@
use std::{
env, fs,
path::{Path, PathBuf},
};
use std::{env, fs, path::PathBuf};
fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
@ -26,7 +23,7 @@ fn main() {
.include(env::var("DEP_WASMTIME_C_API_WASM_INCLUDE").unwrap());
}
let manifest_path = Path::new(env!("CARGO_MANIFEST_DIR"));
let manifest_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let include_path = manifest_path.join("include");
let src_path = manifest_path.join("src");
let wasm_path = src_path.join("wasm");