[tint][bench] Fix linker errors for certain build
Not all builds have TINT_BUILD_SPV_READER enabled.
Guard the logic that uses this with a preprocessor flag.
Change-Id: I870c2bd402f87b02b50e99a60c20fcdc1236c9e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/154320
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/tint/cmd/bench/bench.cc b/src/tint/cmd/bench/bench.cc
index f9cb65e..0bdb5d8 100644
--- a/src/tint/cmd/bench/bench.cc
+++ b/src/tint/cmd/bench/bench.cc
@@ -102,13 +102,18 @@
Result<Source::File> LoadInputFile(std::string name) {
auto path = std::filesystem::path(name).is_absolute() ? name : (kInputFileDir / name).string();
if (tint::HasSuffix(path, ".wgsl")) {
+#if TINT_BUILD_WGSL_READER
auto data = ReadFile<uint8_t>(path);
if (!data) {
return data.Failure();
}
return tint::Source::File(path, std::string(data->begin(), data->end()));
+#else
+ return Failure{"cannot load " + path + " file as TINT_BUILD_WGSL_READER is not enabled"};
+#endif
}
if (tint::HasSuffix(path, ".spv")) {
+#if TINT_BUILD_SPV_READER
auto spirv = ReadFile<uint32_t>(path);
if (spirv) {
auto program = tint::spirv::reader::Read(spirv.Get(), {});
@@ -122,6 +127,9 @@
return tint::Source::File(path, result->wgsl);
}
return spirv.Failure();
+#else
+ return Failure{"cannot load " + path + " as TINT_BUILD_SPV_READER is not enabled"};
+#endif
}
return Failure{"unsupported file extension: '" + name + "'"};
}