Skip to content

Commit 41f1994

Browse files
committed
Add centralized build configuration
Create single source of truth for build toolchain versions in .github/build-config.json, eliminating hardcoded versions across CI workflows, setup scripts, CMake, and Docker files. New files: - .github/build-config.json - Centralized version configuration - .github/actions/build-config/action.yml - GitHub Action to read config - cmake/BuildConfig.cmake - CMake module to parse JSON config - tools/setup/read-config.sh - Bash helper (jq + Python fallback) - tools/setup/read-config.ps1 - PowerShell helper Updated to use centralized config: - CMake: CustomOptions, FindGStreamer, Android platform, gstqml6gl - Docker: Dockerfile-build-ubuntu, Dockerfile-build-android - Deploy: appimagecraft.yml, Vagrantfile, .vagrantconfig.yml - Scripts: install-dependencies-*, install-qt-* Key improvements: - No hardcoded fallback defaults in action.yml (config is authoritative) - Added ndk_full_version for simplified Docker builds - Simplified Dockerfile NDK version handling - Version-agnostic comments throughout
1 parent a808b15 commit 41f1994

File tree

21 files changed

+671
-97
lines changed

21 files changed

+671
-97
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Build Config
2+
description: Read build toolchain versions from .github/build-config.json
3+
4+
outputs:
5+
qt_version:
6+
description: Qt version
7+
value: ${{ steps.read.outputs.qt_version }}
8+
qt_minimum_version:
9+
description: Qt minimum supported version
10+
value: ${{ steps.read.outputs.qt_minimum_version }}
11+
qt_modules:
12+
description: Qt modules (desktop)
13+
value: ${{ steps.read.outputs.qt_modules }}
14+
qt_modules_ios:
15+
description: Qt modules (iOS, excludes qtserialport/qtscxml)
16+
value: ${{ steps.read.outputs.qt_modules_ios }}
17+
gstreamer_version:
18+
description: GStreamer version (macOS/Linux)
19+
value: ${{ steps.read.outputs.gstreamer_version }}
20+
gstreamer_android_version:
21+
description: GStreamer version (Android)
22+
value: ${{ steps.read.outputs.gstreamer_android_version }}
23+
gstreamer_windows_version:
24+
description: GStreamer version (Windows)
25+
value: ${{ steps.read.outputs.gstreamer_windows_version }}
26+
ndk_version:
27+
description: Android NDK version (short form)
28+
value: ${{ steps.read.outputs.ndk_version }}
29+
ndk_full_version:
30+
description: Android NDK version (full form for sdkmanager)
31+
value: ${{ steps.read.outputs.ndk_full_version }}
32+
java_version:
33+
description: Java version
34+
value: ${{ steps.read.outputs.java_version }}
35+
android_platform:
36+
description: Android platform/API level
37+
value: ${{ steps.read.outputs.android_platform }}
38+
android_min_sdk:
39+
description: Android minimum SDK version
40+
value: ${{ steps.read.outputs.android_min_sdk }}
41+
android_build_tools:
42+
description: Android build tools version
43+
value: ${{ steps.read.outputs.android_build_tools }}
44+
android_cmdline_tools:
45+
description: Android command line tools version
46+
value: ${{ steps.read.outputs.android_cmdline_tools }}
47+
xcode_version:
48+
description: Xcode version (macOS)
49+
value: ${{ steps.read.outputs.xcode_version }}
50+
xcode_ios_version:
51+
description: Xcode version (iOS)
52+
value: ${{ steps.read.outputs.xcode_ios_version }}
53+
cmake_minimum_version:
54+
description: CMake minimum version
55+
value: ${{ steps.read.outputs.cmake_minimum_version }}
56+
ccache_version:
57+
description: ccache version
58+
value: ${{ steps.read.outputs.ccache_version }}
59+
ccache_max_size:
60+
description: ccache max cache size
61+
value: ${{ steps.read.outputs.ccache_max_size }}
62+
clang_format_version:
63+
description: clang-format version
64+
value: ${{ steps.read.outputs.clang_format_version }}
65+
node_version:
66+
description: Node.js version
67+
value: ${{ steps.read.outputs.node_version }}
68+
flatpak_gnome_version:
69+
description: GNOME version for Flatpak
70+
value: ${{ steps.read.outputs.flatpak_gnome_version }}
71+
72+
runs:
73+
using: composite
74+
steps:
75+
- name: Validate and read build config
76+
id: read
77+
shell: bash
78+
run: |
79+
CONFIG_FILE="${GITHUB_WORKSPACE}/.github/build-config.json"
80+
if [[ ! -f "$CONFIG_FILE" ]]; then
81+
echo "::error::Build config not found: $CONFIG_FILE"
82+
exit 1
83+
fi
84+
if ! jq empty "$CONFIG_FILE" 2>/dev/null; then
85+
echo "::error::Invalid JSON in $CONFIG_FILE"
86+
exit 1
87+
fi
88+
89+
# Read all values (no fallbacks - config is authoritative)
90+
QT_VERSION=$(jq -r '.qt_version' "$CONFIG_FILE")
91+
QT_MIN_VERSION=$(jq -r '.qt_minimum_version' "$CONFIG_FILE")
92+
QT_MODULES=$(jq -r '.qt_modules' "$CONFIG_FILE")
93+
QT_MODULES_IOS=$(echo "$QT_MODULES" | sed 's/qtserialport//g; s/qtscxml//g; s/ */ /g; s/^ *//; s/ *$//')
94+
GST_VERSION=$(jq -r '.gstreamer_version' "$CONFIG_FILE")
95+
GST_ANDROID_VERSION=$(jq -r '.gstreamer_android_version' "$CONFIG_FILE")
96+
GST_WIN_VERSION=$(jq -r '.gstreamer_windows_version' "$CONFIG_FILE")
97+
NDK_VERSION=$(jq -r '.ndk_version' "$CONFIG_FILE")
98+
NDK_FULL_VERSION=$(jq -r '.ndk_full_version' "$CONFIG_FILE")
99+
JAVA_VERSION=$(jq -r '.java_version' "$CONFIG_FILE")
100+
ANDROID_PLATFORM=$(jq -r '.android_platform' "$CONFIG_FILE")
101+
ANDROID_MIN_SDK=$(jq -r '.android_min_sdk' "$CONFIG_FILE")
102+
ANDROID_BUILD_TOOLS=$(jq -r '.android_build_tools' "$CONFIG_FILE")
103+
ANDROID_CMDLINE_TOOLS=$(jq -r '.android_cmdline_tools' "$CONFIG_FILE")
104+
XCODE_VERSION=$(jq -r '.xcode_version' "$CONFIG_FILE")
105+
XCODE_IOS_VERSION=$(jq -r '.xcode_ios_version' "$CONFIG_FILE")
106+
CMAKE_MIN_VERSION=$(jq -r '.cmake_minimum_version' "$CONFIG_FILE")
107+
CCACHE_VERSION=$(jq -r '.ccache_version' "$CONFIG_FILE")
108+
CCACHE_MAX_SIZE=$(jq -r '.ccache_max_size' "$CONFIG_FILE")
109+
CLANG_FORMAT_VERSION=$(jq -r '.clang_format_version' "$CONFIG_FILE")
110+
NODE_VERSION=$(jq -r '.node_version' "$CONFIG_FILE")
111+
FLATPAK_GNOME_VERSION=$(jq -r '.flatpak_gnome_version' "$CONFIG_FILE")
112+
113+
{
114+
echo "qt_version=$QT_VERSION"
115+
echo "qt_minimum_version=$QT_MIN_VERSION"
116+
echo "qt_modules=$QT_MODULES"
117+
echo "qt_modules_ios=$QT_MODULES_IOS"
118+
echo "gstreamer_version=$GST_VERSION"
119+
echo "gstreamer_android_version=$GST_ANDROID_VERSION"
120+
echo "gstreamer_windows_version=$GST_WIN_VERSION"
121+
echo "ndk_version=$NDK_VERSION"
122+
echo "ndk_full_version=$NDK_FULL_VERSION"
123+
echo "java_version=$JAVA_VERSION"
124+
echo "android_platform=$ANDROID_PLATFORM"
125+
echo "android_min_sdk=$ANDROID_MIN_SDK"
126+
echo "android_build_tools=$ANDROID_BUILD_TOOLS"
127+
echo "android_cmdline_tools=$ANDROID_CMDLINE_TOOLS"
128+
echo "xcode_version=$XCODE_VERSION"
129+
echo "xcode_ios_version=$XCODE_IOS_VERSION"
130+
echo "cmake_minimum_version=$CMAKE_MIN_VERSION"
131+
echo "ccache_version=$CCACHE_VERSION"
132+
echo "ccache_max_size=$CCACHE_MAX_SIZE"
133+
echo "clang_format_version=$CLANG_FORMAT_VERSION"
134+
echo "node_version=$NODE_VERSION"
135+
echo "flatpak_gnome_version=$FLATPAK_GNOME_VERSION"
136+
} >> "$GITHUB_OUTPUT"
137+
138+
# Only set commonly-used variables as environment variables to avoid polluting the env.
139+
# All values are available as step outputs (e.g., steps.config.outputs.ndk_version).
140+
- name: Set environment variables
141+
shell: bash
142+
run: |
143+
echo "QT_VERSION=${{ steps.read.outputs.qt_version }}" >> "$GITHUB_ENV"
144+
echo "GSTREAMER_VERSION=${{ steps.read.outputs.gstreamer_version }}" >> "$GITHUB_ENV"

