Skip to content

Commit 0639a65

Browse files
committed
merge
2 parents b3ea527 + 8957947 commit 0639a65

File tree

8 files changed

+203
-32
lines changed

8 files changed

+203
-32
lines changed

.github/workflows/test-android.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI-android
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os:
12+
- ubuntu-22.04
13+
- windows-2022
14+
- macos-12
15+
qt:
16+
- version: "5.15.2"
17+
ndk-version: r21e
18+
modules:
19+
example-archives: qtbase qtsensors
20+
example-modules:
21+
- version: "6.3.2"
22+
ndk-version: r21e
23+
modules: qtsensors
24+
example-archives: qtbase
25+
example-modules: qtsensors
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- uses: actions/setup-node@v3
31+
with:
32+
node-version: 16
33+
cache: npm
34+
cache-dependency-path: action/
35+
36+
- run: |
37+
cd action
38+
npm ci || npm install
39+
shell: bash
40+
41+
- run: |
42+
cd action
43+
npm run build
44+
45+
- name: Install Qt
46+
uses: ./
47+
with:
48+
target: android
49+
modules: ${{ matrix.qt.modules }}
50+
version: ${{ matrix.qt.version }}
51+
examples: true
52+
example-archives: ${{ matrix.qt.example-archives }}
53+
example-modules: ${{ matrix.qt.example-modules }}
54+
55+
- name: Install Android NDK
56+
shell: bash
57+
# Links to NDK are at https://github.com/android/ndk/wiki/Unsupported-Downloads
58+
run: |
59+
if [[ "${RUNNER_OS}" == "Linux" ]]; then
60+
export TARGET_ARCH="linux"
61+
elif [[ "${RUNNER_OS}" == "Windows" ]]; then
62+
export TARGET_ARCH="windows"
63+
else
64+
export TARGET_ARCH="darwin"
65+
fi
66+
export NDK_VER_NUM=$(echo ${{ matrix.qt.ndk-version }} | sed -e 's/r(\d+).*/$1/g')
67+
# If it's less than 23, append -x86_64
68+
if (( "${NDK_VER_NUM}" < 23 )); then
69+
export TARGET_ARCH="${TARGET_ARCH}-x86_64"
70+
fi;
71+
curl -O "https://dl.google.com/android/repository/android-ndk-${{ matrix.qt.ndk-version }}-${TARGET_ARCH}.zip"
72+
unzip "android-ndk-${{ matrix.qt.ndk-version }}-${TARGET_ARCH}.zip"
73+
74+
- name: Build test project
75+
env:
76+
QT_VERSION: ${{ matrix.qt.version }}
77+
run: |
78+
export ANDROID_NDK_ROOT=$(pwd)/android-ndk-${{ matrix.qt.ndk-version }}
79+
cd ../Qt/Examples/Qt-${{ matrix.qt.version }}/sensors/accelbubble
80+
qmake || qmake.bat
81+
make
82+
shell: bash

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ jobs:
127127
run: |
128128
cd tests/TestWithModules
129129
for /f "delims=" %%d in ( 'vswhere.exe -latest -property installationPath' ) do @( call "%%d\VC\Auxiliary\Build\vcvars64.bat" )
130-
IF "%QT_VERSION:~0,1%"=="5" ( dir %Qt5_DIR%\lib\cmake ) ELSE ( dir %Qt6_DIR%\lib\cmake )
130+
IF "%QT_VERSION:~0,1%"=="5" ( dir %Qt5_DIR% ) ELSE ( dir %QT_ROOT_DIR%\lib\cmake )
131131
qmake
132+
cmake -S . -B ./build
132133
shell: cmd
133134

134135
- name: Configure test project on unix
@@ -138,11 +139,12 @@ jobs:
138139
run: |
139140
cd tests/TestWithModules
140141
if [[ $QT_VERSION == 6* ]]; then
141-
ls "$Qt6_DIR/lib/cmake"
142+
ls "${QT_ROOT_DIR}/lib/cmake"
142143
else
143-
ls "$Qt5_DIR/lib/cmake"
144+
ls "${Qt5_DIR}"
144145
fi
145146
qmake
147+
cmake -S . -B ./build
146148
shell: bash
147149

148150
- name: Install source

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ You know what's easier than dealing with that? Just using this:
1010
1111
All done.
1212
13+
## Upgrade Guides
14+
Each new major version of this project includes changes that can break workflows written to use an older version of
15+
this project. These changes are summarized here, to help you upgrade your existing workflows.
16+
17+
[Upgrading `install-qt-action`](README_upgrade_guide.md)
18+
1319
## Options
1420

