Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Qt6 builds based on vcpkg #57414

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2ce2c21
Add vcpkg for windows
m-kuhn May 2, 2024
14e6711
use sip build
m-kuhn May 3, 2024
a60d91b
Port native updates
m-kuhn May 3, 2024
0f3e07d
Install flex/bison
m-kuhn May 3, 2024
ea0712f
Wchar
m-kuhn May 3, 2024
a58ffde
Vendored dep fixes
m-kuhn May 3, 2024
07a2323
More bash
m-kuhn May 3, 2024
b77072d
Fix paths
m-kuhn May 3, 2024
2fdef03
Port QgsAttributeTableConfig fix
m-kuhn May 5, 2024
39ced78
Fix QgsExpressionContext
m-kuhn May 5, 2024
6ab1edb
utf16
m-kuhn May 6, 2024
4260974
Bundle and ccache
m-kuhn May 6, 2024
ffc6e54
Define bison output files
m-kuhn May 6, 2024
1be5878
No absolute install paths
m-kuhn May 6, 2024
a1c0d6b
Create zip and fix ccache
m-kuhn May 6, 2024
f6d725e
Install deps
m-kuhn May 9, 2024
23d6c2f
Pin winflexbison
m-kuhn May 10, 2024
b8cfca1
Install qt plugins and qml
m-kuhn May 11, 2024
c9ecaef
Bump baseline
m-kuhn May 13, 2024
2d8a9d1
Consume gdal and swig from python-registry
m-kuhn May 13, 2024
ad03cab
Prepare for merge
m-kuhn May 13, 2024
4ecffc4
Remove unneeded features
m-kuhn May 13, 2024
c380dd4
Fix bad merge
m-kuhn May 13, 2024
3488d7d
Fix indentation
m-kuhn May 13, 2024
117b82a
Allow writing packages
m-kuhn May 13, 2024
152810a
UX
m-kuhn May 13, 2024
0ff6542
Add python dependencies
m-kuhn May 14, 2024
90ee3db
Update comment
m-kuhn May 15, 2024
9332fba
Update windows-qt6.yml
m-kuhn May 16, 2024
f9d44d7
Create sdk
m-kuhn Jun 2, 2024
a8dda99
Absolute path
m-kuhn Jun 3, 2024
77589b6
Update windows-qt6.yml
m-kuhn Jun 3, 2024
10f26a9
Debug
m-kuhn Jun 3, 2024
296bd9f
Fix sdk export
m-kuhn Jun 5, 2024
ad6725b
Fix param
m-kuhn Jun 8, 2024
c23690c
Update windows-qt6.yml
m-kuhn Jun 8, 2024
67e58ae
Bump cmake version
m-kuhn Jun 29, 2024
6e24900
Add more python deps
m-kuhn Jun 30, 2024
b22291b
relative
m-kuhn Jun 30, 2024
1c7c16a
Add sdk support
m-kuhn Jun 30, 2024
a10ee78
Complain if toolchain is not around
m-kuhn Jun 30, 2024
d0b36a8
More robust sip version check
m-kuhn Jul 1, 2024
ffedc33
Improve docs
m-kuhn Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/actions/setup-vcpkg/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Setup Vcpkg
description: Initialize vcpkg tool, does not checkout the registry
# TODO, set VCPKG_BASE_VERSION based on this
# inputs:
# vcpkg-version:
# description: Enter vcpkg version tag or stable or latest
# required: false
# default: latest
# type: string

