Fix builds that disable tint_build_spv_reader
If tint_build_spv_reader = false is set in a Chrome's build_overrides
then the tint_unittests_spv_reader_src begins failing with a bunch of
missing spvtools identifiers.
Most uses of spv_reader_src include it as a conditional dependency only
when tint_build_spv_reader is true, Chrome's `all` target always builds
it. This causes problems when critical includes are excluded due to the
tint_build_spv_reader setting. The solution is to not make use of the
TINT_BUILD_SPV_READER define at all in this subdirectory and instead
assume that the entire directory will be included or excluded as needed
at a higher level.
Additionally, one switch statement in tint_common_fuzzer needed to have
the scope of it's TINT_BUILD_SPV_READER exclusion reduced so that it
wouldn't trigger warnings that not all enum values were covered.
Bug: dawn:286
Change-Id: I53518e2fda497fe976721b5f087e2e21a170f5dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117244
Reviewed-by: dan sinclair <dsinclair@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/fuzzers/tint_common_fuzzer.cc b/src/tint/fuzzers/tint_common_fuzzer.cc
index 15ab7d8..11cdf76 100644
--- a/src/tint/fuzzers/tint_common_fuzzer.cc
+++ b/src/tint/fuzzers/tint_common_fuzzer.cc
@@ -149,8 +149,8 @@
#endif
switch (input_) {
-#if TINT_BUILD_WGSL_READER
case InputFormat::kWGSL: {
+#if TINT_BUILD_WGSL_READER
// Clear any existing diagnostics, as these will hold pointers to file_,
// which we are about to release.
diagnostics_ = {};
@@ -160,11 +160,12 @@
dump_input_data(str, ".wgsl");
}
program = reader::wgsl::Parse(file_.get());
+#endif // TINT_BUILD_WGSL_READER
break;
}
-#endif // TINT_BUILD_WGSL_READER
-#if TINT_BUILD_SPV_READER
+
case InputFormat::kSpv: {
+#if TINT_BUILD_SPV_READER
// `spirv_input` has been initialized with the capacity to store `size /
// sizeof(uint32_t)` uint32_t values. If `size` is not a multiple of
// sizeof(uint32_t) then not all of `data` can be copied into
@@ -177,9 +178,9 @@
dump_input_data(spirv_input, ".spv");
}
program = reader::spirv::Parse(spirv_input);
+#endif // TINT_BUILD_SPV_READER
break;
}
-#endif // TINT_BUILD_SPV_READER
}
if (!program.IsValid()) {
diff --git a/src/tint/reader/spirv/parser_impl.h b/src/tint/reader/spirv/parser_impl.h
index 9ff9033..7713734 100644
--- a/src/tint/reader/spirv/parser_impl.h
+++ b/src/tint/reader/spirv/parser_impl.h
@@ -25,7 +25,6 @@
#include "src/tint/utils/compiler_macros.h"
#include "src/tint/utils/hashmap.h"
-#if TINT_BUILD_SPV_READER
TINT_BEGIN_DISABLE_WARNING(NEWLINE_EOF);
TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST);
TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION);
@@ -35,7 +34,6 @@
TINT_END_DISABLE_WARNING(SIGN_CONVERSION);
TINT_END_DISABLE_WARNING(OLD_STYLE_CAST);
TINT_END_DISABLE_WARNING(NEWLINE_EOF);
-#endif
#include "src/tint/program_builder.h"
#include "src/tint/reader/reader.h"
diff --git a/src/tint/reader/spirv/parser_impl_test_helper.h b/src/tint/reader/spirv/parser_impl_test_helper.h
index d1b0e35..ea0e37e 100644
--- a/src/tint/reader/spirv/parser_impl_test_helper.h
+++ b/src/tint/reader/spirv/parser_impl_test_helper.h
@@ -23,7 +23,6 @@
#include "src/tint/utils/compiler_macros.h"
-#if TINT_BUILD_SPV_READER
TINT_BEGIN_DISABLE_WARNING(NEWLINE_EOF);
TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST);
TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION);
@@ -33,7 +32,6 @@
TINT_END_DISABLE_WARNING(SIGN_CONVERSION);
TINT_END_DISABLE_WARNING(OLD_STYLE_CAST);
TINT_END_DISABLE_WARNING(NEWLINE_EOF);
-#endif
#include "gtest/gtest.h"
#include "src/tint/demangler.h"