.github/build-config.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"qt_version": "6.10.1",
3+
"qt_minimum_version": "6.10.0",
4+
"qt_modules": "qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors qtscxml",
5+
6+
"gstreamer_version": "1.24.13",
7+
"gstreamer_android_version": "1.22.12",
8+
"gstreamer_windows_version": "1.22.12",
9+
10+
"ndk_version": "r27c",
11+
"ndk_full_version": "27.2.12829759",
12+
"java_version": "17",
13+
"android_platform": "35",
14+
"android_min_sdk": "28",
15+
"android_build_tools": "35.0.0",
16+
"android_cmdline_tools": "13114758",
17+
18+
"xcode_version": "16.x",
19+
"xcode_ios_version": "latest-stable",
20+
21+
"cmake_minimum_version": "3.25",
22+
23+
"ccache_version": "4.11.3",
24+
"ccache_max_size": "2G",
25+
"clang_format_version": "17",
26+
"node_version": "22",
27+
28+
"flatpak_gnome_version": "47"
29+
}

.github/workflows/docker-linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ on:
1212
pull_request:
1313
paths:
1414
- '.github/workflows/docker-linux.yml'
15+
- '.github/build-config.json'
1516
- 'deploy/docker/**'
1617
- 'deploy/linux/**'
18+
- 'tools/setup/**'
1719
- 'src/**'
1820
- 'CMakeLists.txt'
1921
- 'cmake/**'

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ repos:
4747
rev: v0.11.0.1
4848
hooks:
4949
- id: shellcheck
50+
args: ['-e', 'SC1091'] # Don't warn about not following sourced files
5051

