@@ -11,8 +11,6 @@ import { exec, getExecOutput } from "@actions/exec";
11
11
import * as glob from "glob" ;
12
12
import { compare , CompareOperator } from "compare-versions" ;
13
13
14
- const nativePath = process . platform === "win32" ? path . win32 . normalize : path . normalize ;
15
-
16
14
const compareVersions = ( v1 : string , op : CompareOperator , v2 : string ) : boolean => {
17
15
return compare ( v1 , v2 , op ) ;
18
16
} ;
@@ -40,7 +38,7 @@ const binlessToolDirectories = ["Conan", "Ninja"];
40
38
41
39
const toolsPaths = ( installDir : string ) : string [ ] => {
42
40
const binlessPaths : string [ ] = binlessToolDirectories
43
- . map ( ( dir ) => ` ${ installDir } / Tools/ ${ dir } ` )
41
+ . map ( ( dir ) => path . join ( installDir , " Tools" , dir ) )
44
42
. filter ( ( dir ) => dirExists ( dir ) ) ;
45
43
return [
46
44
"Tools/**/bin" ,
@@ -50,7 +48,8 @@ const toolsPaths = (installDir: string): string[] => {
50
48
"Tools/*/*.app/**/bin" ,
51
49
]
52
50
. flatMap ( ( p : string ) : string [ ] => glob . sync ( `${ installDir } /${ p } ` ) )
53
- . concat ( binlessPaths ) ;
51
+ . concat ( binlessPaths )
52
+ . map ( ( p ) => path . resolve ( p ) ) ;
54
53
} ;
55
54
56
55
const pythonCommand = ( command : string , args : readonly string [ ] ) : string => {
@@ -77,14 +76,16 @@ const locateQtArchDir = (installDir: string): string => {
77
76
// This makes a list of all the viable arch directories that contain a qmake file.
78
77
const qtArchDirs = glob
79
78
. sync ( `${ installDir } /[0-9]*/*/bin/qmake*` )
80
- . map ( ( s ) => s . replace ( / \/ b i n \/ q m a k e [ ^ / ] * $ / , "" ) ) ;
79
+ . map ( ( s ) => path . resolve ( s , ".." , ".. ") ) ;
81
80
82
81
// For Qt6 mobile and wasm installations, and Qt6 Windows on ARM installations,
83
82
// a standard desktop Qt installation must exist alongside the requested architecture.
84
83
// In these cases, we must select the first item that ends with 'android*', 'ios', 'wasm*' or 'msvc*_arm64'.
85
- const requiresParallelDesktop = qtArchDirs . filter ( ( p ) =>
86
- p . match ( / 6 \. \d + \. \d + \/ ( a n d r o i d [ ^ / ] * | i o s | w a s m [ ^ / ] * | m s v c [ ^ / ] * _ a r m 6 4 ) $ / )
87
- ) ;
84
+ const requiresParallelDesktop = qtArchDirs . filter ( ( archPath ) => {
85
+ const archDir = path . basename ( archPath ) ;
86
+ const versionDir = path . basename ( path . join ( archPath , ".." ) ) ;
87
+ return versionDir . match ( / ^ 6 \. \d + \. \d + $ / ) && archDir . match ( / ^ ( a n d r o i d * | i o s | w a s m * | m s v c * _ a r m 6 4 ) $ / ) ;
88
+ } ) ;
88
89
if ( requiresParallelDesktop . length ) {
89
90
// NOTE: if multiple mobile/wasm installations coexist, this may not select the desired directory
90
91
return requiresParallelDesktop [ 0 ] ;
@@ -204,7 +205,7 @@ class Inputs {
204
205
if ( ! dir ) {
205
206
throw TypeError ( `"dir" input may not be empty` ) ;
206
207
}
207
- this . dir = ` ${ dir } /Qt` ;
208
+ this . dir = path . resolve ( dir , "Qt" ) ;
208
209
209
210
this . modules = Inputs . getStringArrayInput ( "modules" ) ;
210
211
@@ -445,35 +446,35 @@ const run = async (): Promise<void> => {
445
446
446
447
// Add tools to path
447
448
if ( inputs . addToolsToPath && inputs . tools . length ) {
448
- toolsPaths ( inputs . dir ) . map ( nativePath ) . forEach ( core . addPath ) ;
449
+ toolsPaths ( inputs . dir ) . forEach ( core . addPath ) ;
449
450
}
450
451
451
452
// Set environment variables/outputs for tools
452
453
if ( inputs . tools . length && inputs . setEnv ) {
453
- core . exportVariable ( "IQTA_TOOLS" , nativePath ( ` ${ inputs . dir } / Tools` ) ) ;
454
+ core . exportVariable ( "IQTA_TOOLS" , path . resolve ( inputs . dir , " Tools" ) ) ;
454
455
}
455
456
// Set environment variables/outputs for binaries
456
457
if ( inputs . isInstallQtBinaries ) {
457
- const qtPath = nativePath ( locateQtArchDir ( inputs . dir ) ) ;
458
+ const qtPath = locateQtArchDir ( inputs . dir ) ;
458
459
// Set outputs
459
460
core . setOutput ( "qtPath" , qtPath ) ;
460
461
461
462
// Set env variables
462
463
if ( inputs . setEnv ) {
463
464
if ( process . platform === "linux" ) {
464
- setOrAppendEnvVar ( "LD_LIBRARY_PATH" , nativePath ( ` ${ qtPath } / lib` ) ) ;
465
+ setOrAppendEnvVar ( "LD_LIBRARY_PATH" , path . resolve ( qtPath , " lib" ) ) ;
465
466
}
466
467
if ( process . platform !== "win32" ) {
467
- setOrAppendEnvVar ( "PKG_CONFIG_PATH" , nativePath ( ` ${ qtPath } / lib/ pkgconfig` ) ) ;
468
+ setOrAppendEnvVar ( "PKG_CONFIG_PATH" , path . resolve ( qtPath , " lib" , " pkgconfig" ) ) ;
468
469
}
469
470
// If less than qt6, set Qt5_DIR variable
470
471
if ( compareVersions ( inputs . version , "<" , "6.0.0" ) ) {
471
- core . exportVariable ( "Qt5_DIR" , nativePath ( ` ${ qtPath } / lib/ cmake` ) ) ;
472
+ core . exportVariable ( "Qt5_DIR" , path . resolve ( qtPath , " lib" , " cmake" ) ) ;
472
473
}
473
474
core . exportVariable ( "QT_ROOT_DIR" , qtPath ) ;
474
- core . exportVariable ( "QT_PLUGIN_PATH" , nativePath ( ` ${ qtPath } / plugins` ) ) ;
475
- core . exportVariable ( "QML2_IMPORT_PATH" , nativePath ( ` ${ qtPath } / qml` ) ) ;
476
- core . addPath ( nativePath ( ` ${ qtPath } / bin` ) ) ;
475
+ core . exportVariable ( "QT_PLUGIN_PATH" , path . resolve ( qtPath , " plugins" ) ) ;
476
+ core . exportVariable ( "QML2_IMPORT_PATH" , path . resolve ( qtPath , " qml" ) ) ;
477
+ core . addPath ( path . resolve ( qtPath , " bin" ) ) ;
477
478
}
478
479
}
479
480
} ;
0 commit comments