runs:
using: composite
steps:
- name: Setup vcpkg
if: runner.os != 'Windows'
shell: bash
run: |
. <(curl https://aka.ms/vcpkg-init.sh -L)
echo "PATH=$VCPKG_ROOT;$PATH" >> $GITHUB_ENV

- name: Setup vcpkg
if: runner.os == 'Windows'
shell: powershell
run: |
$env:VCPKG_ROOT = "C:/.vcpkg"
iex (iwr -useb https://aka.ms/vcpkg-init.ps1)
echo "VCPKG_ROOT=$env:VCPKG_ROOT" >> $env:GITHUB_ENV
echo "PATH=$env:VCPKG_ROOT;$env:PATH" >> $env:GITHUB_ENV
103 changes: 43 additions & 60 deletions .github/workflows/build_artifact_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Write build artifact comments

on:
workflow_run:
workflows: [🪟 MingW64 Windows 64bit Build]
workflows:
- "🪟 MingW64 Windows 64bit Build"
- "🪟 Windows Qt6"
types:
- completed

Expand All @@ -11,7 +13,6 @@ permissions:

jobs:
on-success:

permissions:
pull-requests: write

Expand All @@ -22,86 +23,68 @@ jobs:
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "QGIS for Windows 64bit"
const artifactName = context.payload.workflow_run.name.includes("MingW64") ? "QGIS for Windows 64bit" : "qgis-windows-qt6";
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
if (matchArtifacts.length>0)
{
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifacts[0].id,
archive_format: 'zip',
const artifact = artifacts.data.artifacts.find(a => a.name == artifactName);
if (artifact) {
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/QGIS for Windows 64bit.zip`, Buffer.from(download.data));
core.setOutput('artifact_id', matchArtifacts[0].id);
}
else
{
core.setOutput('artifact_id', 0);
}
let matchArtifactsDebugSymbols = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "QGIS for Windows 64bit Debug Symbols"
});
if (matchArtifactsDebugSymbols.length>0)
{
core.setOutput('debug_symbols_artifact_id', matchArtifactsDebugSymbols[0].id);
}
else
{
core.setOutput('debug_symbols_artifact_id', 0);
const fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}`, Buffer.from(download.data));
core.setOutput('artifact_url', `${context.repo.owner}/${context.repo.repo}/suites/${context.payload.workflow_run.check_suite_id}/artifacts/${artifact.id}`);
} else {
core.setOutput('artifact_url', '');
}

- name: 'Unzip artifact'
if: fromJSON(steps.download_artifact.outputs.artifact_id) > 0
run: |
unzip "QGIS for Windows 64bit.zip"
unzip -j qgis-portable-win64.zip pr_number git_commit

- name: 'Post artifact download link as comment on PR'
if: fromJSON(steps.download_artifact.outputs.artifact_id) > 0
- name: 'Post or update PR comment'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let issue_number = Number(fs.readFileSync('./pr_number'));
let git_sha = String(fs.readFileSync('./git_commit')).trim();
const fs = require('fs');
const issue_number = Number(fs.readFileSync('./pr_number'));
const git_sha = String(fs.readFileSync('./git_commit')).trim();
const artifactUrl = steps.download_artifact.outputs.artifact_url;
const buildType = context.payload.workflow_run.name.includes("MingW64") ? "Windows" : "Qt6";
const bodyPart = artifactUrl ? `${buildType} builds of this PR are available for testing [here](https://github.com/${artifactUrl}).` : `${buildType} build N/A`;

const prComments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
});
const PREFIX = "## 🪟 Windows builds ready!";
let body = PREFIX + "\n\n" +
"Windows builds of this PR are available for testing [here](https://github.com/" + context.repo.owner + "/" + context.repo.repo + "/suites/" + context.payload.workflow_run.check_suite_id + "/artifacts/${{steps.download_artifact.outputs.artifact_id}}).";
if ( ${{steps.download_artifact.outputs.debug_symbols_artifact_id}} > 0 )
{
body += " Debug symbols for this build are available [here](https://github.com/" + context.repo.owner + "/" + context.repo.repo + "/suites/" + context.payload.workflow_run.check_suite_id + "/artifacts/${{steps.download_artifact.outputs.debug_symbols_artifact_id}}).";
}
body += "\n\n*(Built from commit " + git_sha + ")*";
const commentPrefix = "## 🪟 Build Details";
const existingComment = prComments.data.find(comment => comment.body.startsWith(commentPrefix));
let newBody;

