[tint] Auto-generate a benchmark input header

The Chrome Perf waterfall prefers test binaries to be standalone with
no runtime dependencies. This script collects all WGSL and SPIR-V
shaders in `test/tint/benchmark/` and converts them to string literals
and constant arrays in a single header file that can be included by
the benchmark binary. It also defines the macro that registers each of
these shaders with Google Benchmark.

Bug: 42251293
Change-Id: I778d7395ea64988705bbbb624f7e5b5abb8a4920
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/200515
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 7e67586..0e0ff6e 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -259,6 +259,7 @@
 
 function(tint_bench_compile_options TARGET)
   tint_core_compile_options(${TARGET})
+  target_include_directories(${TARGET} PUBLIC "${DAWN_BUILD_GEN_DIR}")
   set_target_properties(${TARGET} PROPERTIES FOLDER "Benchmarks")
 endfunction()
 
@@ -320,6 +321,18 @@
 ################################################################################
 # Benchmarks
 ################################################################################
+if(TINT_BUILD_BENCHMARKS)
+  set(SCRIPT "${TINT_ROOT_SOURCE_DIR}/src/tint/cmd/bench/generate_benchmark_inputs.py")
+  set(OUTPUT "${DAWN_BUILD_GEN_DIR}/src/tint/cmd/bench/benchmark_inputs.h")
+  set(ARGS ${Python3_EXECUTABLE} ${SCRIPT} ${OUTPUT})
+  add_custom_command(
+    COMMAND ${ARGS}
+    OUTPUT ${OUTPUT}
+    DEPENDS ${SCRIPT}
+    COMMENT "Tint benchmark: Generating ${OUTPUT}."
+  )
+  add_custom_target(tint_generate_benchmark_inputs DEPENDS ${OUTPUT})
+endif()
 if(TINT_BUILD_BENCHMARKS AND TINT_EXTERNAL_BENCHMARK_CORPUS_DIR)
   # Glob all the files at TINT_EXTERNAL_BENCHMARK_CORPUS_DIR, and create a header
   # that lists these with the macros: