mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Use env::var_os instead of env::var
For the unliekly case in which the git repository is checked out in a directory that cannot be represented with unicode
This commit is contained in:
parent
31da762245
commit
0553ab8b1a
4 changed files with 12 additions and 12 deletions
|
@ -131,7 +131,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
let (syntax_node, mut diag) = parser::parse_tokens(tokens.clone());
|
let (syntax_node, mut diag) = parser::parse_tokens(tokens.clone());
|
||||||
|
|
||||||
if let Ok(cargo_manifest) = std::env::var("CARGO_MANIFEST_DIR") {
|
if let Some(cargo_manifest) = std::env::var_os("CARGO_MANIFEST_DIR") {
|
||||||
diag.current_path = cargo_manifest.into();
|
diag.current_path = cargo_manifest.into();
|
||||||
diag.current_path.push("Cargo.toml");
|
diag.current_path.push("Cargo.toml");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn main() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut include_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let mut include_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
include_dir.pop();
|
include_dir.pop();
|
||||||
include_dir.pop();
|
include_dir.pop();
|
||||||
include_dir.pop(); // target/{debug|release}/build/package/out/ -> target/{debug|release}
|
include_dir.pop(); // target/{debug|release}/build/package/out/ -> target/{debug|release}
|
||||||
|
@ -33,10 +33,10 @@ fn main() {
|
||||||
|
|
||||||
std::fs::create_dir_all(include_dir.clone()).unwrap();
|
std::fs::create_dir_all(include_dir.clone()).unwrap();
|
||||||
|
|
||||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
let crate_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
|
||||||
cbindgen::Builder::new()
|
cbindgen::Builder::new()
|
||||||
.with_config(config.clone())
|
.with_config(config.clone())
|
||||||
.with_src(format!("{}/abi/string.rs", crate_dir))
|
.with_src(crate_dir.join("abi/string.rs"))
|
||||||
.with_after_include("namespace sixtyfps { struct SharedString; }")
|
.with_after_include("namespace sixtyfps { struct SharedString; }")
|
||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings")
|
.expect("Unable to generate bindings")
|
||||||
|
@ -44,23 +44,23 @@ fn main() {
|
||||||
|
|
||||||
cbindgen::Builder::new()
|
cbindgen::Builder::new()
|
||||||
.with_config(config.clone())
|
.with_config(config.clone())
|
||||||
.with_src(format!("{}/abi/properties.rs", crate_dir))
|
.with_src(crate_dir.join("abi/properties.rs"))
|
||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings")
|
.expect("Unable to generate bindings")
|
||||||
.write_to_file(include_dir.join("sixtyfps_properties_internal.h"));
|
.write_to_file(include_dir.join("sixtyfps_properties_internal.h"));
|
||||||
|
|
||||||
cbindgen::Builder::new()
|
cbindgen::Builder::new()
|
||||||
.with_config(config.clone())
|
.with_config(config.clone())
|
||||||
.with_src(format!("{}/abi/signals.rs", crate_dir))
|
.with_src(crate_dir.join("abi/signals.rs"))
|
||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings")
|
.expect("Unable to generate bindings")
|
||||||
.write_to_file(include_dir.join("sixtyfps_signals_internal.h"));
|
.write_to_file(include_dir.join("sixtyfps_signals_internal.h"));
|
||||||
|
|
||||||
cbindgen::Builder::new()
|
cbindgen::Builder::new()
|
||||||
.with_config(config)
|
.with_config(config)
|
||||||
.with_src(format!("{}/abi/datastructures.rs", crate_dir))
|
.with_src(crate_dir.join("abi/datastructures.rs"))
|
||||||
.with_src(format!("{}/abi/primitives.rs", crate_dir))
|
.with_src(crate_dir.join("abi/primitives.rs"))
|
||||||
.with_src(format!("{}/abi/model.rs", crate_dir))
|
.with_src(crate_dir.join("abi/model.rs"))
|
||||||
.with_include("vtable.h")
|
.with_include("vtable.h")
|
||||||
.with_include("sixtyfps_string.h")
|
.with_include("sixtyfps_string.h")
|
||||||
.with_include("sixtyfps_properties.h")
|
.with_include("sixtyfps_properties.h")
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn main() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut include_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let mut include_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
include_dir.pop();
|
include_dir.pop();
|
||||||
include_dir.pop();
|
include_dir.pop();
|
||||||
include_dir.pop(); // target/{debug|release}/build/package/out/ -> target/{debug|release}
|
include_dir.pop(); // target/{debug|release}/build/package/out/ -> target/{debug|release}
|
||||||
|
@ -26,7 +26,7 @@ fn main() {
|
||||||
|
|
||||||
std::fs::create_dir_all(include_dir.clone()).unwrap();
|
std::fs::create_dir_all(include_dir.clone()).unwrap();
|
||||||
|
|
||||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
let crate_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
|
||||||
cbindgen::Builder::new()
|
cbindgen::Builder::new()
|
||||||
.with_config(config)
|
.with_config(config)
|
||||||
.with_crate(crate_dir)
|
.with_crate(crate_dir)
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub struct ApplicationArguments {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root_dir() -> Result<PathBuf, Box<dyn Error>> {
|
fn root_dir() -> Result<PathBuf, Box<dyn Error>> {
|
||||||
let mut root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").map_err(|_| "Cannot determine root directory - CARGO_MANIFEST_DIR is not set -- you can only run xtask via cargo")?);
|
let mut root = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").ok_or_else(|| "Cannot determine root directory - CARGO_MANIFEST_DIR is not set -- you can only run xtask via cargo")?);
|
||||||
root.pop(); // $root/xtask -> $root
|
root.pop(); // $root/xtask -> $root
|
||||||
Ok(root)
|
Ok(root)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue