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

Mac Qt6 Builds #59177

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions .github/actions/setup-vcpkg/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ runs:
if: runner.os != 'Windows'
shell: bash
run: |
. <(curl https://aka.ms/vcpkg-init.sh -L)
export VCPKG_ROOT=$HOME/.vcpkg
wget https://aka.ms/vcpkg-init.sh -O /tmp/vcpkg-init.sh
. /tmp/vcpkg-init.sh
echo "VCPKG_ROOT=$VCPKG_ROOT" >> $GITHUB_ENV
echo "PATH=$VCPKG_ROOT;$PATH" >> $GITHUB_ENV
# Integrate patch from https://github.com/microsoft/vcpkg/pull/41146
wget https://raw.githubusercontent.com/microsoft/vcpkg/6271c9bfab7ff6dbf3444c3600a28e7c6b0ea462/scripts/cmake/z_vcpkg_fixup_rpath_macho.cmake -O /Users/runner/.vcpkg/scripts/cmake/z_vcpkg_fixup_rpath_macho.cmake
- name: Setup vcpkg
if: runner.os == 'Windows'
Expand All @@ -25,4 +30,4 @@ runs:
$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
echo "PATH=$env:VCPKG_ROOT;$env:PATH" >> $env:GITHUB_ENV
49 changes: 49 additions & 0 deletions .github/actions/vcpkg_update_report/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Compare vcpkg install changes
description: Compares vcpkg install outputs between the base and head refs on pull requests and generates a report.

inputs:
vcpkg-manifest-dir:
description: 'Directory containing the vcpkg.json manifest'
required: true
default: '.'
type: string
triplet:
description: 'Triplet to use for vcpkg installation'
required: true
default: 'x64-linux'
type: string

outputs:
report:
description: 'The report of added and removed packages after vcpkg installation comparison'
value: ${{ steps.compare.outputs.report }}

runs:
using: "composite"
steps:
# Run vcpkg install --dry-run on the head ref
- name: Run vcpkg install (HEAD)
shell: bash
run: |
vcpkg install --dry-run --triplet ${{ inputs.triplet }} --x-manifest-root=${{ inputs.vcpkg-manifest-dir }} > /tmp/vcpkg-head-output.txt

# Run vcpkg install --dry-run on the base ref
- name: Run vcpkg install (BASE)
shell: bash
run: |
git worktree add .base-ref ${{ github.event.pull_request.base.sha }}
vcpkg install --dry-run --triplet ${{ inputs.triplet }} --x-manifest-root=.base-ref/${{ inputs.vcpkg-manifest-dir }} > /tmp/vcpkg-base-output.txt


# Compare the outputs and generate a report
- name: Compare vcpkg outputs
shell: bash
id: compare
run: |
python3 ${GITHUB_ACTION_PATH}/vcpkg-diff.py > /tmp/vcpkg-report.txt
cat /tmp/vcpkg-report.txt
{
echo 'report<<EOF'
cat /tmp/vcpkg-report.txt
echo EOF
} >> "$GITHUB_OUTPUT"
101 changes: 101 additions & 0 deletions .github/actions/vcpkg_update_report/vcpkg-diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import re


def extract_packages(data):
"""
Extract package name, triplet, version, and features information from the file content.
"""
packages = {}
lines = data.strip().split("\n")
for line in lines:
# Regex to match the package format and capture features inside brackets
match = re.match(
r"\s*\*\s+([^\[\]:]+)(?:\[(.*?)\])?:([^\[\]@]+)@([^\s]+)\s+--", line
)
if match:
package_name = match.group(1)
features = match.group(2) if match.group(2) else ""
triplet = match.group(3)
version = match.group(4)
features_list = (
[feature.strip() for feature in features.split(",")] if features else []
)
packages[package_name] = (triplet, version, features_list)
return packages


def compare_features(features1, features2):
"""
Compare two feature lists and return the differences.
"""
added_features = set(features2) - set(features1)
removed_features = set(features1) - set(features2)
return added_features, removed_features


def generate_report(file1_content, file2_content):
# Extract package information from both files
file1_packages = extract_packages(file1_content)
file2_packages = extract_packages(file2_content)

added = []
removed = []
updated = []

# Identify removed and updated packages
for pkg in file1_packages:
if pkg not in file2_packages:
removed.append(pkg)
else:
# Compare version and features
triplet1, version1, features1 = file1_packages[pkg]
triplet2, version2, features2 = file2_packages[pkg]
updated_parts = []
if version1 != version2 or triplet1 != triplet2:
updated_parts.append(f"{version1} -> {version2}")
added_features, removed_features = compare_features(features1, features2)
if added_features:
updated_parts.append("+" + ", ".join(added_features))
if removed_features:
updated_parts.append("-" + ", ".join(removed_features))
if updated_parts:
updated.append(f"{pkg}: " + " ".join(updated_parts))

# Identify added packages
for pkg in file2_packages:
if pkg not in file1_packages:
added.append(pkg)

# Print the report
if added:
print("**Added packages:**")
for pkg in added:
triplet, version, features = file2_packages[pkg]
print(f" 🍓 {pkg}: {version} (Features: {', '.join(features)})")

if removed:
print("\n**Removed packages:**")
for pkg in removed:
triplet, version, features = file1_packages[pkg]
print(f" 🍄 {pkg}: {version} (Features: {', '.join(features)})")

if updated:
print("\n**Updated packages:**")
for pkg in updated:
print(f" 🍇 {pkg}")


def read_file(file_path):
"""
Read the content of a file.
"""
with open(file_path, "r") as file:
return file.read()


# Read files
file1_content = read_file("/tmp/vcpkg-base-output.txt")
file2_content = read_file("/tmp/vcpkg-head-output.txt")

# Generate the report
generate_report(file1_content, file2_content)
108 changes: 108 additions & 0 deletions .github/workflows/build-macos-qt6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
name: 🍎 Build - MacOS Qt6
on:
push:
branches:
- main
pull_request:
release:
types: ['published']
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
include:
# - os: macos-13
# triplet: x64-osx
# deployment-target: "10.15"
- os: macos-14
triplet: arm64-osx-dynamic-release
deployment-target: "11.0"
name: build (macos)
runs-on: ${{ matrix.os }}

steps:
- name: 🐣 Checkout
uses: actions/checkout@v4

- name: 🐩 Install CMake and Ninja
uses: lukka/get-cmake@latest
with:
# Pin to specific version to avoid rebuilding too often
# Also helps to avoid spurious build failures like https://github.com/qgis/QGIS/pull/47098
cmakeVersion: 3.30.4

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

- name: 🔨 Prepare build env
run: |
brew install automake bison flex gnu-sed create-dmg autoconf-archive nasm libtool fdupes
echo $(brew --prefix bison)/bin >> $GITHUB_PATH
echo $(brew --prefix flex)/bin >> $GITHUB_PATH
echo $(brew --prefix libtool)/bin >> $GITHUB_PATH

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: 🍭 Setup XCode
uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: latest-stable

- name: 🌱 Install dependencies and generate project files
run: |
echo "VCPKG_ROOT: ${VCPKG_ROOT}"

# Install first only with binarycaching, then deduplicate binaries and replace copies with symlinks.
# Nuget doesn't understand the symlink concept
cmake -S . \
-G Ninja \
-B build \
-D WITH_VCPKG=ON \
-D BUILD_WITH_QT6=ON \
-D WITH_QTWEBKIT=OFF \
-D WITH_BINDINGS=ON \
-D QGIS_MACAPP_FRAMEWORK=OFF \
-D VCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
-D VCPKG_HOST_TRIPLET="${{ matrix.triplet }}" \
-D VCPKG_INSTALL_OPTIONS="--only-binarycaching" \
-D NUGET_USERNAME=${{ github.actor }} \
-D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} || true

fdupes -r -1 build/vcpkg_installed/arm64-osx-dynamic/lib | grep libQt | while read line; do master=""; for file in ${line[*]}; do if [[ "x${master}" == "x" ]]; then master=$file; else rm "${file}"; ln -s $(basename "${master}") "${file}"; fi; done; done

cmake -D VCPKG_INSTALL_OPTIONS="" build

- name: 📑 Upload vcpkg build logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: build-logs-${{ matrix.triplet }}
path: |
${{ env.VCPKG_ROOT }}/buildtrees/**/*.log

- name: 📦 Create SDK
if: github.event_name == 'workflow_dispatch' || github.event_name == 'release'
run: |
./build/_deps/vcpkg-src/vcpkg 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: kadas-albireo2-sdk-${{ matrix.triplet }}
path: |
sdk/vcpkg-export-*.zip

- name: 🌋 Build
run: |
cmake --build build
1 change: 1 addition & 0 deletions .github/workflows/build_artifact_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
workflows:
- 🪟 MingW64 Windows 64bit Build
- 🪟 Windows Qt6
- 🧮 Vcpkg report
types:
- completed

Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/vcpkg-update-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: 🧮 Vcpkg report
on:
pull_request:
paths:
- 'vcpkg/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
vcpkg-check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 30

- name: Generate diff report
id: vcpkg_diff
uses: ./.github/actions/vcpkg_update_report
with:
vcpkg-manifest-dir: vcpkg
triplet: x64-linux