5152
# YAML validation
5253
- repo: https://github.com/adrienverge/yamllint

cmake/BuildConfig.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ============================================================================
2+
# BuildConfig.cmake - Read .github/build-config.json
3+
# ============================================================================
4+
5+
set(QGC_BUILD_CONFIG_FILE "${CMAKE_SOURCE_DIR}/.github/build-config.json")
6+
7+
if(NOT EXISTS "${QGC_BUILD_CONFIG_FILE}")
8+
message(FATAL_ERROR "BuildConfig: Config file not found: ${QGC_BUILD_CONFIG_FILE}")
9+
endif()
10+
11+
# Read the JSON file
12+
file(READ "${QGC_BUILD_CONFIG_FILE}" QGC_BUILD_CONFIG_CONTENT)
13+
14+
# Extract value from JSON (simple regex for flat JSON)
15+
# NOTE: All values in build-config.json must be quoted strings for this parser
16+
macro(qgc_config_get_value VAR_NAME JSON_KEY)
17+
string(REGEX MATCH "\"${JSON_KEY}\"[ \t\n]*:[ \t\n]*\"([^\"]*)\"" _match "${QGC_BUILD_CONFIG_CONTENT}")
18+
if(_match)
19+
set(${VAR_NAME} "${CMAKE_MATCH_1}" CACHE STRING "${JSON_KEY}")
20+
else()
21+
message(FATAL_ERROR "BuildConfig: Key '${JSON_KEY}' not found in ${QGC_BUILD_CONFIG_FILE}")
22+
endif()
23+
endmacro()
24+
25+
qgc_config_get_value(QGC_CONFIG_QT_VERSION "qt_version")
26+
qgc_config_get_value(QGC_CONFIG_QT_MINIMUM_VERSION "qt_minimum_version")
27+
qgc_config_get_value(QGC_CONFIG_GSTREAMER_VERSION "gstreamer_version")
28+
qgc_config_get_value(QGC_CONFIG_GSTREAMER_ANDROID_VERSION "gstreamer_android_version")
29+
qgc_config_get_value(QGC_CONFIG_GSTREAMER_WIN_VERSION "gstreamer_windows_version")
30+
qgc_config_get_value(QGC_CONFIG_NDK_VERSION "ndk_version")
31+
qgc_config_get_value(QGC_CONFIG_NDK_FULL_VERSION "ndk_full_version")
32+
qgc_config_get_value(QGC_CONFIG_JAVA_VERSION "java_version")
33+
qgc_config_get_value(QGC_CONFIG_ANDROID_PLATFORM "android_platform")
34+
qgc_config_get_value(QGC_CONFIG_ANDROID_MIN_SDK "android_min_sdk")
35+
qgc_config_get_value(QGC_CONFIG_CMAKE_MINIMUM "cmake_minimum_version")
36+
37+
message(STATUS "BuildConfig: Qt ${QGC_CONFIG_QT_VERSION}, GStreamer ${QGC_CONFIG_GSTREAMER_VERSION}, NDK ${QGC_CONFIG_NDK_VERSION}")

