forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 6
440 lines (379 loc) · 15.6 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
name: main
on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux_GCC_9_Python37
os: ubuntu-20.04
compiler: gcc
compiler_version: "9"
python: 3.7
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON
- name: Linux_GCC_12_Python311
os: ubuntu-22.04
compiler: gcc
compiler_version: "12"
python: 3.11
build_javascript: ON
- name: Linux_GCC_12_Python311_Static_Monolithic
os: ubuntu-22.04
compiler: gcc
compiler_version: "12"
python: 3.11
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON -DMATERIALX_BUILD_MONOLITHIC=ON
- name: Linux_GCC_14_Python312
os: ubuntu-24.04
compiler: gcc
compiler_version: "14"
python: 3.12
static_analysis: ON
cmake_config: -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Linux_GCC_CoverageAnalysis
os: ubuntu-22.04
compiler: gcc
compiler_version: "None"
python: None
coverage_analysis: ON
cmake_config: -DMATERIALX_COVERAGE_ANALYSIS=ON -DMATERIALX_BUILD_RENDER=OFF -DMATERIALX_BUILD_PYTHON=OFF
- name: Linux_Clang_10_Python37
os: ubuntu-20.04
compiler: clang
compiler_version: "10"
python: 3.7
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON
- name: Linux_Clang_18_Python312
os: ubuntu-24.04
compiler: clang
compiler_version: "18"
python: 3.12
test_render: ON
clang_format: ON
- name: MacOS_Xcode_13_Python37
os: macos-12
compiler: xcode
compiler_version: "13.1"
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON
python: 3.7
- name: MacOS_Xcode_14_Python311
os: macos-14
compiler: xcode
compiler_version: "14.3"
python: 3.11
- name: MacOS_Xcode_15_Python312
os: macos-14
compiler: xcode
compiler_version: "15.0"
python: 3.12
test_shaders: ON
- name: MacOS_Xcode_DynamicAnalysis
os: macos-14
compiler: xcode
compiler_version: "15.0"
python: None
dynamic_analysis: ON
cmake_config: -DMATERIALX_DYNAMIC_ANALYSIS=ON
- name: iOS_Xcode_15
os: macos-14
compiler: xcode
compiler_version: "15.0"
python: None
cmake_config: -DMATERIALX_BUILD_IOS=ON -DCMAKE_OSX_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path` -DCMAKE_OSX_ARCHITECTURES=arm64
- name: Windows_VS2019_Win32_Python37
os: windows-2019
architecture: x86
python: 3.7
cmake_config: -G "Visual Studio 16 2019" -A "Win32" -DMATERIALX_BUILD_SHARED_LIBS=ON
- name: Windows_VS2022_x64_Python311
os: windows-2022
architecture: x64
python: 3.11
cmake_config: -G "Visual Studio 17 2022" -A "x64"
test_shaders: ON
- name: Windows_VS2022_x64_Python312
os: windows-2022
architecture: x64
python: 3.12
cmake_config: -G "Visual Studio 17 2022" -A "x64"
upload_shaders: ON
steps:
- name: Sync Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install xorg-dev
if [ "${{ matrix.compiler_version }}" != 'None' ]; then
if [ "${{ matrix.compiler }}" = "gcc" ]; then
sudo apt-get install -y g++-${{ matrix.compiler_version }}
echo "CC=gcc-${{ matrix.compiler_version }}" >> $GITHUB_ENV
echo "CXX=g++-${{ matrix.compiler_version }}" >> $GITHUB_ENV
else
sudo apt-get install -y clang-${{ matrix.compiler_version }}
echo "CC=clang-${{ matrix.compiler_version }}" >> $GITHUB_ENV
echo "CXX=clang++-${{ matrix.compiler_version }}" >> $GITHUB_ENV
fi
fi
- name: Install Dependencies (MacOS)
if: runner.os == 'macOS'
run: |
if [ "${{ matrix.compiler_version }}" != 'None' ]; then
if [ "${{ matrix.compiler }}" = "gcc" ]; then
brew install gcc@${{ matrix.compiler_version }}
echo "CC=gcc-${{ matrix.compiler_version }}" >> $GITHUB_ENV
echo "CXX=g++-${{ matrix.compiler_version }}" >> $GITHUB_ENV
else
ls -ls /Applications/
sudo xcode-select -switch /Applications/Xcode_${{ matrix.compiler_version }}.app
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
fi
fi
- name: Install Dependencies (Windows)
if: runner.os == 'Windows'
run: |
git clone https://github.com/Microsoft/vcpkg -b 2021.05.12 -c advice.detachedHead=false
vcpkg/bootstrap-vcpkg.bat -disableMetrics
Add-Content $env:GITHUB_PATH "$PWD/build/installed/bin"
Add-Content $env:GITHUB_PATH "$PWD/vcpkg/installed/x64-windows/bin"
Add-Content $env:GITHUB_PATH "$PWD/vcpkg/installed/x64-windows/tools"
- name: Install Python ${{ matrix.python }}
if: matrix.python != 'None'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.architecture }}
- name: Install Python Dependencies
if: matrix.python != 'None'
run: pip install setuptools
- name: Install Emscripten
if: matrix.build_javascript == 'ON'
run: |
git clone https://github.com/emscripten-core/emsdk --recursive
cd emsdk
./emsdk install 2.0.20
./emsdk activate 2.0.20
source ./emsdk_env.sh
echo "EMSDK=$EMSDK" >> $GITHUB_ENV
- name: Install Node
if: matrix.build_javascript == 'ON'
uses: actions/setup-node@v4
with:
node-version: '16'
- name: Run Clang Format
if: matrix.clang_format == 'ON'
run: find source \( -name *.h -o -name *.cpp -o -name *.mm -o -name *.inl \) ! -path "*/External/*" ! -path "*/NanoGUI/*" | xargs clang-format -i --verbose
- name: CMake Generate
run: cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_BUILD_TESTS=ON -DMATERIALX_TEST_RENDER=OFF -DMATERIALX_WARNINGS_AS_ERRORS=ON ${{matrix.cmake_config}}
- name: CMake Build
run: cmake --build build --target install --config Release --parallel 2
- name: CMake Unit Tests
run: ctest -VV --output-on-failure --build-config Release
working-directory: build
- name: Python Tests
if: matrix.python != 'None'
run: |
python MaterialXTest/main.py
python MaterialXTest/genshader.py
python Scripts/creatematerial.py ../resources/Materials/Examples/StandardSurface/chess_set --texturePrefix chessboard --shadingModel standard_surface
python Scripts/creatematerial.py ../resources/Materials/Examples/GltfPbr/boombox --shadingModel gltf_pbr
python Scripts/mxformat.py ../resources/Materials/TestSuite/stdlib/upgrade --yes --upgrade
python Scripts/mxvalidate.py ../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose
python Scripts/mxdoc.py --docType md ../libraries/pbrlib/pbrlib_defs.mtlx
python Scripts/mxdoc.py --docType html ../libraries/bxdf/standard_surface.mtlx
python Scripts/generateshader.py ../resources/Materials/Examples/StandardSurface --target glsl
python Scripts/generateshader.py ../resources/Materials/Examples/StandardSurface --target osl
python Scripts/generateshader.py ../resources/Materials/Examples/StandardSurface --target mdl
python Scripts/generateshader.py ../resources/Materials/Examples/StandardSurface --target msl
working-directory: python
- name: Shader Validation Tests (Windows)
if: matrix.test_shaders == 'ON' && runner.os == 'Windows'
run: |
vcpkg/vcpkg install glslang --triplet=x64-windows
glslangValidator.exe -v
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target glsl --validator glslangValidator.exe --vulkanGlsl True --validatorArgs="-V --aml"
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target essl --validator glslangValidator.exe
- name: Shader Validation Tests (MacOS)
if: matrix.test_shaders == 'ON' && runner.os == 'macOS'
run: |
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target msl --validator "xcrun metal --language=metal" --validatorArgs="-w"
- name: Coverage Analysis Tests
if: matrix.coverage_analysis == 'ON'
run: |
sudo apt-get install gcovr
mkdir coverage
gcovr --html --html-details --output coverage/index.html --exclude .*\/External\/.* --root .. .
working-directory: build
- name: Static Analysis Tests
if: matrix.static_analysis == 'ON' && runner.os == 'Linux'
run: |
sudo apt-get install cppcheck
cppcheck --project=build/compile_commands.json --error-exitcode=1 --suppress=*:*/External/* --suppress=*:*/NanoGUI/*
- name: Initialize Virtual Framebuffer
if: matrix.test_render == 'ON' && runner.os == 'Linux'
run: |
Xvfb :1 -screen 0 1280x960x24 &
echo "DISPLAY=:1" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
- name: Render Script Tests
if: matrix.test_render == 'ON'
run: |
mkdir build/render
python python/Scripts/baketextures.py resources/Materials/Examples/StandardSurface/standard_surface_brass_tiled.mtlx build/render/brass_average_baked.mtlx --average
python python/Scripts/translateshader.py resources/Materials/Examples/StandardSurface/standard_surface_carpaint.mtlx build/render/usd_preview_surface_carpaint.mtlx UsdPreviewSurface --hdr
- name: Render Application Tests
if: matrix.test_render == 'ON'
run: |
../installed/bin/MaterialXView --material brass_average_baked.mtlx --mesh ../../resources/Geometry/sphere.obj --screenWidth 128 --screenHeight 128 --cameraZoom 1.4 --shadowMap false --captureFilename Viewer_BrassAverage.png
../installed/bin/MaterialXView --material usd_preview_surface_carpaint.mtlx --mesh ../../resources/Geometry/sphere.obj --screenWidth 128 --screenHeight 128 --cameraZoom 1.4 --shadowMap false --captureFilename Viewer_CarpaintTranslated.png
../installed/bin/MaterialXGraphEditor --material ../../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --viewWidth 128 --viewHeight 128 --captureFilename GraphEditor_MarbleSolid.png
working-directory: build/render
- name: Upload Installed Package
if: matrix.python != 'None'
uses: actions/upload-artifact@v4
with:
name: MaterialX_${{ matrix.name }}
path: build/installed/
- name: Upload Formatted Source
if: matrix.clang_format == 'ON'
uses: actions/upload-artifact@v4
with:
name: MaterialX_ClangFormat
path: source
- name: Upload Reference Shaders
uses: actions/upload-artifact@v4
if: matrix.upload_shaders == 'ON'
with:
name: Reference_Shaders_${{ matrix.name }}
path: build/bin/reference/
- name: Upload Renders
uses: actions/upload-artifact@v4
if: matrix.test_render == 'ON'
with:
name: Renders_${{ matrix.name }}
path: build/render/*.png
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
if: matrix.coverage_analysis == 'ON'
with:
name: MaterialX_Coverage
path: build/coverage
- name: JavaScript CMake Generate
if: matrix.build_javascript == 'ON'
run: cmake -S . -B javascript/build -DMATERIALX_BUILD_JS=ON -DMATERIALX_EMSDK_PATH=${{ env.EMSDK }}
- name: JavaScript CMake Build
if: matrix.build_javascript == 'ON'
run: cmake --build javascript/build --target install --config Release --parallel 2
- name: JavaScript Unit Tests
if: matrix.build_javascript == 'ON'
run: |
npm install
npm run test
npm run test:browser
working-directory: javascript/MaterialXTest
- name: Build Web Viewer
if: matrix.build_javascript == 'ON'
run: |
npm install
npm run build
working-directory: javascript/MaterialXView
- name: Deploy Web Viewer
if: matrix.build_javascript == 'ON' && github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: javascript/MaterialXView/dist
single-commit: true
- name: Upload JavaScript Package
if: matrix.build_javascript == 'ON'
uses: actions/upload-artifact@v4
with:
name: MaterialX_JavaScript
path: javascript/build/installed/JavaScript/MaterialX
sdist:
name: Python SDist
runs-on: ubuntu-latest
if: github.repository == 'AcademySoftwareFoundation/MaterialX'
outputs:
sdist_filename: ${{ steps.generate.outputs.filename }}
steps:
- name: Sync Repository
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Build SDist
id: generate
run: |
python -m pip install build
python -m build -s . --outdir dist
echo "filename=$(ls dist)" >> "$GITHUB_OUTPUT"
- name: Upload SDist
uses: actions/upload-artifact@v4
with:
name: MaterialX_Python_SDist
path: dist/*.tar.gz
wheels:
name: Python Wheels
runs-on: ${{ matrix.os }}
needs: ['sdist']
if: github.repository == 'AcademySoftwareFoundation/MaterialX'
strategy:
fail-fast: false
matrix:
python-minor: ['7', '8', '9', '10', '11', '12']
os: ['ubuntu-latest', 'windows-2022', 'macos-13']
steps:
- name: Sync Repository
uses: actions/checkout@v4
- name: Install Python 3.${{ matrix.python-minor }}
uses: actions/setup-python@v5
with:
python-version: 3.${{ matrix.python-minor }}
- name: Download Sdist
uses: actions/download-artifact@v4
with:
name: MaterialX_Python_SDist
path: sdist
- name: Build Wheel
uses: pypa/[email protected]
with:
package-dir: ${{ github.workspace }}/sdist/${{ needs.sdist.outputs.sdist_filename }}
env:
CIBW_BUILD: 'cp3${{ matrix.python-minor }}-*'
CIBW_SKIP: '*musllinux*'
CIBW_ARCHS: 'auto64'
# https://github.com/pypa/manylinux
# manylinux2014 is CentOS 7 based. Which means GCC 10 and glibc 2.17.
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: yum install -y libXt-devel
CIBW_BUILD_VERBOSITY: 1
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
# CIBW_BUILD_FRONTEND: build # https://github.com/pypa/build
MACOSX_DEPLOYMENT_TARGET: '10.15'
- name: Install Wheel
run: python -m pip install MaterialX --find-links wheelhouse --no-index
- name: Python Tests
run: |
python MaterialXTest/main.py
python MaterialXTest/genshader.py
working-directory: python
- name: Upload Wheel
uses: actions/upload-artifact@v4
with:
name: MaterialX_Python_Wheel_${{ runner.os }}_3_${{ matrix.python-minor }}
path: wheelhouse/*.whl