Skip to content

Commit 7245720

Browse files
SanderVockeSander Vocke
authored andcommitted
qt-build-utils: support qmake wrapper scripts
1 parent 96d3233 commit 7245720

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ impl TryFrom<PathBuf> for QtInstallationQMake {
102102

103103
fn try_from(qmake_path: PathBuf) -> anyhow::Result<Self> {
104104
// Attempt to read the QT_VERSION from qmake
105-
let qmake_version = match Command::new(&qmake_path)
105+
let qmake_command : String =
106+
format!("{} -query QT_VERSION", qmake_path.to_string_lossy().to_string());
107+
let qmake_version = match utils::native_shell_command(&qmake_command)
106108
.args(["-query", "QT_VERSION"])
107109
.output()
108110
{
@@ -373,9 +375,11 @@ impl QtInstallationQMake {
373375
}
374376

375377
fn qmake_query(&self, var_name: &str) -> String {
378+
let qmake_command = format!("{} -query {}",
379+
self.qmake_path.to_string_lossy().to_string(),
380+
var_name);
376381
String::from_utf8_lossy(
377-
&Command::new(&self.qmake_path)
378-
.args(["-query", var_name])
382+
&utils::native_shell_command(&qmake_command)
379383
.output()
380384
.unwrap()
381385
.stdout,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//
44
// SPDX-License-Identifier: MIT OR Apache-2.0
55

6+
use std::process::Command;
7+
68
/// Whether apple is the current target
79
pub(crate) fn is_apple_target() -> bool {
810
std::env::var("TARGET")
@@ -14,3 +16,16 @@ pub(crate) fn is_apple_target() -> bool {
1416
pub(crate) fn is_emscripten_target() -> bool {
1517
std::env::var("CARGO_CFG_TARGET_OS") == Ok("emscripten".to_owned())
1618
}
19+
20+
/// Wrap a command in a native subshell
21+
pub(crate) fn native_shell_command(command : &str) -> Command {
22+
let mut result : Command;
23+
if cfg!(target_os = "windows") {
24+
result = Command::new("cmd");
25+
result.args(["/C", &command]);
26+
} else {
27+
result = Command::new("sh");
28+
result.args(["-c", &command]);
29+
}
30+
result
31+
}

0 commit comments

Comments
 (0)