Skip to content

Commit 51b9abd

Browse files
committed
Try to build v4
1 parent 0639a65 commit 51b9abd

File tree

3 files changed

+1576
-22
lines changed

3 files changed

+1576
-22
lines changed

action/lib/main.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ const setOrAppendEnvVar = (name, value) => {
5353
}
5454
core.exportVariable(name, newValue);
5555
};
56-
const execPython = (command, args) => __awaiter(void 0, void 0, void 0, function* () {
56+
const pythonCommand = (command, args) => {
5757
const python = process.platform === "win32" ? "python" : "python3";
58-
return (0, exec_1.exec)(`${python} -m ${command} ${args.join(" ")}`);
58+
return `${python} -m ${command} ${args.join(" ")}`;
59+
};
60+
const execPython = (command, args) => __awaiter(void 0, void 0, void 0, function* () {
61+
return (0, exec_1.exec)(pythonCommand(command, args));
62+
});
63+
const getPythonOutput = (command, args) => __awaiter(void 0, void 0, void 0, function* () {
64+
// Aqtinstall prints to both stderr and stdout, depending on the command.
65+
// This function assumes we don't care which is which, and we want to see it all.
66+
const out = yield (0, exec_1.getExecOutput)(pythonCommand(command, args));
67+
return out.stdout + out.stderr;
5968
});
6069
const flaggedList = (flag, listArgs) => {
6170
return listArgs.length ? [flag, ...listArgs] : [];
@@ -82,6 +91,11 @@ const locateQtArchDir = (installDir) => {
8291
return qtArchDirs[0];
8392
}
8493
};
94+
const isAutodesktopSupported = () => __awaiter(void 0, void 0, void 0, function* () {
95+
const rawOutput = yield getPythonOutput("aqt", ["version"]);
96+
const match = rawOutput.match(/aqtinstall\(aqt\)\s+v(\d+\.\d+\.\d+)/);
97+
return match ? compareVersions(match[1], ">=", "3.0.0") : false;
98+
});
8599
class Inputs {
86100
constructor() {
87101
const host = core.getInput("host");
@@ -124,7 +138,16 @@ class Inputs {
124138
this.arch = core.getInput("arch");
125139
// Set arch automatically if omitted
126140
if (!this.arch) {
127-
if (this.host === "windows") {
141+
if (this.target === "android") {
142+
if (compareVersions(this.version, ">=", "5.14.0") &&
143+
compareVersions(this.version, "<", "6.0.0")) {
144+
this.arch = "android";
145+
}
146+
else {
147+
this.arch = "android_armv7";
148+
}
149+
}
150+
else if (this.host === "windows") {
128151
if (compareVersions(this.version, ">=", "5.15.0")) {
129152
this.arch = "win64_msvc2019_64";
130153
}
@@ -138,15 +161,6 @@ class Inputs {
138161
this.arch = "win64_msvc2017_64";
139162
}
140163
}
141-
else if (this.target === "android") {
142-
if (compareVersions(this.version, ">=", "5.14.0") &&
143-
compareVersions(this.version, "<", "6.0.0")) {
144-
this.arch = "android";
145-
}
146-
else {
147-
this.arch = "android_armv7";
148-
}
149-
}
150164
}
151165
const dir = core.getInput("dir") || process.env.RUNNER_WORKSPACE;
152166
if (!dir) {
@@ -297,13 +311,17 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
297311
yield execPython("pip install", ["setuptools", "wheel", `"py7zr${inputs.py7zrVersion}"`]);
298312
// Install aqtinstall separately: allows aqtinstall to override py7zr if required
299313
yield execPython("pip install", [`"aqtinstall${inputs.aqtVersion}"`]);
314+
// This flag will install a parallel desktop version of Qt, only where required.
315+
// aqtinstall will automatically determine if this is necessary.
316+
const autodesktop = (yield isAutodesktopSupported()) ? ["--autodesktop"] : [];
300317
// Install Qt
301318
if (inputs.isInstallQtBinaries) {
302319
const qtArgs = [
303320
inputs.host,
304321
inputs.target,
305322
inputs.version,
306323
...(inputs.arch ? [inputs.arch] : []),
324+
...autodesktop,
307325
...["--outputdir", inputs.dir],
308326
...flaggedList("--modules", inputs.modules),
309327
...flaggedList("--archives", inputs.archives),
@@ -359,14 +377,11 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
359377
if (process.platform !== "win32") {
360378
setOrAppendEnvVar("PKG_CONFIG_PATH", nativePath(`${qtPath}/lib/pkgconfig`));
361379
}
362-
// If less than qt6, set qt5_dir variable, otherwise set qt6_dir variable
380+
// If less than qt6, set Qt5_DIR variable
363381
if (compareVersions(inputs.version, "<", "6.0.0")) {
364-
core.exportVariable("Qt5_Dir", qtPath); // Incorrect name that was fixed, but kept around so it doesn't break anything
365-
core.exportVariable("Qt5_DIR", qtPath);
366-
}
367-
else {
368-
core.exportVariable("Qt6_DIR", qtPath);
382+
core.exportVariable("Qt5_DIR", nativePath(`${qtPath}/lib/cmake`));
369383
}
384+
core.exportVariable("QT_ROOT_DIR", qtPath);
370385
core.exportVariable("QT_PLUGIN_PATH", nativePath(`${qtPath}/plugins`));
371386
core.exportVariable("QML2_IMPORT_PATH", nativePath(`${qtPath}/qml`));
372387
core.addPath(nativePath(`${qtPath}/bin`));

0 commit comments

Comments
 (0)