Skip to content

Commit fb77df4

Browse files
authored
Merge pull request #268 from jdpurcell/qt-host-path
Set QT_HOST_PATH for parallel desktop installations
2 parents ab8c8a2 + dc5cb24 commit fb77df4

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

.github/workflows/test-android.yml

+16
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ jobs:
5252
example-archives: ${{ matrix.qt.example-archives }}
5353
example-modules: ${{ matrix.qt.example-modules }}
5454

55+
- name: Test QT_HOST_PATH
56+
if: ${{ startsWith(matrix.qt.version, '6.') }}
57+
shell: pwsh
58+
run: |
59+
$qmakeHostPrefix = [string](Resolve-Path -Path (qmake -query QT_HOST_PREFIX))
60+
if ($env:QT_HOST_PATH -ne $qmakeHostPrefix) {
61+
throw "QT_HOST_PATH should match qmake's QT_HOST_PREFIX."
62+
}
63+
if ($env:QT_HOST_PATH -eq $env:QT_ROOT_DIR) {
64+
throw "QT_HOST_PATH and QT_ROOT_DIR should be different."
65+
}
66+
if ((Split-Path -Path $env:QT_HOST_PATH -Parent) -ne (Split-Path -Path $env:QT_ROOT_DIR -Parent)) {
67+
throw "QT_HOST_PATH and QT_ROOT_DIR should have the same parent directory."
68+
}
69+
Write-Host "All tests passed!"
70+
5571
- name: Install Android NDK
5672
shell: bash
5773
# Links to NDK are at https://github.com/android/ndk/wiki/Unsupported-Downloads

.github/workflows/test.yml

+4-7
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,14 @@ jobs:
146146
ls "${QT_ROOT_DIR}/bin/" | grep qmake
147147
148148
- name: Switch macOS Xcode version with older Qt versions
149-
if: ${{ matrix.qt.version && (startsWith(matrix.os, 'macos-13') || startsWith(matrix.os, 'macos-14')) }}
149+
if: ${{ matrix.qt.version && startsWith(matrix.os, 'macos-13') }}
150150
shell: pwsh
151151
env:
152152
QT_VERSION: ${{ matrix.qt.version }}
153153
run: |
154-
if ([version]$env:QT_VERSION -ge [version]"6.5.3") {
155-
# GitHub macOS 13/14 runners use Xcode 15.0.x by default which has a known linker issue causing crashes if the artifact is run on macOS <= 12
156-
sudo xcode-select --switch /Applications/Xcode_15.2.app
157-
} else {
158-
# Keep older Qt versions on Xcode 14 due to concern over QTBUG-117484
159-
sudo xcode-select --switch /Applications/Xcode_14.3.1.app
154+
if ([version]$env:QT_VERSION -lt [version]'6.5.3') {
155+
# Workaround for QTBUG-117225
156+
sudo xcode-select --switch /Applications/Xcode_14.3.1.app
160157
}
161158
162159
- name: Configure test project on windows

action/src/main.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const flaggedList = (flag: string, listArgs: readonly string[]): string[] => {
7171
return listArgs.length ? [flag, ...listArgs] : [];
7272
};
7373

74-
const locateQtArchDir = (installDir: string): string => {
74+
const locateQtArchDir = (installDir: string): [string, boolean] => {
7575
// For 6.4.2/gcc, qmake is at 'installDir/6.4.2/gcc_64/bin/qmake'.
7676
// This makes a list of all the viable arch directories that contain a qmake file.
7777
const qtArchDirs = glob
@@ -84,16 +84,18 @@ const locateQtArchDir = (installDir: string): string => {
8484
const requiresParallelDesktop = qtArchDirs.filter((archPath) => {
8585
const archDir = path.basename(archPath);
8686
const versionDir = path.basename(path.join(archPath, ".."));
87-
return versionDir.match(/^6\.\d+\.\d+$/) && archDir.match(/^(android*|ios|wasm*|msvc*_arm64)$/);
87+
return (
88+
versionDir.match(/^6\.\d+\.\d+$/) && archDir.match(/^(android.*|ios|wasm.*|msvc.*_arm64)$/)
89+
);
8890
});
8991
if (requiresParallelDesktop.length) {
9092
// NOTE: if multiple mobile/wasm installations coexist, this may not select the desired directory
91-
return requiresParallelDesktop[0];
93+
return [requiresParallelDesktop[0], true];
9294
} else if (!qtArchDirs.length) {
9395
throw Error(`Failed to locate a Qt installation directory in ${installDir}`);
9496
} else {
9597
// NOTE: if multiple Qt installations exist, this may not select the desired directory
96-
return qtArchDirs[0];
98+
return [qtArchDirs[0], false];
9799
}
98100
};
99101

@@ -455,7 +457,7 @@ const run = async (): Promise<void> => {
455457
}
456458
// Set environment variables/outputs for binaries
457459
if (inputs.isInstallQtBinaries) {
458-
const qtPath = locateQtArchDir(inputs.dir);
460+
const [qtPath, requiresParallelDesktop] = locateQtArchDir(inputs.dir);
459461
// Set outputs
460462
core.setOutput("qtPath", qtPath);
461463

@@ -474,6 +476,15 @@ const run = async (): Promise<void> => {
474476
core.exportVariable("QT_ROOT_DIR", qtPath);
475477
core.exportVariable("QT_PLUGIN_PATH", path.resolve(qtPath, "plugins"));
476478
core.exportVariable("QML2_IMPORT_PATH", path.resolve(qtPath, "qml"));
479+
if (requiresParallelDesktop) {
480+
const hostPrefix = await fs.promises
481+
.readFile(path.join(qtPath, "bin", "target_qt.conf"), "utf8")
482+
.then((data) => data.match(/^HostPrefix=(.*)$/m)?.[1].trim() ?? "")
483+
.catch(() => "");
484+
if (hostPrefix) {
485+
core.exportVariable("QT_HOST_PATH", path.resolve(qtPath, "bin", hostPrefix));
486+
}
487+
}
477488
core.addPath(path.resolve(qtPath, "bin"));
478489
}
479490
}

0 commit comments

Comments
 (0)