cmake/CustomOptions.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
include(CMakeDependentOption)
77

8+
# Load centralized build configuration from .github/build-config.json
9+
include(BuildConfig)
10+
811
# ============================================================================
912
# Application Metadata
1013
# ============================================================================
@@ -138,8 +141,8 @@ set(QGC_WINDOWS_RESOURCE_FILE_PATH "${CMAKE_SOURCE_DIR}/deploy/windows/QGroundCo
138141
# Qt Configuration
139142
# ============================================================================
140143

141-
set(QGC_QT_MINIMUM_VERSION "6.10.0" CACHE STRING "Minimum supported Qt version")
142-
set(QGC_QT_MAXIMUM_VERSION "6.10.1" CACHE STRING "Maximum supported Qt version")
144+
set(QGC_QT_MINIMUM_VERSION "${QGC_CONFIG_QT_MINIMUM_VERSION}" CACHE STRING "Minimum supported Qt version")
145+
set(QGC_QT_MAXIMUM_VERSION "${QGC_CONFIG_QT_VERSION}" CACHE STRING "Maximum supported Qt version")
143146

144147
set(QT_QML_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qml" CACHE PATH "QML output directory")
145148
set(QML_IMPORT_PATH "${QT_QML_OUTPUT_DIRECTORY}" CACHE STRING "Additional QML import paths")

cmake/find-modules/FindGStreamer.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
# Default Configuration
1111
# ----------------------------------------------------------------------------
1212

13-
# Set default version based on platform
13+
# Set default version based on platform (from build-config.json)
1414
if(NOT DEFINED GStreamer_FIND_VERSION)
1515
if(LINUX)
1616
set(GStreamer_FIND_VERSION 1.20)
17+
elseif(WIN32)
18+
set(GStreamer_FIND_VERSION ${QGC_CONFIG_GSTREAMER_WIN_VERSION})
19+
elseif(ANDROID)
20+
set(GStreamer_FIND_VERSION ${QGC_CONFIG_GSTREAMER_ANDROID_VERSION})
1721
else()
18-
set(GStreamer_FIND_VERSION 1.22.12)
22+
set(GStreamer_FIND_VERSION ${QGC_CONFIG_GSTREAMER_VERSION})
1923
endif()
2024
endif()
2125

cmake/platform/Android.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ endif()
99
# ----------------------------------------------------------------------------
1010
# Android NDK Version Validation
1111
# ----------------------------------------------------------------------------
12-
if(Qt6_VERSION VERSION_EQUAL "6.10.1")
13-
if(NOT CMAKE_ANDROID_NDK_VERSION VERSION_EQUAL "27.2")
14-
message(FATAL_ERROR "QGC: Invalid NDK Version: ${CMAKE_ANDROID_NDK_VERSION}. Qt 6.10.1 requires NDK 27.2")
12+
# Use ndk_full_version from build-config.json (e.g., "27.2.12829759") for direct
13+
# comparison with CMAKE_ANDROID_NDK_VERSION (same format).
14+
if(DEFINED QGC_CONFIG_NDK_FULL_VERSION AND Qt6_VERSION VERSION_GREATER_EQUAL "${QGC_CONFIG_QT_MINIMUM_VERSION}")
15+
if(NOT CMAKE_ANDROID_NDK_VERSION VERSION_GREATER_EQUAL "${QGC_CONFIG_NDK_FULL_VERSION}")
16+
message(FATAL_ERROR "QGC: NDK ${CMAKE_ANDROID_NDK_VERSION} is too old. Qt ${Qt6_VERSION} requires NDK ${QGC_CONFIG_NDK_FULL_VERSION}+ (${QGC_CONFIG_NDK_VERSION})")
1517
endif()
1618
endif()
1719

0 commit comments

Comments
 (0)