mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
Clean up generated C++ include directory handling
Don't generate the headers by default in the source directory, put them into a sub-directory in OUT_DIR instead and convey that location via links to the C++ test driver.
This commit is contained in:
parent
499ab6645c
commit
324fb48499
5 changed files with 19 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,4 +4,3 @@ node_modules
|
||||||
tools/figma_import/target
|
tools/figma_import/target
|
||||||
tools/figma_import/figma_output
|
tools/figma_import/figma_output
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
api/sixtyfps-cpp/generated_include
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ description = "SixtyFPS C++ integration"
|
||||||
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
||||||
homepage = "https://sixtyfps.io"
|
homepage = "https://sixtyfps.io"
|
||||||
publish = false
|
publish = false
|
||||||
|
# prefix used to convey path to generated includes to the C++ test driver
|
||||||
|
links = "sixtyfps_cpp"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
|
@ -20,8 +20,12 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
manifest_dir.to_string_lossy()
|
manifest_dir.to_string_lossy()
|
||||||
));
|
));
|
||||||
|
|
||||||
let output_dir = std::env::var_os("SIXTYFPS_GENERATED_INCLUDE_DIR")
|
let output_dir = std::env::var_os("SIXTYFPS_GENERATED_INCLUDE_DIR").unwrap_or_else(|| {
|
||||||
.unwrap_or_else(|| Path::new(&manifest_dir).join("generated_include").into());
|
Path::new(&std::env::var_os("OUT_DIR").unwrap()).join("generated_include").into()
|
||||||
|
});
|
||||||
|
let output_dir = Path::new(&output_dir);
|
||||||
|
|
||||||
cbindgen::gen_all(&root_dir, &Path::new(&output_dir))
|
println!("cargo:GENERATED_INCLUDE_DIR={}", output_dir.display());
|
||||||
|
|
||||||
|
cbindgen::gen_all(&root_dir, &output_dir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,11 @@ license = "GPL-3.0-only"
|
||||||
path = "main.rs"
|
path = "main.rs"
|
||||||
name = "test-driver-cpp"
|
name = "test-driver-cpp"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
sixtyfps-cpp = { path = "../../../api/sixtyfps-cpp", features = ["testing"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sixtyfps-compilerlib = { path = "../../../sixtyfps_compiler", features = ["cpp", "display-diagnostics"] }
|
sixtyfps-compilerlib = { path = "../../../sixtyfps_compiler", features = ["cpp", "display-diagnostics"] }
|
||||||
sixtyfps-cpp = { path = "../../../api/sixtyfps-cpp", features = ["testing"] }
|
|
||||||
cc = "1.0.54"
|
cc = "1.0.54"
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
scopeguard = "1.1.0"
|
scopeguard = "1.1.0"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
Please contact info@sixtyfps.io for more information.
|
Please contact info@sixtyfps.io for more information.
|
||||||
LICENSE END */
|
LICENSE END */
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
/// The root dir of the git repository
|
/// The root dir of the git repository
|
||||||
fn root_dir() -> PathBuf {
|
fn root_dir() -> PathBuf {
|
||||||
|
@ -34,15 +34,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
println!("cargo:rustc-env=CPP_LIB_PATH={}", target_dir.display());
|
println!("cargo:rustc-env=CPP_LIB_PATH={}", target_dir.display());
|
||||||
|
|
||||||
|
let generated_include_dir = std::env::var_os("DEP_SIXTYFPS_CPP_GENERATED_INCLUDE_DIR")
|
||||||
|
.expect("the sixtyfps-cpp crate needs to provide the meta-data that points to the directory with the generated includes");
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=GENERATED_CPP_HEADERS_PATH={}",
|
||||||
|
Path::new(&generated_include_dir).display()
|
||||||
|
);
|
||||||
let root_dir = root_dir();
|
let root_dir = root_dir();
|
||||||
println!(
|
println!(
|
||||||
"cargo:rustc-env=CPP_API_HEADERS_PATH={}/api/sixtyfps-cpp/include",
|
"cargo:rustc-env=CPP_API_HEADERS_PATH={}/api/sixtyfps-cpp/include",
|
||||||
root_dir.display()
|
root_dir.display()
|
||||||
);
|
);
|
||||||
println!(
|
|
||||||
"cargo:rustc-env=GENERATED_CPP_HEADERS_PATH={}/api/sixtyfps-cpp/generated_include",
|
|
||||||
root_dir.display()
|
|
||||||
);
|
|
||||||
|
|
||||||
let tests_file_path =
|
let tests_file_path =
|
||||||
std::path::Path::new(&std::env::var_os("OUT_DIR").unwrap()).join("test_functions.rs");
|
std::path::Path::new(&std::env::var_os("OUT_DIR").unwrap()).join("test_functions.rs");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue