[tint][ir][fuzz] Fix breakage of fuzz_cmd target for CMake
Adding an explicit dependency of fuzz.proto on ir.proto was causing
issues with how libprotobuf was being included in the target (two
different link rules with different visibility).
Additionally, this makes the guard on the building the IR fuzzer
explicitly include IR binary being built, since that can be infered
based on if libprotobuf is present, so it is possible to turn on the
IR fuzzer, but not have IR binary available because protobuf was
turned off.
Fixes: 347031381
Change-Id: Ie4ab057a52c6b067476c07794c21baf8651d7ac9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/193621
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
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 a820043..3a59059 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -680,7 +680,7 @@
PROTOC_OUT_DIR "${DAWN_BUILD_GEN_DIR}")
target_include_directories(${PROTO_TARGET} PRIVATE "${DAWN_BUILD_GEN_DIR}/src/tint/")
target_include_directories(${PROTO_TARGET} PUBLIC "${DAWN_BUILD_GEN_DIR}")
- target_link_libraries(${PROTO_TARGET} libprotobuf)
+ target_link_libraries(${PROTO_TARGET} PUBLIC libprotobuf)
endforeach()
endif()
diff --git a/src/tint/cmd/fuzz/ir/BUILD.bazel b/src/tint/cmd/fuzz/ir/BUILD.bazel
index c0f5235..68cf24d 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.bazel
+++ b/src/tint/cmd/fuzz/ir/BUILD.bazel
@@ -77,3 +77,11 @@
actual = "//src/tint:tint_build_wgsl_writer_true",
)
+selects.config_setting_group(
+ name = "tint_build_ir_binary_and_tint_build_ir_fuzzer",
+ match_all = [
+ ":tint_build_ir_binary",
+ ":tint_build_ir_fuzzer",
+ ],
+)
+
diff --git a/src/tint/cmd/fuzz/ir/BUILD.cfg b/src/tint/cmd/fuzz/ir/BUILD.cfg
index efdf654..8728766 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.cfg
+++ b/src/tint/cmd/fuzz/ir/BUILD.cfg
@@ -1,12 +1,12 @@
{
"proto": {
- "Condition": "tint_build_ir_fuzzer",
+ "Condition": "tint_build_ir_binary && tint_build_ir_fuzzer",
"AdditionalDependencies": {
"Internal": [ "lang/core/ir/binary:proto" ]
}
},
"fuzz_cmd": {
- "Condition": "tint_build_ir_fuzzer",
+ "Condition": "tint_build_ir_binary && tint_build_ir_fuzzer",
/* The Tint fuzzer executable for IR-input. */
"OutputName": "tint_ir_fuzzer",
"AdditionalDependencies": {
diff --git a/src/tint/cmd/fuzz/ir/BUILD.cmake b/src/tint/cmd/fuzz/ir/BUILD.cmake
index fa416fc..356e8c4 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.cmake
+++ b/src/tint/cmd/fuzz/ir/BUILD.cmake
@@ -34,11 +34,11 @@
# Do not modify this file directly
################################################################################
-if(TINT_BUILD_IR_FUZZER)
+if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
################################################################################
# Target: tint_cmd_fuzz_ir_proto
# Kind: proto
-# Condition: TINT_BUILD_IR_FUZZER
+# Condition: TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER
################################################################################
tint_add_target(tint_cmd_fuzz_ir_proto proto
cmd/fuzz/ir/fuzz.proto
@@ -50,12 +50,12 @@
)
endif(TINT_BUILD_IR_BINARY)
-endif(TINT_BUILD_IR_FUZZER)
-if(TINT_BUILD_IR_FUZZER)
+endif(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
+if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
################################################################################
# Target: tint_cmd_fuzz_ir_fuzz_cmd
# Kind: fuzz_cmd
-# Condition: TINT_BUILD_IR_FUZZER
+# Condition: TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER
################################################################################
tint_add_target(tint_cmd_fuzz_ir_fuzz_cmd fuzz_cmd
cmd/fuzz/ir/main_fuzz.cc
@@ -113,11 +113,11 @@
)
endif(TINT_BUILD_IR_BINARY)
-if(TINT_BUILD_IR_FUZZER)
+if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
tint_target_add_dependencies(tint_cmd_fuzz_ir_fuzz_cmd fuzz_cmd
tint_cmd_fuzz_ir_proto
)
-endif(TINT_BUILD_IR_FUZZER)
+endif(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
if(TINT_BUILD_MSL_WRITER)
tint_target_add_dependencies(tint_cmd_fuzz_ir_fuzz_cmd fuzz_cmd
@@ -146,7 +146,7 @@
tint_target_set_output_name(tint_cmd_fuzz_ir_fuzz_cmd fuzz_cmd "tint_ir_fuzzer")
-endif(TINT_BUILD_IR_FUZZER)
+endif(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
################################################################################
# Target: tint_cmd_fuzz_ir_fuzz
# Kind: fuzz
diff --git a/src/tint/cmd/fuzz/ir/BUILD.gn b/src/tint/cmd/fuzz/ir/BUILD.gn
index 011934b..222afe1 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.gn
+++ b/src/tint/cmd/fuzz/ir/BUILD.gn
@@ -37,7 +37,7 @@
import("../../../../../scripts/tint_overrides_with_defaults.gni")
import("${tint_src_dir}/tint.gni")
-if (tint_build_ir_fuzzer) {
+if (tint_build_ir_binary && tint_build_ir_fuzzer) {
tint_proto_library("proto") {
sources = [ "fuzz.proto" ]
deps = []
@@ -90,7 +90,7 @@
]
}
}
-if (tint_build_ir_fuzzer) {
+if (tint_build_ir_binary && tint_build_ir_fuzzer) {
tint_fuzzer_test("ir") {
output_name = "tint_ir_fuzzer"
sources = [ "main_fuzz.cc" ]
@@ -139,7 +139,7 @@
]
}
- if (tint_build_ir_fuzzer) {
+ if (tint_build_ir_binary && tint_build_ir_fuzzer) {
deps += [ "${tint_src_dir}/cmd/fuzz/ir:proto" ]
}