From 552413cc34423d15e96b13e61d5fb89fbbbb8c05 Mon Sep 17 00:00:00 2001 From: Jay Shen Date: Sun, 11 Jan 2026 18:30:07 +0800 Subject: [PATCH] infra: add Meson GL backend option for examples Introduce meson_options.txt with a gl_backend selector and use it to choose GL vs GLES deps/flags; update the GL target call signature in MultiCanvas for the new API. --- meson_options.txt | 5 +++++ src/meson.build | 23 ++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 meson_options.txt diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..6966579 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,5 @@ +option('gl_backend', + type: 'combo', + choices: ['gl', 'gles'], + value: 'gl', + description: 'Select GL backend for examples (gl, gles)') diff --git a/src/meson.build b/src/meson.build index 6968f90..64e21ea 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,16 +4,25 @@ examples_dep = [thorvg_dep, dependency('sdl2', required: true)] compiler_flags = ['-DSDL_MAIN_HANDLED'] # GL or GLES +gl_backend = get_option('gl_backend') gl_dep = dependency('gl', required: false) gles_dep = dependency('glesv2', required: false) +egl_dep = dependency('egl', required: false) -if gl_dep.found() - examples_dep += gl_dep -elif gles_dep.found() - examples_dep += gles_dep - compiler_flags += ['-DTVGEXAMPLE_GLES_SUPPORTED'] -else - message('Neither OpenGL nor OpenGL ES was found. Skipping GL examples.') +if gl_backend == 'gl' + if gl_dep.found() + examples_dep += gl_dep + compiler_flags += ['-DTVGEXAMPLE_GL_SUPPORTED'] + else + message('Requested OpenGL but it was not found. Skipping GL examples.') + endif +elif gl_backend == 'gles' + if gles_dep.found() and egl_dep.found() + examples_dep += [gles_dep, egl_dep] + compiler_flags += ['-DTVGEXAMPLE_GLES_SUPPORTED'] + else + message('Requested OpenGL ES but it was not found. Skipping GL examples.') + endif endif # WebGPU