Skip to content

Commit 4c85f90

Browse files
committed
qt-build-utils: remove qmake executable path as it is in installation
1 parent eae651c commit 4c85f90

File tree

1 file changed

+4
-118
lines changed
  • crates/qt-build-utils/src

1 file changed

+4
-118
lines changed

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

+4-118
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ pub struct QmlModuleRegistrationFiles {
231231
/// ```
232232
pub struct QtBuild {
233233
qt_installation: Box<dyn QtInstallation>,
234-
qmake_executable: String,
235234
qt_modules: Vec<String>,
236235
}
237236

@@ -284,123 +283,10 @@ impl QtBuild {
284283
#[cfg(not(feature = "qmake"))]
285284
unsupported!("Only qmake feature is supported");
286285

287-
println!("cargo::rerun-if-env-changed=QMAKE");
288-
println!("cargo::rerun-if-env-changed=QT_VERSION_MAJOR");
289-
fn verify_candidate(candidate: &str) -> Result<&str, QtBuildError> {
290-
match Command::new(candidate)
291-
.args(["-query", "QT_VERSION"])
292-
.output()
293-
{
294-
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Err(QtBuildError::QtMissing),
295-
Err(e) => Err(QtBuildError::QmakeFailed(e)),
296-
Ok(output) => {
297-
if output.status.success() {
298-
let version_string = std::str::from_utf8(&output.stdout)
299-
.unwrap()
300-
.trim()
301-
.to_string();
302-
let qmake_version = Version::parse(&version_string).unwrap();
303-
if let Ok(env_version) = env::var("QT_VERSION_MAJOR") {
304-
let env_version = match env_version.trim().parse::<u64>() {
305-
Err(e) if *e.kind() == std::num::IntErrorKind::Empty => {
306-
println!(
307-
"cargo::warning=QT_VERSION_MAJOR environment variable defined but empty"
308-
);
309-
return Ok(candidate);
310-
}
311-
Err(e) => {
312-
return Err(QtBuildError::QtVersionMajorInvalid {
313-
qt_version_major_env_var: env_version,
314-
source: e,
315-
})
316-
}
317-
Ok(int) => int,
318-
};
319-
if env_version == qmake_version.major as u64 {
320-
return Ok(candidate);
321-
} else {
322-
return Err(QtBuildError::QtVersionMajorDoesNotMatch {
323-
qmake_version: qmake_version.major as u64,
324-
qt_version_major: env_version,
325-
});
326-
}
327-
}
328-
Ok(candidate)
329-
} else {
330-
Err(QtBuildError::QtMissing)
331-
}
332-
}
333-
}
334-
}
335-
336-
if let Ok(qmake_env_var) = env::var("QMAKE") {
337-
match verify_candidate(qmake_env_var.trim()) {
338-
Ok(executable_name) => {
339-
return Ok(Self {
340-
qt_installation,
341-
qmake_executable: executable_name.to_string(),
342-
qt_modules,
343-
});
344-
}
345-
Err(e) => {
346-
return Err(QtBuildError::QMakeSetQtMissing {
347-
qmake_env_var,
348-
error: Box::new(e.into()),
349-
}
350-
.into())
351-
}
352-
}
353-
}
354-
355-
// Fedora 36 renames Qt5's qmake to qmake-qt5
356-
let candidate_executable_names = ["qmake6", "qmake-qt5", "qmake"];
357-
for (index, executable_name) in candidate_executable_names.iter().enumerate() {
358-
match verify_candidate(executable_name) {
359-
Ok(executable_name) => {
360-
return Ok(Self {
361-
qt_installation,
362-
qmake_executable: executable_name.to_string(),
363-
qt_modules,
364-
});
365-
}
366-
// If QT_VERSION_MAJOR is specified, it is expected that one of the versioned
367-
// executable names will not match, so the unversioned `qmake` needs to be
368-
// attempted last and QtVersionMajorDoesNotMatch should only be returned if
369-
// none of the candidate executable names match.
370-
Err(QtBuildError::QtVersionMajorDoesNotMatch {
371-
qmake_version,
372-
qt_version_major,
373-
}) => {
374-
if index == candidate_executable_names.len() - 1 {
375-
return Err(QtBuildError::QtVersionMajorDoesNotMatch {
376-
qmake_version,
377-
qt_version_major,
378-
}
379-
.into());
380-
}
381-
eprintln!("Candidate qmake executable `{executable_name}` is for Qt{qmake_version} but QT_VERSION_MAJOR environment variable specified as {qt_version_major}. Trying next candidate executable name `{}`...", candidate_executable_names[index + 1]);
382-
continue;
383-
}
384-
Err(QtBuildError::QtMissing) => continue,
385-
Err(e) => return Err(e.into()),
386-
}
387-
}
388-
389-
Err(QtBuildError::QtMissing.into())
390-
}
391-
392-
/// Get the output of running `qmake -query var_name`
393-
pub fn qmake_query(&self, var_name: &str) -> String {
394-
std::str::from_utf8(
395-
&Command::new(&self.qmake_executable)
396-
.args(["-query", var_name])
397-
.output()
398-
.unwrap()
399-
.stdout,
400-
)
401-
.unwrap()
402-
.trim()
403-
.to_string()
286+
Ok(Self {
287+
qt_installation,
288+
qt_modules,
289+
})
404290
}
405291

406292
/// Tell Cargo to link each Qt module.

0 commit comments

Comments
 (0)