Skip to content

Commit

Permalink
Merge pull request #173 from ddalcino/fix-bad-qtpath
Browse files Browse the repository at this point in the history
Fix detection of Qt architecture directory
  • Loading branch information
jurplel committed Feb 18, 2023
2 parents 6def958 + 0f87477 commit 05e8c48
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 25 deletions.
59 changes: 41 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ jobs:
os:
- ubuntu-22.04
- ubuntu-20.04
- ubuntu-18.04
- windows-2022
- windows-2019
- macos-11
- macos-12
version:
- "5.9.0"
- "5.15.2"
- "6.2.0"
qt:
- version: "5.9.0"
requested: "5.9.0"
- version: "5.15.2"
requested: "5.15"
- version: "6.3.2" # Qt 6.3 is not an LTS version, so '6.3.*' always resolves to '6.3.2'
requested: "6.3.*"
- version: null # Tools-only build
requested: null
cache:
- cached
- uncached

# Ubuntu 18 is not a supported target for Qt 6: https://www.qt.io/blog/qt6-development-hosts-and-targets
exclude:
- os: ubuntu-18.04
version: "6.2.0"
steps:
- uses: actions/checkout@v3

Expand All @@ -67,28 +67,28 @@ jobs:
npm run build
- name: Install Qt5 with options
if: startsWith(matrix.version, '5')
if: ${{ matrix.qt.version && startsWith(matrix.qt.version, '5') }}
uses: ./
with:
modules: qtwebengine
version: ${{ matrix.version }}
version: ${{ matrix.qt.requested }}
tools: tools_ifw tools_qtcreator,qt.tools.qtcreator
cache: ${{ matrix.cache == 'cached' }}

- name: Install Qt6 with options
if: startsWith(matrix.version, '6.2')
if: ${{ matrix.qt.version && startsWith(matrix.qt.version, '6') }}
uses: ./
with:
# In Qt 6.2.0, qtwebengine requires qtpositioning and qtwebchannel
# In Qt 6.2.0+, qtwebengine requires qtpositioning and qtwebchannel
modules: qtwebengine qtpositioning qtwebchannel
version: ${{ matrix.version }}
version: ${{ matrix.qt.requested }}
tools: tools_ifw tools_qtcreator,qt.tools.qtcreator
cache: ${{ matrix.cache == 'cached' }}

- name: Configure test project on windows
if: startsWith(matrix.os, 'windows')
if: ${{ matrix.qt.version && startsWith(matrix.os, 'windows') }}
env:
QT_VERSION: ${{ matrix.version }}
QT_VERSION: ${{ matrix.qt.version }}
run: |
cd tests/TestWithModules
for /f "delims=" %%d in ( 'vswhere.exe -latest -property installationPath' ) do @( call "%%d\VC\Auxiliary\Build\vcvars64.bat" )
Expand All @@ -97,9 +97,9 @@ jobs:
shell: cmd

- name: Configure test project on unix
if: (!startsWith(matrix.os, 'windows'))
if: ${{ matrix.qt.version && !startsWith(matrix.os, 'windows') }}
env:
QT_VERSION: ${{ matrix.version }}
QT_VERSION: ${{ matrix.qt.version }}
run: |
cd tests/TestWithModules
if [[ $QT_VERSION == 6* ]]; then
Expand All @@ -109,3 +109,26 @@ jobs:
fi
qmake
shell: bash

- name: Install tools with options
if: ${{ !matrix.qt.version }}
uses: ./
with:
tools-only: true
tools: tools_ifw tools_qtcreator,qt.tools.qtcreator
cache: ${{ matrix.cache == 'cached' }}

- name: Test installed tools
if: ${{ !matrix.qt.version }}
env:
# Conditionally set qtcreator path based on os:
QTCREATOR_BIN_PATH: ${{ startsWith(matrix.os, 'macos') && '../Qt/Qt Creator.app/Contents/MacOS/' || '../Qt/Tools/QtCreator/bin/' }}
shell: bash
run: |
# Check if QtIFW is installed
ls ../Qt/Tools/QtInstallerFramework/*/bin/
../Qt/Tools/QtInstallerFramework/*/bin/archivegen --version
# Check if QtCreator is installed: QtCreator includes the CLI program 'qbs' on all 3 platforms
ls "${QTCREATOR_BIN_PATH}"
"${QTCREATOR_BIN_PATH}qbs" --version
32 changes: 25 additions & 7 deletions action/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ const execPython = async (command: string, args: readonly string[]): Promise<num
return exec(`${python} -m ${command} ${args.join(" ")}`);
};

const locateQtArchDir = (installDir: string): string => {
// 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
.sync(`${installDir}/[0-9]*/*/bin/qmake*`)
.map((s) => s.replace(/\/bin\/qmake[^/]*$/, ""));

// For Qt6 mobile and wasm installations, a standard desktop Qt installation
// must exist alongside the requested architecture.
// In these cases, we must select the first item that ends with 'android*', 'ios', or 'wasm*'.
const requiresParallelDesktop = qtArchDirs.filter((p) =>
p.match(/6\.\d+\.\d+\/(android[^/]*|ios|wasm[^/]*)$/)
);
if (requiresParallelDesktop.length) {
// NOTE: if multiple mobile/wasm installations coexist, this may not select the desired directory
return requiresParallelDesktop[0];
} 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];
}
};

class Inputs {
readonly host: "windows" | "mac" | "linux";
readonly target: "desktop" | "android" | "ios";
Expand Down Expand Up @@ -172,12 +196,6 @@ class Inputs {
this.py7zrVersion = core.getInput("py7zrversion");
}

public get versionDir(): string {
// Weird naming scheme exception for qt 5.9
const version = this.version === "5.9.0" ? "5.9" : this.version;
return nativePath(`${this.dir}/${version}`);
}

public get cacheKey(): string {
let cacheKey = this.cacheKeyPrefix;
for (const keyStringArray of [
Expand Down Expand Up @@ -331,12 +349,12 @@ const run = async (): Promise<void> => {
}

// Set environment variables
const qtPath = nativePath(glob.sync(`${inputs.versionDir}/**/*`)[0]);
if (inputs.setEnv) {
if (inputs.tools.length) {
core.exportVariable("IQTA_TOOLS", nativePath(`${inputs.dir}/Tools`));
}
if (!inputs.toolsOnly) {
const qtPath = nativePath(locateQtArchDir(inputs.dir));
if (process.platform === "linux") {
setOrAppendEnvVar("LD_LIBRARY_PATH", nativePath(`${qtPath}/lib`));
}
Expand Down

0 comments on commit 05e8c48

Please sign in to comment.