Skip to content

Commit

Permalink
Merge pull request #268 from jdpurcell/qt-host-path
Browse files Browse the repository at this point in the history
Set QT_HOST_PATH for parallel desktop installations
  • Loading branch information
jurplel authored Feb 13, 2025
2 parents ab8c8a2 + dc5cb24 commit fb77df4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ jobs:
example-archives: ${{ matrix.qt.example-archives }}
example-modules: ${{ matrix.qt.example-modules }}

- name: Test QT_HOST_PATH
if: ${{ startsWith(matrix.qt.version, '6.') }}
shell: pwsh
run: |
$qmakeHostPrefix = [string](Resolve-Path -Path (qmake -query QT_HOST_PREFIX))
if ($env:QT_HOST_PATH -ne $qmakeHostPrefix) {
throw "QT_HOST_PATH should match qmake's QT_HOST_PREFIX."
}
if ($env:QT_HOST_PATH -eq $env:QT_ROOT_DIR) {
throw "QT_HOST_PATH and QT_ROOT_DIR should be different."
}
if ((Split-Path -Path $env:QT_HOST_PATH -Parent) -ne (Split-Path -Path $env:QT_ROOT_DIR -Parent)) {
throw "QT_HOST_PATH and QT_ROOT_DIR should have the same parent directory."
}
Write-Host "All tests passed!"
- name: Install Android NDK
shell: bash
# Links to NDK are at https://github.com/android/ndk/wiki/Unsupported-Downloads
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,14 @@ jobs:
ls "${QT_ROOT_DIR}/bin/" | grep qmake
- name: Switch macOS Xcode version with older Qt versions
if: ${{ matrix.qt.version && (startsWith(matrix.os, 'macos-13') || startsWith(matrix.os, 'macos-14')) }}
if: ${{ matrix.qt.version && startsWith(matrix.os, 'macos-13') }}
shell: pwsh
env:
QT_VERSION: ${{ matrix.qt.version }}
run: |
if ([version]$env:QT_VERSION -ge [version]"6.5.3") {
# 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
sudo xcode-select --switch /Applications/Xcode_15.2.app
} else {
# Keep older Qt versions on Xcode 14 due to concern over QTBUG-117484
sudo xcode-select --switch /Applications/Xcode_14.3.1.app
if ([version]$env:QT_VERSION -lt [version]'6.5.3') {
# Workaround for QTBUG-117225
sudo xcode-select --switch /Applications/Xcode_14.3.1.app
}
- name: Configure test project on windows
Expand Down
21 changes: 16 additions & 5 deletions action/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const flaggedList = (flag: string, listArgs: readonly string[]): string[] => {
return listArgs.length ? [flag, ...listArgs] : [];
};

const locateQtArchDir = (installDir: string): string => {
const locateQtArchDir = (installDir: string): [string, boolean] => {
// For 6.4.2/gcc, qmake is at 'installDir/6.4.2/gcc_64/bin/qmake'.
// This makes a list of all the viable arch directories that contain a qmake file.
const qtArchDirs = glob
Expand All @@ -84,16 +84,18 @@ const locateQtArchDir = (installDir: string): string => {
const requiresParallelDesktop = qtArchDirs.filter((archPath) => {
const archDir = path.basename(archPath);
const versionDir = path.basename(path.join(archPath, ".."));
return versionDir.match(/^6\.\d+\.\d+$/) && archDir.match(/^(android*|ios|wasm*|msvc*_arm64)$/);
return (
versionDir.match(/^6\.\d+\.\d+$/) && archDir.match(/^(android.*|ios|wasm.*|msvc.*_arm64)$/)
);
});
if (requiresParallelDesktop.length) {
// NOTE: if multiple mobile/wasm installations coexist, this may not select the desired directory
return requiresParallelDesktop[0];
return [requiresParallelDesktop[0], true];
} else if (!qtArchDirs.length) {
throw Error(`Failed to locate a Qt installation directory in ${installDir}`);
} else {
// NOTE: if multiple Qt installations exist, this may not select the desired directory
return qtArchDirs[0];
return [qtArchDirs[0], false];
}
};

Expand Down Expand Up @@ -455,7 +457,7 @@ const run = async (): Promise<void> => {
}
// Set environment variables/outputs for binaries
if (inputs.isInstallQtBinaries) {
const qtPath = locateQtArchDir(inputs.dir);
const [qtPath, requiresParallelDesktop] = locateQtArchDir(inputs.dir);
// Set outputs
core.setOutput("qtPath", qtPath);

Expand All @@ -474,6 +476,15 @@ const run = async (): Promise<void> => {
core.exportVariable("QT_ROOT_DIR", qtPath);
core.exportVariable("QT_PLUGIN_PATH", path.resolve(qtPath, "plugins"));
core.exportVariable("QML2_IMPORT_PATH", path.resolve(qtPath, "qml"));
if (requiresParallelDesktop) {
const hostPrefix = await fs.promises
.readFile(path.join(qtPath, "bin", "target_qt.conf"), "utf8")
.then((data) => data.match(/^HostPrefix=(.*)$/m)?.[1].trim() ?? "")
.catch(() => "");
if (hostPrefix) {
core.exportVariable("QT_HOST_PATH", path.resolve(qtPath, "bin", hostPrefix));
}
}
core.addPath(path.resolve(qtPath, "bin"));
}
}
Expand Down

0 comments on commit fb77df4

Please sign in to comment.