File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
crates/qt-build-utils/src Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -102,10 +102,11 @@ impl TryFrom<PathBuf> for QtInstallationQMake {
102
102
103
103
fn try_from ( qmake_path : PathBuf ) -> anyhow:: Result < Self > {
104
104
// Attempt to read the QT_VERSION from qmake
105
- let qmake_version = match Command :: new ( & qmake_path)
106
- . args ( [ "-query" , "QT_VERSION" ] )
107
- . output ( )
108
- {
105
+ let qmake_command: String = format ! (
106
+ "{} -query QT_VERSION" ,
107
+ qmake_path. to_string_lossy( ) . to_string( )
108
+ ) ;
109
+ let qmake_version = match utils:: native_shell_command ( & qmake_command) . output ( ) {
109
110
Err ( e) if e. kind ( ) == ErrorKind :: NotFound => Err ( QtBuildError :: QtMissing ) ,
110
111
Err ( e) => Err ( QtBuildError :: QmakeFailed ( e) ) ,
111
112
Ok ( output) if !output. status . success ( ) => Err ( QtBuildError :: QtMissing ) ,
@@ -373,9 +374,13 @@ impl QtInstallationQMake {
373
374
}
374
375
375
376
fn qmake_query ( & self , var_name : & str ) -> String {
377
+ let qmake_command = format ! (
378
+ "{} -query {}" ,
379
+ self . qmake_path. to_string_lossy( ) . to_string( ) ,
380
+ var_name
381
+ ) ;
376
382
String :: from_utf8_lossy (
377
- & Command :: new ( & self . qmake_path )
378
- . args ( [ "-query" , var_name] )
383
+ & utils:: native_shell_command ( & qmake_command)
379
384
. output ( )
380
385
. unwrap ( )
381
386
. stdout ,
Original file line number Diff line number Diff line change 3
3
//
4
4
// SPDX-License-Identifier: MIT OR Apache-2.0
5
5
6
+ use std:: process:: Command ;
7
+
6
8
/// Whether apple is the current target
7
9
pub ( crate ) fn is_apple_target ( ) -> bool {
8
10
std:: env:: var ( "TARGET" )
@@ -14,3 +16,16 @@ pub(crate) fn is_apple_target() -> bool {
14
16
pub ( crate ) fn is_emscripten_target ( ) -> bool {
15
17
std:: env:: var ( "CARGO_CFG_TARGET_OS" ) == Ok ( "emscripten" . to_owned ( ) )
16
18
}
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
+ }
You can’t perform that action at this time.
0 commit comments