- name: Schedule report comment
uses: ./.github/actions/post_sticky_comment
if: github.event_name == 'pull_request'
with:
marker: vcpkg-report
body: |
### 🧮 Vcpkg update report
${{ steps.vcpkg_diff.outputs.report }}
pr: ${{ github.event.number }}
17 changes: 13 additions & 4 deletions cmake/VcpkgToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ if(WITH_GUI)
list(APPEND VCPKG_MANIFEST_FEATURES "gui")
endif()

# Setup binary cache
if(NOT "${NUGET_TOKEN}" STREQUAL "" AND WIN32)
set(_VCPKG_EXECUTABLE "vcpkg.exe")
# Binarycache can only be used on Windows or if mono is available.
find_program(_VCPKG_MONO mono)
if(NOT "${NUGET_TOKEN}" STREQUAL "" AND (_HOST_IS_WINDOWS OR EXISTS "${_VCPKG_MONO}"))
if(_HOST_IS_WINDOWS)
set(_VCPKG_EXECUTABLE "$ENV{VCPKG_ROOT}/vcpkg.exe")
else()
set(_VCPKG_EXECUTABLE "$ENV{VCPKG_ROOT}/vcpkg")
endif()

execute_process(
COMMAND ${_VCPKG_EXECUTABLE} fetch nuget
Expand All @@ -24,7 +29,11 @@ if(NOT "${NUGET_TOKEN}" STREQUAL "" AND WIN32)
STRING(REGEX REPLACE "\n" ";" _FETCH_NUGET_OUTPUT "${_FETCH_NUGET_OUTPUT}")
list(GET _FETCH_NUGET_OUTPUT -1 _NUGET_PATH)

set(_NUGET_EXE ${_NUGET_PATH})
if(_HOST_IS_WINDOWS)
set(_NUGET_EXE ${_NUGET_PATH})
else()
set(_NUGET_EXE ${_VCPKG_MONO} ${_NUGET_PATH})
endif()

set(_CONFIG_PATH "${CMAKE_BINARY_DIR}/github-NuGet.Config")

Expand Down
8 changes: 7 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,13 @@ if (ANDROID)
# require c++17
target_compile_features(${QGIS_APP_NAME} PRIVATE cxx_std_17)
else()
add_executable(${QGIS_APP_NAME} MACOSX_BUNDLE WIN32 ${QGIS_APPMAIN_SRCS})
if(APPLE)
set (CREATE_MACOSX_BUNDLE TRUE CACHE BOOL "Create macosx bundle during build. Disable for development to avoid copying libraries and ease debugging.")
if(CREATE_MACOSX_BUNDLE)
set(MACOSX_BUNDLE "MACOSX_BUNDLE")
endif()
endif()
add_executable(${QGIS_APP_NAME} ${MACOSX_BUNDLE} WIN32 ${QGIS_APPMAIN_SRCS})

if(MSVC AND BUILD_WITH_QT6)
qt_disable_unicode_defines(${QGIS_APP_NAME})
Expand Down
Loading
Loading