Skip to content

Commit e38866b

Browse files
committed
cxx-qt-build: store manifest and dependencies in Interface for now
This allows export() to have no args meaning we can return an Interface from the compile command next.
1 parent 08ae5f7 commit e38866b

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
99

1010
use std::path::PathBuf;
1111

12-
#[derive(Clone, Serialize, Deserialize)]
12+
#[derive(Clone, Default, Serialize, Deserialize)]
1313
/// This struct is used by cxx-qt-build internally to propagate data through to downstream
1414
/// dependencies
1515
pub(crate) struct Manifest {

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub struct Interface {
1818
pub(crate) reexport_links: HashSet<String>,
1919
pub(crate) exported_include_prefixes: Vec<String>,
2020
pub(crate) exported_include_directories: Vec<(PathBuf, String)>,
21+
pub(crate) manifest: Manifest,
22+
pub(crate) dependencies: Vec<Dependency>,
2123
// TODO: In future, we want to also set up the include paths so that you can include anything
2224
// from the crates source directory.
2325
// Once this is done, this flag should indicate whether or not to export our own crates source
@@ -31,6 +33,8 @@ impl Default for Interface {
3133
reexport_links: HashSet::new(),
3234
exported_include_prefixes: vec![super::crate_name()],
3335
exported_include_directories: Vec::new(),
36+
manifest: Manifest::default(),
37+
dependencies: Vec::new(),
3438
}
3539
}
3640
}
@@ -100,20 +104,20 @@ impl Interface {
100104
self
101105
}
102106

103-
pub(crate) fn export(self, mut manifest: Manifest, dependencies: &[Dependency]) {
107+
pub(crate) fn export(mut self) {
104108
self.write_exported_include_directories();
105109

106110
// We automatically reexport all qt_modules and downstream dependencies
107111
// as they will always need to be enabled in the final binary.
108112
// However, we only reexport the headers of libraries that
109113
// are marked as re-export.
110-
let dependencies = reexported_dependencies(&self, &dependencies);
114+
let dependencies = reexported_dependencies(&self, &self.dependencies);
111115

112-
manifest.exported_include_prefixes = all_include_prefixes(&self, &dependencies);
116+
self.manifest.exported_include_prefixes = all_include_prefixes(&self, &dependencies);
113117

114118
let manifest_path = dir::crate_target().join("manifest.json");
115-
let manifest_json =
116-
serde_json::to_string_pretty(&manifest).expect("Failed to convert Manifest to JSON!");
119+
let manifest_json = serde_json::to_string_pretty(&self.manifest)
120+
.expect("Failed to convert Manifest to JSON!");
117121
std::fs::write(&manifest_path, manifest_json).expect("Failed to write manifest.json!");
118122
println!(
119123
"cargo::metadata=CXX_QT_MANIFEST_PATH={}",

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,16 +1125,17 @@ extern "C" bool {init_fun}() {{
11251125
self.cc_builder.compile(&static_lib_name());
11261126
}
11271127

1128-
if let Some(interface) = self.public_interface {
1129-
let manifest = Manifest {
1128+
if let Some(mut interface) = self.public_interface {
1129+
interface.manifest = Manifest {
11301130
name: crate_name(),
11311131
link_name: link_name()
11321132
.expect("The links key must be set when creating a library with CXX-Qt-build!"),
11331133
initializers: vec![public_initializer.strip_file()],
11341134
qt_modules: qt_modules.into_iter().collect(),
11351135
exported_include_prefixes: vec![],
11361136
};
1137-
interface.export(manifest, &dependencies);
1137+
interface.dependencies = dependencies;
1138+
interface.export();
11381139
}
11391140
}
11401141
}

0 commit comments

Comments
 (0)