Skip to content

Commit 9b72931

Browse files
committed
vje-2
0 parents  commit 9b72931

705 files changed

Lines changed: 88755 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# ----------------------------------------------------------------------------------------------------------------------
2+
# VJE 2.0 -- Continuous Integration
3+
#
4+
# Builds and tests the single source tree on a Windows + Linux matrix from Phase 5 onward. Linux CI was planned from Phase 0 but
5+
# stood up here, at the first Qt Widgets phase, where portability drift becomes
6+
# likely). Each job installs Qt 6, GCC 13 (MinGW-w64 on Windows, matched to the Qt MinGW build), Ninja, and CMake, then
7+
# configures / builds / tests through the per-toolchain presets with warnings-as-errors on (the CI contract).
8+
#
9+
# Note: Qt / MinGW tool archive names track Qt releases; bump the `qt-version` / `mingw` inputs together when moving Qt.
10+
# ----------------------------------------------------------------------------------------------------------------------
11+
12+
name: CI
13+
14+
on:
15+
push:
16+
branches: [ main ]
17+
pull_request:
18+
branches: [ main ]
19+
workflow_dispatch: # allow a manual run from the Actions tab / `gh workflow run`
20+
21+
# Cancel superseded runs on the same ref to save minutes.
22+
concurrency:
23+
group: ci-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
build-and-test:
28+
name: ${{ matrix.name }}
29+
runs-on: ${{ matrix.os }}
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- name: Windows (MinGW GCC)
36+
os: windows-latest
37+
configure-preset: windows-release
38+
build-preset: windows-release
39+
test-preset: windows-release
40+
qt-arch: win64_mingw
41+
qt-tools: tools_mingw1310
42+
qt-tools-bin: mingw1310_64/bin
43+
- name: Linux (GCC 13)
44+
os: ubuntu-latest
45+
configure-preset: linux-release
46+
build-preset: linux-release
47+
test-preset: linux-release
48+
qt-arch: linux_gcc_64
49+
qt-tools: ""
50+
qt-tools-bin: ""
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
56+
- name: Install GCC 13 and Ninja (Linux)
57+
if: runner.os == 'Linux'
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install -y g++-13 ninja-build
61+
62+
- name: Install Ninja (Windows)
63+
if: runner.os == 'Windows'
64+
uses: seanmiddleditch/gha-setup-ninja@v5
65+
66+
# Qt SVG (required by src/vje_app/services/IconLibrary) needs NO `modules:` entry: it is part of the base
67+
# aqtinstall archive this action wraps. Verified against an aqt linux_gcc_64 6.8.3 install, which ships
68+
# libQt6Svg.so, the Qt6Svg CMake package, and the qsvg image plugin. Only MSYS2 splits it into a separate
69+
# package.
70+
71+
- name: Install Qt 6
72+
uses: jurplel/install-qt-action@v4
73+
with:
74+
version: 6.8.3
75+
arch: ${{ matrix.qt-arch }}
76+
tools: ${{ matrix.qt-tools }}
77+
cache: true
78+
79+
- name: Add MinGW to PATH (Windows)
80+
if: runner.os == 'Windows'
81+
shell: bash
82+
run: echo "${IQTA_TOOLS}/${{ matrix.qt-tools-bin }}" >> "$GITHUB_PATH"
83+
84+
- name: Configure
85+
run: cmake --preset ${{ matrix.configure-preset }} -DVJE_WARNINGS_AS_ERRORS=ON
86+
87+
- name: Build
88+
run: cmake --build --preset ${{ matrix.build-preset }}
89+
90+
# --output-on-failure is not optional here. Without it a red CI run names the failing suite and nothing else, so
91+
# a failure that does not reproduce locally -- exactly the kind CI exists to catch -- costs a full round-trip just
92+
# to learn which assertion broke. Qt Test already prints the actual/expected pair; this is what lets it be seen.
93+
94+
- name: Test
95+
run: ctest --preset ${{ matrix.test-preset }} --output-on-failure
96+
97+
# A test that dies BEFORE Qt Test prints its banner -- a missing DLL, a crash in widget construction -- produces
98+
# no output at all, so --output-on-failure has nothing to show and the log names the suite and stops. That is
99+
# exactly what the first red run on this matrix looked like. Re-running the failed test alone under -VV surfaces
100+
# the invocation, the environment and the exit code, which is what distinguishes "it crashed" from "it failed".
101+
102+
- name: Diagnose a failing test
103+
if: failure()
104+
shell: bash
105+
run: |
106+
# set +e is load-bearing. GitHub runs `shell: bash` with -e, so the FIRST binary that exits non-zero aborts
107+
# this whole script -- which is precisely the binary being investigated, and the reason the previous version
108+
# of this step reported nothing at all.
109+
110+
set +e
111+
112+
ctest --preset ${{ matrix.test-preset }} --rerun-failed --extra-verbose
113+
114+
# THE EXIT CODE IS THE DATUM. A test that dies before Qt Test prints its banner loses its buffered stdout
115+
# entirely, so ctest shows nothing however verbose it is asked to be. The raw code separates cases that
116+
# otherwise look identical: 0xC0000135 (3221225781) is a DLL that failed to load, 0xC0000005 (3221225477) an
117+
# access violation, and a small number an ordinary count of failed assertions.
118+
119+
echo "=== direct run of each test binary (non-zero exits only) ==="
120+
121+
# The "no dot in the name" arm is how the Linux binaries are matched without also matching *.o / *.cpp.obj.
122+
123+
find build -type f \( -name 'tst_*.exe' -o \( -name 'tst_*' ! -name '*.*' \) \) | while read -r binary; do
124+
125+
output=$( QT_QPA_PLATFORM=offscreen "$binary" 2>&1 )
126+
code=$?
127+
128+
if [ "$code" -ne 0 ]; then
129+
echo "--- $binary -> exit $code"
130+
echo "$output" | tail -40
131+
132+
# Qt Test's own FILE output, because stdout has proved unreliable here: a binary returning 1 (which is
133+
# its count of failed test functions, so it definitely reported) produced not one byte on stdout or
134+
# stderr, through both ctest --extra-verbose and a direct capture. -o bypasses the stream entirely.
135+
136+
echo "--- re-run via QTest file output ---"
137+
QT_QPA_PLATFORM=offscreen "$binary" -o "qtest-report.txt,txt" > /dev/null 2>&1
138+
cat "qtest-report.txt" 2>/dev/null | tail -40
139+
rm -f "qtest-report.txt"
140+
fi
141+
done
142+
143+
# Diagnostic only: the Test step above already failed the job, and this step failing too would just obscure it.
144+
145+
exit 0

‎.gitignore‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Public repository .gitignore.
2+
#
3+
# This file is OWNED by the public repo and preserved across promotions -- it is
4+
# never overwritten by tools/promote. Keep it free of any reference to private,
5+
# dev-only paths (those must never leave a trace in the public tree).
6+
7+
# CMake / build trees
8+
build/
9+
build-*/
10+
cmake-build-*/
11+
out/
12+
13+
# Distribution artifacts (installers, AppImages, archives ship as release assets,
14+
# not committed to the repo)
15+
dist/
16+
17+
# C / C++ object & binary artifacts
18+
*.o
19+
*.obj
20+
*.a
21+
*.lib
22+
*.so
23+
*.dylib
24+
*.dll
25+
*.exe
26+
27+
# Qt generated files (when a tool emits them in-tree rather than under build/)
28+
moc_*.cpp
29+
qrc_*.cpp
30+
ui_*.h
31+
*.moc
32+
33+
# IDE / editor
34+
.idea/
35+
.vscode/
36+
*.user
37+
38+
# OS junk
39+
.DS_Store
40+
Thumbs.db

‎CMakeLists.txt‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#-----------------------------------------------------------------------------------------------------------------------
2+
# Project: VJE (Versatile JSON Editor) 2.0
3+
# Version: 2.0.0
4+
# Date: 2024
5+
# Author: Rohin Gosling
6+
#
7+
# Description:
8+
#
9+
# Top-level CMake build for VJE 2.0 -- a native, cross-platform (Windows + Linux) desktop JSON editor built in
10+
# C++20 / Qt 6 Widgets with CMake + Ninja and GCC 13+. One codebase, one src/ tree (no per-OS split): the UI-free
11+
# vje_core domain library (Qt Core only), the vje_app Qt Widgets executable, and their Qt Test / CTest targets.
12+
#
13+
# Configure / build / test via the presets in CMakePresets.json:
14+
# cmake --preset <preset> | cmake --build --preset <preset> | ctest --preset <preset> --output-on-failure
15+
#
16+
#-----------------------------------------------------------------------------------------------------------------------
17+
18+
cmake_minimum_required ( VERSION 3.21 )
19+
20+
project ( vje
21+
VERSION 2.0.0
22+
DESCRIPTION "VJE (Versatile JSON Editor) 2.0 -- a native cross-platform desktop JSON editor"
23+
LANGUAGES CXX
24+
)
25+
26+
#-----------------------------------------------------------------------------------------------------------------------
27+
# Language standard: C++20 on every target (GCC 13+; enables std::format). No compiler extensions.
28+
#-----------------------------------------------------------------------------------------------------------------------
29+
30+
set ( CMAKE_CXX_STANDARD 20 )
31+
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
32+
set ( CMAKE_CXX_EXTENSIONS OFF )
33+
34+
# Emit compile_commands.json for clangd / IntelliSense.
35+
36+
set ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
37+
38+
#-----------------------------------------------------------------------------------------------------------------------
39+
# Build options.
40+
#-----------------------------------------------------------------------------------------------------------------------
41+
42+
option ( VJE_BUILD_TESTS "Build the Qt Test / CTest targets" ON )
43+
option ( VJE_WARNINGS_AS_ERRORS "Treat compiler warnings as errors (CI default: on)" OFF )
44+
45+
#-----------------------------------------------------------------------------------------------------------------------
46+
# Qt 6.5+ (6.5 introduced QStyleHints::colorScheme(), required by the System theme).
47+
# vje_core uses Core + Gui (Gui for the undo framework ONLY -- Qt 6 moved QUndoStack/QUndoCommand out of Qt Core into
48+
# Qt Gui; the classes are headless QObjects that run under a QCoreApplication, so vje_core stays display-free and
49+
# unit-testable, and links NO Widgets). vje_app adds Widgets; PrintSupport backs printing (Phase 13);
50+
# Svg rasterizes the bundled icon set (QSvgRenderer, src/vje_app/services/IconLibrary) -- without it the .svg assets
51+
# fail to load SILENTLY, so it is a hard requirement, not an optional extra; Test backs the CTest targets.
52+
#-----------------------------------------------------------------------------------------------------------------------
53+
54+
find_package ( Qt6 6.5 REQUIRED COMPONENTS Core Gui Widgets Svg Test PrintSupport )
55+
56+
# Qt code-generation tooling (moc / rcc / uic) is driven automatically per target.
57+
58+
set ( CMAKE_AUTOMOC ON )
59+
set ( CMAKE_AUTORCC ON )
60+
set ( CMAKE_AUTOUIC ON )
61+
62+
#-----------------------------------------------------------------------------------------------------------------------
63+
# Shared warning flags. Targets that carry our own code link this INTERFACE library privately; third-party code
64+
# fetched by Dependencies.cmake does not, so its warnings never fail our build.
65+
#-----------------------------------------------------------------------------------------------------------------------
66+
67+
add_library ( vje_warnings INTERFACE )
68+
69+
target_compile_options ( vje_warnings INTERFACE
70+
-Wall
71+
-Wextra
72+
-Wpedantic
73+
)
74+
75+
if ( VJE_WARNINGS_AS_ERRORS )
76+
target_compile_options ( vje_warnings INTERFACE -Werror )
77+
endif ()
78+
79+
#-----------------------------------------------------------------------------------------------------------------------
80+
# External dependencies (CMake FetchContent -- resolved decision, OQ-A4).
81+
#-----------------------------------------------------------------------------------------------------------------------
82+
83+
include ( cmake/Dependencies.cmake )
84+
85+
#-----------------------------------------------------------------------------------------------------------------------
86+
# Test infrastructure (Qt Test + CTest -- OQ-A3).
87+
#-----------------------------------------------------------------------------------------------------------------------
88+
89+
if ( VJE_BUILD_TESTS )
90+
enable_testing ()
91+
endif ()
92+
93+
#-----------------------------------------------------------------------------------------------------------------------
94+
# Targets. The layering is the schedule: the UI-free core first, then the Qt Widgets application on top.
95+
#-----------------------------------------------------------------------------------------------------------------------
96+
97+
add_subdirectory ( src/vje_core )
98+
add_subdirectory ( src/vje_app )

