Skip to content

qt-build-utils: Add support for including headers from private modules #1160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions crates/qt-build-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ impl QtBuild {
};

for qt_module in &self.qt_modules {
if qt_module.contains("Private") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explaining how Private does not have a separate library and is just the normal library name.

I assume there is not a usecase of only putting like CorePrivate and not Core ? As this code currently requires you to specify the modules Core and CorePrivate, is this the same behaviour as with CMake ?

continue;
}

let framework = if is_apple_target() {
Path::new(&format!("{lib_path}/Qt{qt_module}.framework")).exists()
} else {
Expand Down Expand Up @@ -562,13 +566,19 @@ impl QtBuild {
let lib_path = self.qmake_query("QT_INSTALL_LIBS");
let mut paths = Vec::new();
for qt_module in &self.qt_modules {
// Add the usual location for the Qt module
paths.push(format!("{root_path}/Qt{qt_module}"));
if qt_module.contains("Private") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the module name always end with private ? as we could use .ends_with for these checks too ?

let version = &self.version;
let qt_module = qt_module.replace("Private", "");
paths.push(format!("{root_path}/Qt{qt_module}/{version}/Qt{qt_module}"));
} else {
// Add the usual location for the Qt module
paths.push(format!("{root_path}/Qt{qt_module}"));

// Ensure that we add any framework's headers path
let header_path = format!("{lib_path}/Qt{qt_module}.framework/Headers");
if is_apple_target() && Path::new(&header_path).exists() {
paths.push(header_path);
// Ensure that we add any framework's headers path
let header_path = format!("{lib_path}/Qt{qt_module}.framework/Headers");
if is_apple_target() && Path::new(&header_path).exists() {
paths.push(header_path);
}
}
}

Expand Down
Loading