From db80c00b154fb32fc06c9a2361303299702a921a Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 27 Feb 2020 14:00:15 +0000
Subject: [PATCH] build: Use a loop to reduce repetition when compiling shaders

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 helpers/meson.build | 58 ++++++++++++++++-----------------------------
 1 file changed, 20 insertions(+), 38 deletions(-)

diff --git a/helpers/meson.build b/helpers/meson.build
index 8f54e62e1..06436e5b2 100644
--- a/helpers/meson.build
+++ b/helpers/meson.build
@@ -80,45 +80,27 @@ executable(
   # and its associated drivers successfully.
 )
 
-custom_target(
-  'frag.spv',
-  build_by_default : true,
-  command : [
-    glslang_validator,
-    '--target-env', 'vulkan1.0',
-    '-o', '@OUTPUT@',
-    '@INPUT@',
-  ],
-  input : 'shader.frag',
-  output : 'frag.spv',
-  install : true,
-  install_dir : join_paths(
-    get_option('prefix'),
-    get_option('libexecdir'),
-    'steam-runtime-tools-' + api_major,
-    'shaders',
-  )
-)
-
-custom_target(
-  'vert.spv',
-  build_by_default : true,
-  command : [
-    glslang_validator,
-    '--target-env', 'vulkan1.0',
-    '-o', '@OUTPUT@',
-    '@INPUT@',
-  ],
-  input : 'shader.vert',
-  output : 'vert.spv',
-  install : true,
-  install_dir : join_paths(
-    get_option('prefix'),
-    get_option('libexecdir'),
-    'steam-runtime-tools-' + api_major,
-    'shaders',
+foreach shader : ['frag', 'vert']
+  custom_target(
+    shader + '.spv',
+    build_by_default : true,
+    command : [
+      glslang_validator,
+      '--target-env', 'vulkan1.0',
+      '-o', '@OUTPUT@',
+      '@INPUT@',
+    ],
+    input : 'shader.' + shader,
+    output : shader + '.spv',
+    install : true,
+    install_dir : join_paths(
+      get_option('prefix'),
+      get_option('libexecdir'),
+      'steam-runtime-tools-' + api_major,
+      'shaders',
+    )
   )
-)
+endforeach
 
 executable(
   multiarch + '-check-gl',
-- 
GitLab