Skip to content

Commit 8eee5aa

Browse files
Improve build configuration in GitHub CI (#2861)
This changelist improves the build configuration in GitHub CI, reducing duplication across the build matrix and adjusting parallelism per platform. The following specific changes are included: - Consolidate extended build configuration as a local `extended_cmake_config` field on each matrix row, reducing the CMake Generate step to a single call. - Adjust build parallelism per platform through the CMAKE_BUILD_PARALLEL_LEVEL environment variable, defaulting to 4 and reduced to 1 on Windows, as the MSVC `/MP` flag already handles file-level parallelism within each project. - Simplify the MacOS rendering setup to setting a debug flag in extended builds, as the `MTL_HARDWARE_RENDERING` and `LIBGL_ALWAYS_SOFTWARE` overrides are not actually supported in Metal rendering.
1 parent 86acb1d commit 8eee5aa

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
permissions:
1212
contents: read
1313

14+
env:
15+
CMAKE_BUILD_PARALLEL_LEVEL: 4
16+
CTEST_PARALLEL_LEVEL: 4
17+
1418
jobs:
1519

1620
build:
@@ -35,6 +39,7 @@ jobs:
3539
compiler_version: "14"
3640
python: 3.13
3741
extended_build_perfetto: ON
42+
extended_cmake_config: -DMATERIALX_BUILD_PERFETTO_TRACING=ON
3843

3944
- name: Linux_GCC_14_Python314
4045
os: ubuntu-24.04
@@ -69,7 +74,7 @@ jobs:
6974
os: macos-14
7075
compiler: xcode
7176
compiler_version: "15.4"
72-
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON
77+
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON -DMATERIALX_BUILD_DATA_LIBRARY=ON
7378
python: 3.11
7479

7580
- name: MacOS_Xcode_16_Python313
@@ -79,14 +84,15 @@ jobs:
7984
python: 3.13
8085
test_shaders: ON
8186
test_render: ON
87+
cmake_config: -DMATERIALX_TEST_RENDER=ON -DMATERIALX_RENDER_MSL_ONLY=ON
8288

8389
- name: MacOS_Xcode_26_Python314
8490
os: macos-26
8591
compiler: xcode
8692
compiler_version: "26.0"
8793
python: 3.14
8894
static_analysis: ON
89-
cmake_config: -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DMATERIALX_BUILD_DATA_LIBRARY=ON
95+
cmake_config: -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
9096

9197
- name: MacOS_Xcode_DynamicAnalysis
9298
os: macos-26
@@ -115,6 +121,7 @@ jobs:
115121
python: 3.13
116122
cmake_config: -G "Visual Studio 17 2022" -A "x64"
117123
extended_build_mdl_sdk: ON
124+
extended_cmake_config: -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-release -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows-release
118125

119126
- name: Windows_VS2022_x64_Python314
120127
os: windows-2025
@@ -123,6 +130,7 @@ jobs:
123130
cmake_config: -G "Visual Studio 17 2022" -A "x64"
124131
test_shaders: ON
125132
extended_build_oiio: ON
133+
extended_cmake_config: -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DMATERIALX_BUILD_OIIO=ON
126134

127135
- name: Windows_VS2022_x64_SharedLibs
128136
os: windows-2025
@@ -164,10 +172,12 @@ jobs:
164172
fi
165173
fi
166174
167-
- name: Install Dependencies (Windows)
175+
- name: Setup Build Environment (Windows)
168176
if: runner.os == 'Windows'
169177
run: |
170178
Add-Content $env:GITHUB_PATH "$PWD/build/installed/bin"
179+
# MSVC /MP already parallelizes within each project, so build projects serially.
180+
Add-Content $env:GITHUB_ENV "CMAKE_BUILD_PARALLEL_LEVEL=1"
171181
172182
- name: Install OpenImageIO
173183
if: env.IS_EXTENDED_BUILD == 'true' && matrix.extended_build_oiio == 'ON' && runner.os == 'Windows'
@@ -199,32 +209,16 @@ jobs:
199209
- name: CMake Generate
200210
shell: bash
201211
run: |
202-
EXTENDED_BUILD_CONFIG=""
203-
if [ "${{ env.IS_EXTENDED_BUILD }}" == "true" ]; then
204-
if [ "${{ runner.os }}" == "Windows" ]; then
205-
EXTENDED_BUILD_CONFIG="-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
206-
fi
207-
if [ "${{ matrix.extended_build_oiio }}" == "ON" ]; then
208-
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DVCPKG_TARGET_TRIPLET=x64-windows -DMATERIALX_BUILD_OIIO=ON"
209-
fi
210-
if [ "${{ matrix.extended_build_mdl_sdk }}" == "ON" -a "${{ runner.os }}" == "Windows" ]; then
211-
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DVCPKG_TARGET_TRIPLET=x64-windows-release -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows-release"
212-
fi
213-
if [ "${{ matrix.extended_build_perfetto }}" == "ON" ]; then
214-
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_BUILD_PERFETTO_TRACING=ON"
215-
fi
216-
fi
217-
TEST_RENDER_CONFIG="-DMATERIALX_TEST_RENDER=OFF"
218-
if [ "${{ matrix.test_render }}" == "ON" ]; then
219-
if [ "${{ runner.os }}" == "macOS" ]; then
220-
TEST_RENDER_CONFIG="-DMATERIALX_TEST_RENDER=ON -DMATERIALX_RENDER_MSL_ONLY=ON"
221-
fi
222-
fi
223-
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG $TEST_RENDER_CONFIG"
224-
cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_BUILD_TESTS=ON -DMATERIALX_WARNINGS_AS_ERRORS=ON $EXTENDED_BUILD_CONFIG ${{matrix.cmake_config}}
212+
cmake -S . -B build \
213+
-DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON \
214+
-DMATERIALX_BUILD_PYTHON=ON \
215+
-DMATERIALX_BUILD_TESTS=ON -DMATERIALX_TEST_RENDER=OFF \
216+
-DMATERIALX_WARNINGS_AS_ERRORS=ON \
217+
${{ env.IS_EXTENDED_BUILD == 'true' && matrix.extended_cmake_config || '' }} \
218+
${{ matrix.cmake_config }}
225219
226220
- name: CMake Build
227-
run: cmake --build build --target install --config Release --parallel 2
221+
run: cmake --build build --target install --config Release
228222

229223
- name: CMake Unit Tests
230224
run: ctest --output-on-failure --build-config Release
@@ -294,14 +288,9 @@ jobs:
294288
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
295289
296290
- name: Setup Rendering Environment (MacOS)
297-
if: matrix.test_render == 'ON' && runner.os == 'macOS'
291+
if: matrix.test_render == 'ON' && runner.os == 'macOS' && env.IS_EXTENDED_BUILD == 'true'
298292
run: |
299-
# macOS can render headless with Metal backend without virtual display
300-
# Force software rendering for Metal backend (more reliable in CI)
301-
echo "MTL_HARDWARE_RENDERING=0" >> $GITHUB_ENV
302-
# Enable Metal debug layer for better debugging in CI
303293
echo "MTL_DEBUG_LAYER=1" >> $GITHUB_ENV
304-
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
305294
306295
- name: Render Script Tests
307296
if: matrix.test_render == 'ON'
@@ -409,7 +398,7 @@ jobs:
409398
run: cmake -S . -B javascript/build -DMATERIALX_BUILD_JS=ON -DMATERIALX_EMSDK_PATH=${{ env.EMSDK }}
410399

411400
- name: JavaScript CMake Build
412-
run: cmake --build javascript/build --target install --config Release --parallel 2
401+
run: cmake --build javascript/build --target install --config Release
413402

414403
- name: Install JavaScript Dependencies
415404
run: |

0 commit comments

Comments
 (0)