Skip to content

Commit d5ab884

Browse files
committed
WIP: split include and exported include dirs
1 parent e379c77 commit d5ab884

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
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("crates-include")
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

+17-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ impl Interface {
133133
}
134134

135135
fn write_exported_include_directories(&self) {
136-
let header_root = dir::header_root();
136+
let header_root = dir::header_root_interface();
137+
std::fs::create_dir_all(&header_root).expect("Failed to create header root for interface");
137138
for (header_dir, dest) in &self.exported_include_directories {
138139
let dest_dir = header_root.join(dest);
139140
match dir::symlink_or_copy_directory(header_dir, &dest_dir) {
@@ -152,6 +153,21 @@ impl Interface {
152153
)
153154
};
154155
}
156+
157+
// TODO: needs tidying but add an reexport links to the exported include dir
158+
let header_root_includes = dir::header_root();
159+
for reexport in &self.reexport_links {
160+
let source_dir = header_root_includes.join(reexport);
161+
let dest_dir = header_root.join(reexport);
162+
match dir::symlink_or_copy_directory(&source_dir, &dest_dir) {
163+
Ok(true) => {},
164+
Ok(false) => panic!("Failed to create symlink folder already exists!"),
165+
Err(e) => panic!(
166+
"Failed to {INCLUDE_VERB} `{reexport}` for export_include_directory `{dir_name}`: {e:?}",
167+
dir_name = source_dir.to_string_lossy()
168+
)
169+
};
170+
}
155171
}
156172
}
157173

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,20 @@ 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+
// TODO: for now skip, this seems possible that not all crates have exports
663+
if !Path::new(&source).is_dir() {
664+
println!(
665+
"cargo::warning=Skipping {source:?} no exported includes found for dependency"
666+
);
667+
continue;
668+
}
669+
662670
match dir::symlink_or_copy_directory(source, dest) {
663671
Ok(true) => (),
664672
Ok(false) => {

0 commit comments

Comments
 (0)