aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-06 23:53:33 +0100
committerDavid Robillard <d@drobilla.net>2021-01-08 18:13:49 +0100
commit69d5d2adde1d13578a94e8b1934235987cf9b2bd (patch)
tree9720c044447bb12e6e714ac969ebb7b0daf87c5f /examples
parent94e30b9c3c188dfdf4765f026872f95ea3cfdda2 (diff)
downloadpugl-69d5d2adde1d13578a94e8b1934235987cf9b2bd.tar.gz
pugl-69d5d2adde1d13578a94e8b1934235987cf9b2bd.tar.bz2
pugl-69d5d2adde1d13578a94e8b1934235987cf9b2bd.zip
Switch to Meson
Diffstat (limited to 'examples')
-rw-r--r--examples/meson.build80
-rw-r--r--examples/shaders/meson.build35
2 files changed, 115 insertions, 0 deletions
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..d455faf
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,80 @@
+data_dir = get_option('prefix') / get_option('datadir') / 'pugl-0'
+example_args = ['-DPUGL_DATA_DIR="@0@"'.format(data_dir)]
+
+gl_examples = [
+ 'pugl_cxx_demo.cpp',
+ 'pugl_embed_demo.c',
+ 'pugl_print_events.c',
+ 'pugl_shader_demo.c',
+ 'pugl_window_demo.c',
+]
+
+cairo_examples = [
+ 'pugl_cairo_demo.c'
+]
+
+vulkan_examples = [
+ 'pugl_vulkan_cxx_demo.cpp',
+ 'pugl_vulkan_demo.c',
+]
+
+includes = [
+ '.',
+ '..',
+ '../bindings/cxx/include',
+ '../include',
+]
+
+subdir('shaders')
+
+# Build GL examples
+if opengl_dep.found()
+ foreach example : gl_examples
+ source = [example]
+ target = example.split('.')[0]
+ dependencies = [gl_backend_dep]
+
+ if target == 'pugl_shader_demo'
+ source += ['file_utils.c', 'glad/glad.c']
+ dependencies += [dl_dep]
+ elif target == 'pugl_print_events'
+ dependencies += [stub_backend_dep]
+ endif
+
+ executable(target, source,
+ include_directories: include_directories(includes),
+ c_args: example_args,
+ cpp_args: example_args,
+ dependencies: dependencies)
+ endforeach
+endif
+
+# Build Cairo examples
+if cairo_dep.found()
+ foreach example : cairo_examples
+ target = example.split('.')[0]
+ executable(target, example,
+ include_directories: include_directories(includes),
+ c_args: example_args,
+ dependencies: [pugl_dep, cairo_backend_dep])
+ endforeach
+endif
+
+# Build Vulkan examples
+if vulkan_dep.found()
+ foreach example : vulkan_examples
+ source = [example]
+ target = example.split('.')[0]
+ dependencies = [dl_dep, vulkan_backend_dep]
+
+ if target == 'pugl_vulkan_cxx_demo'
+ source += ['file_utils.c']
+ endif
+
+ executable(target, source,
+ include_directories: include_directories(includes),
+ c_args: example_args,
+ cpp_args: example_args,
+ dependencies: dependencies)
+ endforeach
+endif
diff --git a/examples/shaders/meson.build b/examples/shaders/meson.build
new file mode 100644
index 0000000..e47be9d
--- /dev/null
+++ b/examples/shaders/meson.build
@@ -0,0 +1,35 @@
+shader_files = [
+ 'header_330.glsl',
+ 'header_420.glsl',
+ 'rect.frag',
+ 'rect.vert',
+]
+
+# Copy shader sources for GL examples
+foreach shader_file : shader_files
+ configure_file(copy: true, input: shader_file, output: shader_file)
+endforeach
+
+# Build SPV shader binaries for Vulkan examples
+if vulkan_dep.found()
+ cat = find_program('../../scripts/cat.py')
+ glslang = find_program('glslangValidator')
+
+ shaders = ['rect.vert', 'rect.frag']
+ foreach shader : shaders
+ source = shader.split('.')[0] + '.vulkan.' + shader.split('.')[1]
+ shader_input = custom_target(source,
+ output: source,
+ input: ['header_420.glsl', shader],
+ command: [cat, '@INPUT@'],
+ build_by_default: true,
+ capture: true)
+
+ mytarget = custom_target(shader,
+ output: shader + '.spv',
+ input: shader_input,
+ command: [glslang, '-V', '-o', '@OUTPUT@', '@INPUT@'],
+ build_by_default: true,
+ install: false)
+ endforeach
+endif