1521
### `version`
@@ -38,7 +44,7 @@ Possible values: `desktop`, `android`, `ios`, or `winrt`
3844
Default: `desktop`
3945

4046
### `arch`
41-
This is the target architecture that your program will be built for. This is only used for Windows and Android.
47+
This is the target architecture that your program will be built for.
4248

4349
**Linux x86 packages are not supported by this action.** Qt does not offer pre-built Linux x86 packages. Please consider using your distro's repository or building it manually.
4450

@@ -61,7 +67,8 @@ Android: `android_armv7`
6167
### `dir`
6268
This is the directory prefix that Qt will be installed to.
6369

64-
For example, if you set dir to `${{ github.workspace }}/example/`, your bin folder will be located at `$GITHUB_WORKSPACE/example/Qt/5.15.2/{arch}/bin`. When possible, access your Qt directory through the `Qt5_DIR` or `Qt6_DIR` environment variable.
70+
For example, if you set dir to `${{ github.workspace }}/example/`, your bin folder will be located at `$GITHUB_WORKSPACE/example/Qt/5.15.2/{arch}/bin`.
71+
When possible, access your Qt directory through the `QT_ROOT_DIR` environment variable; this will point to `$GITHUB_WORKSPACE/example/Qt/5.15.2/{arch}` in this case.
6572

6673
Default: `$RUNNER_WORKSPACE` (this is one folder above the starting directory)
6774

@@ -214,12 +221,12 @@ Default: `false`
214221

