mirror of
https://github.com/slint-ui/slint.git
synced 2025-07-07 13:15:23 +00:00

`__CARGO_FIX_YOLO=1` is a hack, but it does help a lot with the tedious fixes where the result is fairly clear. See https://rust-lang.github.io/rust-clippy/master/index.html#/needless_borrow ``` __CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::needless_borrow cargo fmt --all ```
32 lines
1.2 KiB
Rust
32 lines
1.2 KiB
Rust
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
|
|
use crate::cbindgen::EnabledFeatures;
|
|
use std::path::Path;
|
|
mod cbindgen;
|
|
|
|
fn main() -> Result<(), anyhow::Error> {
|
|
let manifest_dir = std::env::var_os("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
// Go from $root/api/cpp down to $root
|
|
let root_dir = Path::new(&manifest_dir).ancestors().nth(2).expect(&format!(
|
|
"Failed to locate root directory, relative to {}",
|
|
manifest_dir.to_string_lossy()
|
|
));
|
|
|
|
println!("cargo:rerun-if-env-changed=SLINT_GENERATED_INCLUDE_DIR");
|
|
let output_dir = std::env::var_os("SLINT_GENERATED_INCLUDE_DIR").unwrap_or_else(|| {
|
|
Path::new(&std::env::var_os("OUT_DIR").unwrap()).join("generated_include").into()
|
|
});
|
|
let output_dir = Path::new(&output_dir);
|
|
|
|
println!("cargo:GENERATED_INCLUDE_DIR={}", output_dir.display());
|
|
|
|
let enabled_features = EnabledFeatures::from_env();
|
|
|
|
let dependencies = cbindgen::gen_all(root_dir, output_dir, enabled_features)?;
|
|
for path in dependencies {
|
|
println!("cargo:rerun-if-changed={}", path.display());
|
|
}
|
|
Ok(())
|
|
}
|