[tint][benchmark] Depend on auto-generated header
For GN, add a new source set template for benchmarks instead of
re-using the unittests template, and add the dependency there.
For CMake, add the dependency to the special case for benchmark
options that we already had.
Bug: 42251289
Change-Id: I9e034763d7fdb707d958c0a1c76fad4ca4df531d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/200540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 0e0ff6e..93d2772 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})
+ add_dependencies(${TARGET} tint_generate_benchmark_inputs)
target_include_directories(${TARGET} PUBLIC "${DAWN_BUILD_GEN_DIR}")
set_target_properties(${TARGET} PROPERTIES FOLDER "Benchmarks")
endfunction()
diff --git a/src/tint/cmd/bench/BUILD.gn b/src/tint/cmd/bench/BUILD.gn
index 329bec4..ba216a0 100644
--- a/src/tint/cmd/bench/BUILD.gn
+++ b/src/tint/cmd/bench/BUILD.gn
@@ -44,7 +44,7 @@
if (tint_build_benchmarks) {
if (tint_build_spv_reader && tint_build_wgsl_reader &&
tint_build_wgsl_writer) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [
"bench.cc",
"bench.h",
diff --git a/src/tint/lang/core/BUILD.gn b/src/tint/lang/core/BUILD.gn
index 19b128a..fe38ed3 100644
--- a/src/tint/lang/core/BUILD.gn
+++ b/src/tint/lang/core/BUILD.gn
@@ -130,7 +130,7 @@
}
}
if (tint_build_benchmarks) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [
"access_bench.cc",
"address_space_bench.cc",
diff --git a/src/tint/lang/glsl/writer/BUILD.gn b/src/tint/lang/glsl/writer/BUILD.gn
index 830c65c..a4e3430 100644
--- a/src/tint/lang/glsl/writer/BUILD.gn
+++ b/src/tint/lang/glsl/writer/BUILD.gn
@@ -89,7 +89,7 @@
if (tint_build_benchmarks) {
if (tint_build_glsl_writer && tint_build_spv_reader &&
tint_build_wgsl_reader && tint_build_wgsl_writer) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [ "writer_bench.cc" ]
deps = [
"${tint_src_dir}:google_benchmark",
diff --git a/src/tint/lang/hlsl/writer/BUILD.gn b/src/tint/lang/hlsl/writer/BUILD.gn
index c7f164d..8ed285d 100644
--- a/src/tint/lang/hlsl/writer/BUILD.gn
+++ b/src/tint/lang/hlsl/writer/BUILD.gn
@@ -146,7 +146,7 @@
if (tint_build_benchmarks) {
if (tint_build_hlsl_writer && tint_build_spv_reader &&
tint_build_wgsl_reader && tint_build_wgsl_writer) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [ "writer_bench.cc" ]
deps = [
"${tint_src_dir}:google_benchmark",
diff --git a/src/tint/lang/msl/writer/BUILD.gn b/src/tint/lang/msl/writer/BUILD.gn
index ab97d19..20e0624 100644
--- a/src/tint/lang/msl/writer/BUILD.gn
+++ b/src/tint/lang/msl/writer/BUILD.gn
@@ -138,7 +138,7 @@
if (tint_build_benchmarks) {
if (tint_build_msl_writer && tint_build_spv_reader &&
tint_build_wgsl_reader && tint_build_wgsl_writer) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [ "writer_bench.cc" ]
deps = [
"${tint_src_dir}:google_benchmark",
diff --git a/src/tint/lang/spirv/writer/BUILD.gn b/src/tint/lang/spirv/writer/BUILD.gn
index e7bd0e5..2307e97 100644
--- a/src/tint/lang/spirv/writer/BUILD.gn
+++ b/src/tint/lang/spirv/writer/BUILD.gn
@@ -160,7 +160,7 @@
if (tint_build_benchmarks) {
if (tint_build_spv_writer && tint_build_spv_reader &&
tint_build_wgsl_reader && tint_build_wgsl_writer) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [ "writer_bench.cc" ]
deps = [
"${tint_src_dir}:google_benchmark",
diff --git a/src/tint/lang/wgsl/BUILD.gn b/src/tint/lang/wgsl/BUILD.gn
index f6c072a..7afe4de 100644
--- a/src/tint/lang/wgsl/BUILD.gn
+++ b/src/tint/lang/wgsl/BUILD.gn
@@ -122,7 +122,7 @@
}
}
if (tint_build_benchmarks) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [
"diagnostic_rule_bench.cc",
"diagnostic_severity_bench.cc",
diff --git a/src/tint/lang/wgsl/reader/BUILD.gn b/src/tint/lang/wgsl/reader/BUILD.gn
index 26601c7..6ed1c04 100644
--- a/src/tint/lang/wgsl/reader/BUILD.gn
+++ b/src/tint/lang/wgsl/reader/BUILD.gn
@@ -116,7 +116,7 @@
if (tint_build_benchmarks) {
if (tint_build_wgsl_reader && tint_build_spv_reader &&
tint_build_wgsl_reader && tint_build_wgsl_writer) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [ "reader_bench.cc" ]
deps = [
"${tint_src_dir}:google_benchmark",
diff --git a/src/tint/lang/wgsl/writer/BUILD.gn b/src/tint/lang/wgsl/writer/BUILD.gn
index d3c44ff..79daccb 100644
--- a/src/tint/lang/wgsl/writer/BUILD.gn
+++ b/src/tint/lang/wgsl/writer/BUILD.gn
@@ -135,7 +135,7 @@
if (tint_build_benchmarks) {
if (tint_build_wgsl_writer && tint_build_spv_reader &&
tint_build_wgsl_reader && tint_build_wgsl_writer) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [ "writer_bench.cc" ]
deps = [
"${tint_src_dir}:google_benchmark",
diff --git a/src/tint/tint.gni b/src/tint/tint.gni
index c21cec0..dcefe10 100644
--- a/src/tint/tint.gni
+++ b/src/tint/tint.gni
@@ -128,6 +128,36 @@
}
###############################################################################
+# Benchmarks - only built when tint_build_benchmarks is enabled
+###############################################################################
+template("tint_benchmarks_source_set") {
+ if (tint_build_benchmarks) {
+ source_set(target_name) {
+ forward_variables_from(invoker, "*", [ "configs" ])
+
+ testonly = true
+
+ if (defined(invoker.configs)) {
+ configs += invoker.configs
+ }
+
+ configs += [ "${tint_src_dir}:tint_common_config" ]
+
+ if (build_with_chromium) {
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [ "//build/config/compiler:no_chromium_code" ]
+ }
+
+ if (!defined(invoker.deps)) {
+ deps = []
+ }
+
+ deps += [ "${tint_src_dir}:generate_benchmark_inputs" ]
+ }
+ }
+}
+
+###############################################################################
# Fuzzers - only built when tint_has_fuzzers is enabled
###############################################################################
if (tint_has_fuzzers) {
diff --git a/src/tint/utils/rtti/BUILD.gn b/src/tint/utils/rtti/BUILD.gn
index f4bdbb1..5f88e84 100644
--- a/src/tint/utils/rtti/BUILD.gn
+++ b/src/tint/utils/rtti/BUILD.gn
@@ -75,7 +75,7 @@
}
}
if (tint_build_benchmarks) {
- tint_unittests_source_set("bench") {
+ tint_benchmarks_source_set("bench") {
sources = [ "switch_bench.cc" ]
deps = [
"${tint_src_dir}:google_benchmark",
diff --git a/tools/src/cmd/gen/build/BUILD.gn.tmpl b/tools/src/cmd/gen/build/BUILD.gn.tmpl
index a5c308f..df7c41b 100644
--- a/tools/src/cmd/gen/build/BUILD.gn.tmpl
+++ b/tools/src/cmd/gen/build/BUILD.gn.tmpl
@@ -64,7 +64,7 @@
{{- else if $.Kind.IsTest -}}
tint_unittests_source_set("unittests") {
{{- else if $.Kind.IsBench -}}
-tint_unittests_source_set("bench") {
+tint_benchmarks_source_set("bench") {
{{- else if $.Kind.IsFuzz -}}
tint_fuzz_source_set("fuzz") {
{{- else if $.Kind.IsTestCmd -}}