|
| 1 | +name: Build (CMake) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +defaults: |
| 14 | + run: |
| 15 | + shell: bash |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + os: ['ubuntu', 'windows'] |
| 23 | + # Qt 5.12.* is excluded: CMakeLists.txt requires Qt >= 5.15.0. |
| 24 | + qt-version: [ '5.15.*', '6.10.*' ] |
| 25 | + python-version: [ '3.12' ] |
| 26 | + runs-on: ${{ matrix.os }}-latest |
| 27 | + steps: |
| 28 | + |
| 29 | + - name: Install MSVC |
| 30 | + if: ${{ matrix.os == 'windows' }} |
| 31 | + uses: ilammy/msvc-dev-cmd@v1 |
| 32 | + with: |
| 33 | + arch: amd64 |
| 34 | + |
| 35 | + - name: Install Qt ${{ matrix.qt-version }} |
| 36 | + uses: jurplel/install-qt-action@v4 |
| 37 | + with: |
| 38 | + version: ${{ matrix.qt-version }} |
| 39 | + modules: ${{ startsWith(matrix.qt-version, '6') && 'qt5compat qtscxml qtpositioning qtwebchannel qtmultimedia qtwebengine' || '' }} |
| 40 | + arch: ${{ (matrix.os == 'ubuntu' && (startsWith(matrix.qt-version, '5') && 'gcc_64' || 'linux_gcc_64')) || startsWith(matrix.qt-version, '6') && 'win64_msvc2022_64' || 'win64_msvc2019_64' }} |
| 41 | + |
| 42 | + - name: Setup Python ${{ matrix.python-version }} |
| 43 | + uses: actions/setup-python@v6 |
| 44 | + with: |
| 45 | + python-version: '${{ matrix.python-version }}' |
| 46 | + |
| 47 | + - name: Checkout PythonQt |
| 48 | + uses: actions/checkout@v6 |
| 49 | + |
| 50 | + - name: Ccache |
| 51 | + if: ${{ matrix.os == 'ubuntu' }} |
| 52 | + uses: hendrikmuhs/ccache-action@v1.2.20 |
| 53 | + with: |
| 54 | + key: ${{ runner.os }}-cmake-${{ matrix.qt-version }} |
| 55 | + evict-old-files: 'job' |
| 56 | + |
| 57 | + - name: Set environment |
| 58 | + id: setenv |
| 59 | + run: | |
| 60 | + QT_VERSION_MAJOR=$(cut -f 1 -d . <<< "${{ matrix.qt-version }}") |
| 61 | + echo "QT_VERSION_MAJOR=$QT_VERSION_MAJOR" >> $GITHUB_ENV |
| 62 | + QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< "${{ matrix.qt-version }}") |
| 63 | + echo "QT_VERSION_SHORT=$QT_VERSION_SHORT" >> $GITHUB_OUTPUT |
| 64 | + PYTHON_VERSION_FULL=$(python --version 2>&1 | cut -f 2 -d ' ') |
| 65 | + PYTHON_VERSION_SHORT=$(cut -f 1,2 -d . <<< $PYTHON_VERSION_FULL) |
| 66 | + echo "PYTHON_VERSION_SHORT=$PYTHON_VERSION_SHORT" >> $GITHUB_OUTPUT |
| 67 | + echo "$pythonLocation/bin" >> $GITHUB_PATH |
| 68 | +
|
| 69 | + - name: Build generator (Ubuntu) |
| 70 | + if: ${{ matrix.os == 'ubuntu' }} |
| 71 | + run: | |
| 72 | + cmake -G Ninja -S generator -B generator/build \ |
| 73 | + -DCMAKE_BUILD_TYPE=Release \ |
| 74 | + -DCMAKE_PREFIX_PATH="$QT_ROOT_DIR" \ |
| 75 | + -DPythonQtGenerator_QT_VERSION=$QT_VERSION_MAJOR |
| 76 | + cmake --build generator/build |
| 77 | +
|
| 78 | + - name: Build generator (Windows) |
| 79 | + if: ${{ matrix.os == 'windows' }} |
| 80 | + shell: cmd |
| 81 | + run: | |
| 82 | + set QT_CMAKE_DIR=%QT_ROOT_DIR%\lib\cmake\Qt%QT_VERSION_MAJOR% |
| 83 | + cmake -G "Visual Studio 17 2022" -S generator -B generator\build ^ |
| 84 | + "-DCMAKE_PREFIX_PATH=%QT_ROOT_DIR%;%QT_ROOT_DIR%\lib\cmake" ^ |
| 85 | + "-DQt%QT_VERSION_MAJOR%_DIR=%QT_CMAKE_DIR%" ^ |
| 86 | + -DPythonQtGenerator_QT_VERSION=%QT_VERSION_MAJOR% || exit /b 1 |
| 87 | + cmake --build generator\build --config Release || exit /b 1 |
| 88 | +
|
| 89 | + - name: Generate Wrappers (Ubuntu) |
| 90 | + if: ${{ matrix.os == 'ubuntu' }} |
| 91 | + run: | |
| 92 | + QTDIR="$QT_ROOT_DIR" \ |
| 93 | + UBSAN_OPTIONS="halt_on_error=1" \ |
| 94 | + ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \ |
| 95 | + ./generator/build/PythonQtGenerator \ |
| 96 | + --output-directory=. |
| 97 | +
|
| 98 | + - name: Generate Wrappers (Windows) |
| 99 | + if: ${{ matrix.os == 'windows' }} |
| 100 | + shell: cmd |
| 101 | + run: | |
| 102 | + set QTDIR=%QT_ROOT_DIR% |
| 103 | + generator\build\Release\PythonQtGenerator.exe --output-directory=. || exit /b 1 |
| 104 | +
|
| 105 | + - name: Upload Wrappers |
| 106 | + uses: actions/upload-artifact@v7 |
| 107 | + with: |
| 108 | + name: cmake_wrappers_${{ matrix.os }}_${{ steps.setenv.outputs.QT_VERSION_SHORT }} |
| 109 | + path: generated_cpp |
| 110 | + if-no-files-found: error |
| 111 | + |
| 112 | + - name: Build and test PythonQt (Ubuntu) |
| 113 | + if: ${{ matrix.os == 'ubuntu' }} |
| 114 | + run: | |
| 115 | + cmake -G Ninja -S . -B build \ |
| 116 | + -DCMAKE_BUILD_TYPE=Release \ |
| 117 | + -DCMAKE_PREFIX_PATH="$QT_ROOT_DIR" \ |
| 118 | + -DPythonQt_QT_VERSION=$QT_VERSION_MAJOR \ |
| 119 | + "-DPythonQt_GENERATED_PATH=$(pwd)/generated_cpp" \ |
| 120 | + -DPythonQt_Wrap_QtCore=ON \ |
| 121 | + -DBUILD_TESTING=ON \ |
| 122 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ |
| 123 | + "-DCMAKE_CXX_FLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined" \ |
| 124 | + "-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address,undefined" \ |
| 125 | + "-DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=address,undefined" |
| 126 | + cmake --build build --parallel $(nproc) |
| 127 | + PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \ |
| 128 | + UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \ |
| 129 | + QT_QPA_PLATFORM=offscreen \ |
| 130 | + ctest --test-dir build --output-on-failure |
| 131 | +
|
| 132 | + - name: Build and test PythonQt (Windows) |
| 133 | + if: ${{ matrix.os == 'windows' }} |
| 134 | + shell: cmd |
| 135 | + run: | |
| 136 | + set QT_CMAKE_DIR=%QT_ROOT_DIR%\lib\cmake\Qt%QT_VERSION_MAJOR% |
| 137 | + cmake -G "Visual Studio 17 2022" -S . -B build ^ |
| 138 | + "-DCMAKE_PREFIX_PATH=%QT_ROOT_DIR%;%QT_ROOT_DIR%\lib\cmake" ^ |
| 139 | + "-DQt%QT_VERSION_MAJOR%_DIR=%QT_CMAKE_DIR%" ^ |
| 140 | + -DPythonQt_QT_VERSION=%QT_VERSION_MAJOR% ^ |
| 141 | + "-DPythonQt_GENERATED_PATH=%CD%\generated_cpp" ^ |
| 142 | + -DPythonQt_Wrap_QtCore=ON ^ |
| 143 | + -DBUILD_TESTING=ON || exit /b 1 |
| 144 | + cmake --build build --config Release || exit /b 1 |
| 145 | + set PYTHONDEVMODE=1 |
| 146 | + set PYTHONASYNCIODEBUG=1 |
| 147 | + set PYTHONWARNINGS=error |
| 148 | + set QT_QPA_PLATFORM=offscreen |
| 149 | + ctest --test-dir build --output-on-failure -C Release || exit /b 1 |
0 commit comments