Skip to content

Commit 253b7af

Browse files
committed
cxx-qt-build: split include and exported include dirs
1 parent b62b038 commit 253b7af

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

crates/cxx-qt-build/src/dir.rs

+4
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ pub(crate) fn header_root() -> PathBuf {
121121
crate_target().join("include")
122122
}
123123

124+
pub(crate) fn header_root_interface() -> PathBuf {
125+
target().join("include-interface")
126+
}
127+
124128
/// The OUT_DIR, converted into a PathBuf
125129
pub(crate) fn out() -> PathBuf {
126130
env::var("OUT_DIR").unwrap().into()

crates/cxx-qt-build/src/interface.rs

+24-4
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,36 @@ impl Interface {
133133
}
134134

135135
fn write_exported_include_directories(&self) {
136-
let header_root = dir::header_root();
136+
// Add any export directories as a child of the include interface directory
137+
let header_root_interface = dir::header_root_interface();
138+
std::fs::create_dir_all(&header_root_interface)
139+
.expect("Failed to create header root for interface");
137140
for (header_dir, dest) in &self.exported_include_directories {
138-
let dest_dir = header_root.join(dest);
139-
if let Err(e) = dir::symlink_or_copy_directory(header_dir, dest_dir) {
140-
panic!(
141+
let dest_dir = header_root_interface.join(dest);
142+
match dir::symlink_or_copy_directory(header_dir, &dest_dir) {
143+
Ok(true) => {},
144+
Ok(false) => panic!("Failed to create symlink folder for `{dest}`"),
145+
Err(e) => panic!(
141146
"Failed to {INCLUDE_VERB} `{dest}` for export_include_directory `{dir_name}`: {e:?}",
142147
dir_name = header_dir.to_string_lossy()
143148
)
144149
};
145150
}
151+
152+
// Add any reexport links as a child of the include interface directory
153+
let header_root = dir::header_root();
154+
for reexport in &self.reexport_links {
155+
let source_dir = header_root.join(reexport);
156+
let dest_dir = header_root_interface.join(reexport);
157+
match dir::symlink_or_copy_directory(&source_dir, &dest_dir) {
158+
Ok(true) => {},
159+
Ok(false) => panic!("Failed to create symlink folder for `{reexport}`"),
160+
Err(e) => panic!(
161+
"Failed to {INCLUDE_VERB} `{reexport}` for export_include_directory `{dir_name}`: {e:?}",
162+
dir_name = source_dir.to_string_lossy()
163+
)
164+
};
165+
}
146166
}
147167
}
148168

crates/cxx-qt-build/src/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,17 @@ impl CxxQtBuilder {
653653
// or deep copy the files if the platform does not support symlinks.
654654
fn include_dependency(&mut self, dependency: &Dependency) {
655655
let header_root = dir::header_root();
656-
let dependency_root = dependency.path.join("include");
656+
let dependency_root = dependency.path.join("crates-include");
657657
for include_prefix in &dependency.manifest.exported_include_prefixes {
658658
// setup include directory
659659
let source = dependency_root.join(include_prefix);
660660
let dest = header_root.join(include_prefix);
661661

662+
// Not all crates have include interface, skip it this does not exist
663+
if !Path::new(&source).is_dir() {
664+
continue;
665+
}
666+
662667
match dir::symlink_or_copy_directory(source, dest) {
663668
Ok(true) => (),
664669
Ok(false) => {

0 commit comments

Comments
 (0)