Skip to content

Commit 4b684a6

Browse files
committed
WIP: cxx-qt-build: add ability to create qmlls.ini
1 parent 4037677 commit 4b684a6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,18 @@ pub(crate) fn module_target(module_uri: &QmlUri) -> PathBuf {
8888
/// TODO: This may conflict if two dependencies are building QML modules with the same name!
8989
/// We should probably include a lockfile here to avoid this.
9090
pub(crate) fn module_export(module_uri: &QmlUri) -> Option<PathBuf> {
91+
// In contrast to crate_export, we don't need to check for the specific crate here.
92+
// QML modules should always be exported.
93+
module_export_qml_modules().map(|dir| dir.join(module_uri.as_dirs()))
94+
}
95+
96+
pub(crate) fn module_export_qml_modules() -> Option<PathBuf> {
9197
// In contrast to crate_export, we don't need to check for the specific crate here.
9298
// QML modules should always be exported.
9399
env::var("CXX_QT_EXPORT_DIR")
94100
.ok()
95101
.map(PathBuf::from)
96-
.map(|dir| dir.join("qml_modules").join(module_uri.as_dirs()))
102+
.map(|dir| dir.join("qml_modules"))
97103
}
98104

99105
/// The target directory or another directory where we can write files that will be shared

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub use qml_modules::{QmlFile, QmlModule, QmlUri};
3636
pub use qt_build_utils::MocArguments;
3737
use qt_build_utils::MocProducts;
3838
use qt_build_utils::QResources;
39+
use qt_build_utils::QmlLsIniBuilder;
3940
use quote::ToTokens;
4041
use std::{
4142
collections::HashSet,
@@ -898,6 +899,22 @@ impl CxxQtBuilder {
898899
.expect("Could not copy qmldir to export directory");
899900
}
900901

902+
// Create a .qmlls.ini file with the build dir set similar to QT_QML_GENERATE_QMLLS_INI
903+
if let (Some(qml_modules_dir), Some(manifest_dir)) =
904+
(dir::module_export_qml_modules(), dir::manifest())
905+
{
906+
// TODO: manifest dir is not enough as QML files might be in a parent
907+
// so this should likely be an argument given to cxx-qt-build
908+
// that optionally exports?
909+
let mut file = File::create(manifest_dir.parent().unwrap().join(".qmlls.ini"))
910+
.expect("Could not create qmlls.ini file");
911+
QmlLsIniBuilder::new()
912+
.build_dir(qml_modules_dir)
913+
.no_cmake_calls(true)
914+
.write(&mut file)
915+
.expect("Could not write qmlls.ini")
916+
}
917+
901918
let module_init_key = qml_module_init_key(&qml_module.uri);
902919
let private_initializers = [qml_module_registration_files.plugin_init];
903920
let public_initializer =

0 commit comments

Comments
 (0)