215222
Version of [aqtinstall](https://github.com/miurahr/aqtinstall) to use, given in the format used by pip, for example: `==0.7.1`, `>=0.7.1`, `==0.7.*`. This is intended to be used to troubleshoot any bugs that might be caused or fixed by certain versions of aqtinstall.
216223

217-
Default: `==2.1.*`
224+
Default: `==3.1.*`
218225

219226
### `py7zrversion`
220227
Version of py7zr in the same style as the aqtversion and intended to be used for the same purpose.
221228

222-
Default: `==0.19.*`
229+
Default: `==0.20.*`
223230

224231
### `extra`
225232
This input can be used to append arguments to the end of the aqtinstall command for any special purpose.
@@ -246,17 +253,21 @@ Example value: `--external 7z`
246253
tools: 'tools_ifw tools_qtcreator,qt.tools.qtcreator'
247254
set-env: 'true'
248255
tools-only: 'false'
249-
aqtversion: '==2.1.*'
250-
py7zrversion: '==0.19.*'
256+
aqtversion: '==3.1.*'
257+
py7zrversion: '==0.20.*'
251258
extra: '--external 7z'
252259
```
253260

254261
## More info
255262
For more in-depth and certifiably up-to-date documentation, check the documentation for aqtinstall [here](https://aqtinstall.readthedocs.io/en/latest/getting_started.html).
256263

257-
The Qt bin directory is appended to your `path` environment variable. `Qt5_DIR`/`Qt6_DIR` is also set appropriately for cmake.
264+
The Qt bin directory is appended to your `path` environment variable.
265+
`Qt5_DIR` is also set appropriately for CMake if you are using Qt 5.
258266
In addition, `QT_PLUGIN_PATH`, `QML2_IMPORT_PATH`, `PKG_CONFIG_PATH` and `LD_LIBRARY_PATH` are set accordingly. `IQTA_TOOLS` is set to the "Tools" directory if tools are installed as well.
259267

268+
Since the Qt bin directory is in your `path`, you will not need to set the `CMAKE_PREFIX_PATH` CMake variable.
269+
If you wish to do so, you can set it to either `${QT_ROOT_DIR}` or to `${QT_ROOT_DIR}/lib/cmake`.
270+
260271
Big thanks to the [aqtinstall](https://github.com/miurahr/aqtinstall/) developer for making this easy. Please go support [miurahr](https://github.com/miurahr/aqtinstall), he did all of the hard work here ([his liberapay](https://liberapay.com/miurahr)).
261272

262273
This action is distributed under the [MIT license](LICENSE).

README_upgrade_guide.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Upgrading `install-qt-action`
2+
3+
## Unreleased
4+
* Updated `aqtinstall` to version 3.1.* by default.
5+
* Use the `--autodesktop` flag to automatically install the desktop version of Qt, parallel to any WASM or mobile
6+
versions of Qt 6.2 and above.
7+
* If your action installed Qt 6.2+ for Android or WASM using `install-qt-action@v3`, then your action would have
8+
needed to install the desktop version of Qt alongside the WASM/mobile version of Qt, otherwise it would not have
9+
worked properly. As long as you are using `aqtinstall v3` or higher, the new version of `install-qt-action` will do
10+
that automatically, so you can remove the second step where you add the parallel desktop version of Qt.
11+
If you don't, your workflow will install desktop Qt twice.
12+
* Added the `QT_ROOT_DIR` environment variable that points to the root of the Qt installation.
13+
This variable points to the same directory as the old `Qt5_DIR` and `Qt6_DIR` variables.
14+
* Changed `Qt5_DIR` environment variable, so that it points to `${QT_ROOT_DIR}/lib/cmake`, as required by CMake.
15+
If your action uses this variable for any other purpose, you should update it to use `QT_ROOT_DIR` instead.
16+
* Removed the `Qt5_Dir` and `Qt6_DIR` environment variables, because they are not used by CMake.
17+
If your action uses these variables, you should update them to use `QT_ROOT_DIR` instead.
18+
19+
## v3
20+
* Updated `aqtinstall` to version 2.1.* by default.
21+
See [changelog entry](https://github.com/miurahr/aqtinstall/blob/master/docs/CHANGELOG.rst#v210-14-apr-2022) for details.
22+
* `aqtinstall` v 2.1.0 now checks that the SHA256 checksums reported at https://download.qt.io matches the 7z archives
23+
that it downloads [aqtinstall#493](https://github.com/miurahr/aqtinstall/pull/493).
24+
This change was necessary because the old checksum algorithm, SHA1, is no longer safe to use for this purpose.
25+
Unfortunately, SHA256 checksums are often not available for up to 24 hours after new 7z archives are made available at
26+
https://download.qt.io, and workflows that use `aqtinstall` v 2.1.0 will fail to install Qt properly during that window.
27+
See [aqtinstall#578](https://github.com/miurahr/aqtinstall/issues/578) for further discussion.

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ inputs:
5050
default: false
5151
aqtversion:
5252
description: Version of aqtinstall to use in case of issues
53-
default: ==2.1.*
53+
default: ==3.1.*
5454
py7zrversion:
5555
description: Version of py7zr to use in case of issues
56-
default: ==0.19.*
56+
default: ==0.20.*
5757
extra:
5858
description: Any extra arguments to append to the back
5959
source:

action/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ inputs:
4747
default: false
4848
aqtversion:
4949
description: Version of aqtinstall to use in case of issues
50-
default: ==2.1.*
50+
default: ==3.1.*
5151
py7zrversion:
5252
description: Version of py7zr to use in case of issues
53-
default: ==0.19.*
53+
default: ==0.20.*
5454
extra:
5555
description: Any extra arguments to append to the back
5656
source:

action/src/main.ts

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as process from "process";
55

66
import * as cache from "@actions/cache";
77
import * as core from "@actions/core";
8-
import { exec } from "@actions/exec";
8+
import { exec, getExecOutput } from "@actions/exec";
99

1010
import * as glob from "glob";
1111
import { compare, CompareOperator } from "compare-versions";
@@ -25,9 +25,23 @@ const setOrAppendEnvVar = (name: string, value: string): void => {
2525
core.exportVariable(name, newValue);
2626
};
2727

28-
const execPython = async (command: string, args: readonly string[]): Promise<number> => {
28+
const pythonCommand = (command: string, args: readonly string[]): string => {
2929
const python = process.platform === "win32" ? "python" : "python3";
30-
return exec(`${python} -m ${command} ${args.join(" ")}`);
30+
return `${python} -m ${command} ${args.join(" ")}`;
31+
};
32+
const execPython = async (command: string, args: readonly string[]): Promise<number> => {
33+
return exec(pythonCommand(command, args));
34+
};
35+
36+
const getPythonOutput = async (command: string, args: readonly string[]): Promise<string> => {
37+
// Aqtinstall prints to both stderr and stdout, depending on the command.
38+
// This function assumes we don't care which is which, and we want to see it all.
39+
const out = await getExecOutput(pythonCommand(command, args));
40+
return out.stdout + out.stderr;
41+
};
42+
43+
const flaggedList = (flag: string, listArgs: readonly string[]): string[] => {
44+
return listArgs.length ? [flag, ...listArgs] : [];
3145
};
3246

3347
const flaggedList = (flag: string, listArgs: readonly string[]): string[] => {
@@ -58,6 +72,12 @@ const locateQtArchDir = (installDir: string): string => {
5872
}
5973
};
6074

75+
const isAutodesktopSupported = async (): Promise<boolean> => {
76+
const rawOutput = await getPythonOutput("aqt", ["version"]);
77+
const match = rawOutput.match(/aqtinstall\(aqt\)\s+v(\d+\.\d+\.\d+)/);
78+
return match ? compareVersions(match[1], ">=", "3.0.0") : false;
79+
};
80+
6181
class Inputs {
6282
readonly host: "windows" | "mac" | "linux";
6383
readonly target: "desktop" | "android" | "ios";
@@ -130,7 +150,16 @@ class Inputs {
130150
this.arch = core.getInput("arch");
131151
// Set arch automatically if omitted
132152
if (!this.arch) {
133-
if (this.host === "windows") {
153+
if (this.target === "android") {
154+
if (
155+
compareVersions(this.version, ">=", "5.14.0") &&
156+
compareVersions(this.version, "<", "6.0.0")
157+
) {
158+
this.arch = "android";
159+
} else {
160+
this.arch = "android_armv7";
161+
}
162+
} else if (this.host === "windows") {
134163
if (compareVersions(this.version, ">=", "5.15.0")) {
135164
this.arch = "win64_msvc2019_64";
136165
} else if (compareVersions(this.version, "<", "5.6.0")) {
@@ -140,15 +169,6 @@ class Inputs {
140169
} else {
141170
this.arch = "win64_msvc2017_64";
142171
}
143-
} else if (this.target === "android") {
144-
if (
145-
compareVersions(this.version, ">=", "5.14.0") &&
146-
compareVersions(this.version, "<", "6.0.0")
147-
) {
148-
this.arch = "android";
149-
} else {
150-
this.arch = "android_armv7";
151-
}
152172
}
153173
}
154174

@@ -322,13 +342,18 @@ const run = async (): Promise<void> => {
322342
// Install aqtinstall separately: allows aqtinstall to override py7zr if required
323343
await execPython("pip install", [`"aqtinstall${inputs.aqtVersion}"`]);
324344

345+
// This flag will install a parallel desktop version of Qt, only where required.
346+
// aqtinstall will automatically determine if this is necessary.
347+
const autodesktop = (await isAutodesktopSupported()) ? ["--autodesktop"] : [];
348+
325349
// Install Qt
326350
if (inputs.isInstallQtBinaries) {
327351
const qtArgs = [
328352
inputs.host,
329353
inputs.target,
330354
inputs.version,
331355
...(inputs.arch ? [inputs.arch] : []),
356+
...autodesktop,
332357
...["--outputdir", inputs.dir],
333358
...flaggedList("--modules", inputs.modules),
334359
...flaggedList("--archives", inputs.archives),
@@ -394,13 +419,11 @@ const run = async (): Promise<void> => {
394419
if (process.platform !== "win32") {
395420
setOrAppendEnvVar("PKG_CONFIG_PATH", nativePath(`${qtPath}/lib/pkgconfig`));
396421
}
397-
// If less than qt6, set qt5_dir variable, otherwise set qt6_dir variable
422+
// If less than qt6, set Qt5_DIR variable
398423
if (compareVersions(inputs.version, "<", "6.0.0")) {
399-
core.exportVariable("Qt5_Dir", qtPath); // Incorrect name that was fixed, but kept around so it doesn't break anything
400-
core.exportVariable("Qt5_DIR", qtPath);
401-
} else {
402-
core.exportVariable("Qt6_DIR", qtPath);
424+
core.exportVariable("Qt5_DIR", nativePath(`${qtPath}/lib/cmake`));
403425
}
426+
core.exportVariable("QT_ROOT_DIR", qtPath);
404427
core.exportVariable("QT_PLUGIN_PATH", nativePath(`${qtPath}/plugins`));
405428
core.exportVariable("QML2_IMPORT_PATH", nativePath(`${qtPath}/qml`));
406429
core.addPath(nativePath(`${qtPath}/bin`));
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.1.0)
2+
3+
project(whatspoppin VERSION 1.0.0 LANGUAGES CXX)
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
set(CMAKE_AUTOMOC ON)
9+
set(CMAKE_AUTORCC ON)
10+
set(CMAKE_AUTOUIC ON)
11+
12+
if(CMAKE_VERSION VERSION_LESS "3.7.0")
13+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
14+
endif()
15+
16+
if(DEFINED ENV{Qt5_DIR})
17+
find_package(Qt5 COMPONENTS WebEngineWidgets REQUIRED)
18+
add_executable(whatspoppin main.cpp)
19+
target_link_libraries(whatspoppin Qt5::WebEngineWidgets)
20+
else()
21+
find_package(Qt6 REQUIRED COMPONENTS Core WebEngineWidgets)
22+
qt_standard_project_setup()
23+
add_executable(whatspoppin main.cpp)
24+
target_link_libraries(whatspoppin PRIVATE Qt::WebEngineWidgets Qt6::Core)
25+
endif()
26+

0 commit comments

Comments
 (0)