‎CMakePresets.json‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": { "major": 3, "minor": 21, "patch": 0 },
4+
5+
"configurePresets": [
6+
{
7+
"name": "base",
8+
"hidden": true,
9+
"generator": "Ninja",
10+
"binaryDir": "${sourceDir}/build/${presetName}",
11+
"cacheVariables": {
12+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
13+
"VJE_BUILD_TESTS": "ON",
14+
"VJE_ENABLE_YAML": "ON"
15+
}
16+
},
17+
18+
{
19+
"name": "windows-base",
20+
"hidden": true,
21+
"inherits": "base",
22+
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows" },
23+
"cacheVariables": {
24+
"CMAKE_CXX_COMPILER": "g++"
25+
}
26+
},
27+
{
28+
"name": "windows-debug",
29+
"displayName": "Windows (MinGW GCC) - Debug",
30+
"inherits": "windows-base",
31+
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }
32+
},
33+
{
34+
"name": "windows-release",
35+
"displayName": "Windows (MinGW GCC) - Release",
36+
"inherits": "windows-base",
37+
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
38+
},
39+
40+
{
41+
"name": "linux-base",
42+
"hidden": true,
43+
"inherits": "base",
44+
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux" },
45+
"cacheVariables": {
46+
"CMAKE_CXX_COMPILER": "g++-13"
47+
}
48+
},
49+
{
50+
"name": "linux-debug",
51+
"displayName": "Linux (GCC 13) - Debug",
52+
"inherits": "linux-base",
53+
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }
54+
},
55+
{
56+
"name": "linux-release",
57+
"displayName": "Linux (GCC 13) - Release",
58+
"inherits": "linux-base",
59+
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
60+
},
61+
62+
{
63+
"name": "verify",
64+
"displayName": "Clean-room verify (Release, either platform)",
65+
"inherits": "base",
66+
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
67+
}
68+
],
69+
70+
"buildPresets": [
71+
{ "name": "windows-debug", "configurePreset": "windows-debug" },
72+
{ "name": "windows-release", "configurePreset": "windows-release" },
73+
{ "name": "linux-debug", "configurePreset": "linux-debug" },
74+
{ "name": "linux-release", "configurePreset": "linux-release" },
75+
{ "name": "verify", "configurePreset": "verify" }
76+
],
77+
78+
"testPresets": [
79+
{ "name": "windows-debug", "configurePreset": "windows-debug", "output": { "outputOnFailure": true } },
80+
{ "name": "windows-release", "configurePreset": "windows-release", "output": { "outputOnFailure": true } },
81+
{ "name": "linux-debug", "configurePreset": "linux-debug", "output": { "outputOnFailure": true } },
82+
{ "name": "linux-release", "configurePreset": "linux-release", "output": { "outputOnFailure": true } },
83+
{ "name": "verify", "configurePreset": "verify", "output": { "outputOnFailure": true } }
84+
]
85+
}

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Rohin Gosling
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)