const winBuildComment = prComments.data?.find(c => c.body.startsWith(PREFIX));
if (!!winBuildComment) {
// update the existing comment
if (existingComment) {
const regex = new RegExp(`(## ${buildType} builds ready![\\s\\S]*?)(?=(## (Windows|Qt6) builds ready!|$))`, "g");
const replacement = `## ${buildType} builds ready!\n\n${bodyPart}\n\n`;
if (existingComment.body.includes(`## ${buildType} builds ready!`)) {
newBody = existingComment.body.replace(regex, replacement);
} else {
newBody = existingComment.body + replacement;
}
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: winBuildComment.id,
body: body
comment_id: existingComment.id,
body: newBody
});
} else {
// submit a new comment
newBody = `${commentPrefix}\n\n${replacement}\n\n*(Built from commit ${git_sha})*`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: body
body: newBody
});
}
132 changes: 132 additions & 0 deletions .github/workflows/windows-qt6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
name: 🪟 Windows Qt6
on:
push:
branches:
- master
- release-**
pull_request:
release:
types: ['published']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
packages: write

jobs:
build:
name: build (windows)
runs-on: windows-2022

steps:
- name: 🐣 Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: 🐩 Install CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.29.6

- name: 🧽 Developer Command Prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1

- name: 🎡 Setup vcpkg
uses: ./.github/actions/setup-vcpkg

- name: 🦬 Setup flex/bison
uses: robinraju/[email protected]
with:
repository: 'lexxmark/winflexbison'
fileName: '*.zip'
tag: 'v2.5.24'
extract: true

- name: 🛍️ Setup ccache
uses: hendrikmuhs/[email protected]
with:
max-size: 1G

- name: 🌱 Install dependencies and generate project files
shell: bash
run: |
BUILD_DIR=$( cygpath "${{ github.workspace }}/build" )
SOURCE_DIR=$( cygpath "${{ github.workspace }}" )

cmake -S "${SOURCE_DIR}" \
-B "${BUILD_DIR}" \
-G Ninja \
-D CMAKE_BUILD_TYPE=Release \
-D WITH_VCPKG=ON \
-D CREATE_ZIP=ON \
-D VCPKG_TARGET_TRIPLET=x64-windows-release \
-D VCPKG_HOST_TRIPLET=x64-windows-release \
-D WITH_DESKTOP=ON \
-D WITH_3D=ON \
-D WITH_BINDINGS=ON \
-D ENABLE_TESTS=OFF \
-D BUILD_WITH_QT6=ON \
-D USE_CCACHE=ON \
-D FLEX_EXECUTABLE="${SOURCE_DIR}/win_flex.exe" \
-D BISON_EXECUTABLE="${SOURCE_DIR}/win_bison.exe" \
-D SIP_BUILD_EXECUTABLE="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\Scripts\sip-build.exe" \
-D PYUIC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyuic5.bat" \
-D PYRCC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyrcc5.bat" \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D WITH_QTWEBKIT=OFF \
-D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \
-D NUGET_USERNAME=${{ github.actor }} \
-D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }}

- name: 🌋 Build
shell: bash
run: |
cmake --build "${{ github.workspace }}/build" --config Release

- uses: m-kuhn/action-tmate@patch-1
if: failure()

- name: 📦 Package
shell: bash
run: |
cmake --build "${{ github.workspace }}/build" --target bundle --config Release

- name: 📦 Create SDK
# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release'
run: |
vcpkg.exe export --zip --output-dir=./sdk --x-install-root=./build/vcpkg_installed --x-manifest-root=vcpkg

- name: 📤 Upload sdk
# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release'
uses: actions/upload-artifact@v4
with:
name: qgis-sdk-x64-windows
path: |
sdk/vcpkg-export-*.zip

- name: 📑 Upload dep build logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-logs-x64-windows
path: |
C:/src/**/*.log

- name: Save PR number to zips
run: |
echo ${{ github.event.number }} | tee pr_number
powershell Compress-Archive -update pr_number *-win64.zip
echo ${{ github.event.pull_request.head.sha }} | tee git_commit
powershell Compress-Archive -update git_commit *-win64.zip

- name: 📤 Upload bundle
uses: actions/upload-artifact@v4
with:
name: qgis-windows-qt6
path: |
build/*-win64.zip
Loading
Loading