Skip to content

Commit b7ee964

Browse files
committed
qt-build-utils: use which to find full qmake path
1 parent 366af14 commit b7ee964

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

Cargo.lock

Lines changed: 28 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/qt-build-utils/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tar = { version = "0.4.44", optional = true }
2727
flate2 = { version = "1.1.9", optional = true }
2828
qt-artifacts = { version = "0.1.0", optional = true }
2929
qt-version = { version = "0.1.3", default-features = false, optional = true }
30+
which = { version = "8.0.0", optional = true }
3031

3132
[features]
3233
# TODO: should we default to qmake or let downstream crates specify, such as cxx-qt-build
@@ -42,7 +43,7 @@ default = ["qmake"]
4243
#
4344
# When linking Qt dynamically, this makes no difference.
4445
link_qt_object_files = []
45-
qmake = []
46+
qmake = ["dep:which"]
4647
qt_minimal = ["qt_version", "dep:serde", "serde/derive", "semver/serde", "dep:reqwest", "dep:sha2", "dep:tempfile", "dep:serde_json", "dep:flate2", "dep:tar", "dep:qt-artifacts", "dep:dirs"]
4748
qt_version = ["dep:qt-version"]
4849
serde = ["dep:serde"]

crates/qt-build-utils/src/installation/qmake.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,20 @@ impl QtInstallationQMake {
7474
// Use the first non-errored installation
7575
// If there are no valid installations we display the last error
7676
.fold(None, |acc, qmake_path| {
77-
Some(acc.map_or_else(
78-
// Value is None so try to create installation
79-
|| QtInstallationQMake::try_from(PathBuf::from(qmake_path)),
80-
// Value is Some so pass through or create if Err
81-
|prev: anyhow::Result<Self>| {
82-
prev.or_else(|_|
77+
if let Ok(qmake_path) = which::which(qmake_path) {
78+
Some(acc.map_or_else(
79+
// Value is None so try to create installation
80+
|| QtInstallationQMake::try_from(qmake_path.clone()),
81+
// Value is Some so pass through or create if Err
82+
|prev: anyhow::Result<Self>| {
83+
prev.or_else(|_|
8384
// Value is Err so try to create installation
84-
QtInstallationQMake::try_from(PathBuf::from(qmake_path)))
85-
},
86-
))
85+
QtInstallationQMake::try_from(qmake_path.clone()))
86+
},
87+
))
88+
} else {
89+
None
90+
}
8791
})
8892
.unwrap_or_else(|| Err(QtBuildError::QtMissing.into()))
8993
}

0 commit comments

Comments
 (0)