Fix build when TINT_BUILD_[WGSL|SPV|MSL|HLSL]_[READER|WRITER] are toggled off

- Locally tested with each of the 6 options turned off alone, and fixed
the build.

- Added an incremental build to the Linux Kokoro build with all these
flags disabled, which will help catch a subset of build issues related
to these flags.

Bug: tint:1139
Change-Id: I40eaaea31d88879aa19eac3f17c47b7e7d7a477f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63241
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2021-09-03 14:16:56 +00:00 committed by Tint LUCI CQ
parent 937a658b58
commit 604c70d3e6
6 changed files with 62 additions and 32 deletions

View File

@ -150,8 +150,16 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then
status "Checking _other.cc files also build" status "Checking _other.cc files also build"
show_cmds show_cmds
cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_AS_OTHER_OS=1 cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_AS_OTHER_OS=ON
cmake --build . -- --jobs=$(nproc) cmake --build . -- --jobs=$(nproc)
cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_AS_OTHER_OS=OFF
hide_cmds
status "Checking disabling all readers and writers also builds"
show_cmds
cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_SPV_READER=OFF -DTINT_BUILD_SPV_WRITER=OFF -DTINT_BUILD_WGSL_READER=OFF -DTINT_BUILD_WGSL_WRITER=OFF -DTINT_BUILD_MSL_WRITER=OFF -DTINT_BUILD_HLSL_WRITER=OFF
cmake --build . -- --jobs=$(nproc)
cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_SPV_READER=ON -DTINT_BUILD_SPV_WRITER=ON -DTINT_BUILD_WGSL_READER=ON -DTINT_BUILD_WGSL_WRITER=ON -DTINT_BUILD_MSL_WRITER=ON -DTINT_BUILD_HLSL_WRITER=ON
hide_cmds hide_cmds
else else
status "Unsupported build system: $BUILD_SYSTEM" status "Unsupported build system: $BUILD_SYSTEM"

View File

@ -117,16 +117,8 @@ const char kUsage[] = R"(Usage: tint [options] <input-file>
--xcrun -- Path to xcrun executable, used to validate MSL output. --xcrun -- Path to xcrun executable, used to validate MSL output.
When specified, automatically enables --validate)"; When specified, automatically enables --validate)";
#ifdef _MSC_VER
#pragma warning(disable : 4068; suppress : 4100)
#endif
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
Format parse_format(const std::string& fmt) { Format parse_format(const std::string& fmt) {
#pragma clang diagnostic pop (void)fmt;
#ifdef _MSC_VER
#pragma warning(default : 4068)
#endif
#if TINT_BUILD_SPV_WRITER #if TINT_BUILD_SPV_WRITER
if (fmt == "spirv") if (fmt == "spirv")
@ -153,6 +145,8 @@ Format parse_format(const std::string& fmt) {
return Format::kNone; return Format::kNone;
} }
#if TINT_BUILD_SPV_WRITER || TINT_BUILD_WGSL_WRITER || \
TINT_BUILD_MSL_WRITER || TINT_BUILD_HLSL_WRITER
/// @param input input string /// @param input input string
/// @param suffix potential suffix string /// @param suffix potential suffix string
/// @returns true if input ends with the given suffix. /// @returns true if input ends with the given suffix.
@ -163,19 +157,12 @@ bool ends_with(const std::string& input, const std::string& suffix) {
return (input_len >= suffix_len) && return (input_len >= suffix_len) &&
(input_len - suffix_len == input.rfind(suffix)); (input_len - suffix_len == input.rfind(suffix));
} }
#endif
/// @param filename the filename to inspect /// @param filename the filename to inspect
/// @returns the inferred format for the filename suffix /// @returns the inferred format for the filename suffix
#ifdef _MSC_VER
#pragma warning(disable : 4068; suppress : 4100)
#endif
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
Format infer_format(const std::string& filename) { Format infer_format(const std::string& filename) {
#pragma clang diagnostic pop (void)filename;
#ifdef _MSC_VER
#pragma warning(default : 4068)
#endif
#if TINT_BUILD_SPV_WRITER #if TINT_BUILD_SPV_WRITER
if (ends_with(filename, ".spv")) { if (ends_with(filename, ".spv")) {
@ -609,6 +596,9 @@ void PrintWGSL(std::ostream& out, const tint::Program& program) {
tint::writer::wgsl::Options options; tint::writer::wgsl::Options options;
auto result = tint::writer::wgsl::Generate(&program, options); auto result = tint::writer::wgsl::Generate(&program, options);
out << std::endl << result.wgsl << std::endl; out << std::endl << result.wgsl << std::endl;
#else
(void)out;
(void)program;
#endif #endif
} }
@ -654,6 +644,8 @@ bool GenerateSpirv(const tint::Program* program, const Options& options) {
return true; return true;
#else #else
(void)program;
(void)options;
std::cerr << "SPIR-V writer not enabled in tint build" << std::endl; std::cerr << "SPIR-V writer not enabled in tint build" << std::endl;
return false; return false;
#endif // TINT_BUILD_SPV_WRITER #endif // TINT_BUILD_SPV_WRITER
@ -675,6 +667,8 @@ bool GenerateWgsl(const tint::Program* program, const Options& options) {
return WriteFile(options.output_file, "w", result.wgsl); return WriteFile(options.output_file, "w", result.wgsl);
#else #else
(void)program;
(void)options;
std::cerr << "WGSL writer not enabled in tint build" << std::endl; std::cerr << "WGSL writer not enabled in tint build" << std::endl;
return false; return false;
#endif // TINT_BUILD_WGSL_WRITER #endif // TINT_BUILD_WGSL_WRITER
@ -788,6 +782,8 @@ bool GenerateMsl(const tint::Program* program, const Options& options) {
return true; return true;
#else #else
(void)program;
(void)options;
std::cerr << "MSL writer not enabled in tint build" << std::endl; std::cerr << "MSL writer not enabled in tint build" << std::endl;
return false; return false;
#endif // TINT_BUILD_MSL_WRITER #endif // TINT_BUILD_MSL_WRITER
@ -841,6 +837,8 @@ bool GenerateHlsl(const tint::Program* program, const Options& options) {
return true; return true;
#else #else
(void)program;
(void)options;
std::cerr << "HLSL writer not enabled in tint build" << std::endl; std::cerr << "HLSL writer not enabled in tint build" << std::endl;
return false; return false;
#endif // TINT_BUILD_HLSL_WRITER #endif // TINT_BUILD_HLSL_WRITER
@ -990,22 +988,22 @@ int main(int argc, const char** argv) {
} }
switch (options.format) { switch (options.format) {
#if TINT_BUILD_MSL_WRITER
case Format::kMsl: { case Format::kMsl: {
#if TINT_BUILD_MSL_WRITER
transform_inputs.Add<tint::transform::Renamer::Config>( transform_inputs.Add<tint::transform::Renamer::Config>(
tint::transform::Renamer::Target::kMslKeywords); tint::transform::Renamer::Target::kMslKeywords);
transform_manager.Add<tint::transform::Renamer>(); transform_manager.Add<tint::transform::Renamer>();
#endif // TINT_BUILD_MSL_WRITER
break; break;
} }
#endif // TINT_BUILD_MSL_WRITER
#if TINT_BUILD_HLSL_WRITER
case Format::kHlsl: { case Format::kHlsl: {
#if TINT_BUILD_HLSL_WRITER
transform_inputs.Add<tint::transform::Renamer::Config>( transform_inputs.Add<tint::transform::Renamer::Config>(
tint::transform::Renamer::Target::kHlslKeywords); tint::transform::Renamer::Target::kHlslKeywords);
transform_manager.Add<tint::transform::Renamer>(); transform_manager.Add<tint::transform::Renamer>();
#endif // TINT_BUILD_HLSL_WRITER
break; break;
} }
#endif // TINT_BUILD_HLSL_WRITER
default: default:
break; break;
} }

View File

@ -639,11 +639,6 @@ if(${TINT_BUILD_TESTS})
demangler_test.cc demangler_test.cc
diagnostic/formatter_test.cc diagnostic/formatter_test.cc
diagnostic/printer_test.cc diagnostic/printer_test.cc
inspector/inspector_test.cc
inspector/test_inspector_builder.cc
inspector/test_inspector_builder.h
inspector/test_inspector_runner.cc
inspector/test_inspector_runner.h
intrinsic_table_test.cc intrinsic_table_test.cc
program_test.cc program_test.cc
resolver/assignment_validation_test.cc resolver/assignment_validation_test.cc
@ -720,6 +715,17 @@ if(${TINT_BUILD_TESTS})
writer/text_generator_test.cc writer/text_generator_test.cc
) )
# Inspector tests depend on WGSL reader
if(${TINT_BUILD_WGSL_READER})
list(APPEND TINT_TEST_SRCS
inspector/inspector_test.cc
inspector/test_inspector_builder.cc
inspector/test_inspector_builder.h
inspector/test_inspector_runner.cc
inspector/test_inspector_runner.h
)
endif()
if(${TINT_BUILD_SPV_READER}) if(${TINT_BUILD_SPV_READER})
list(APPEND TINT_TEST_SRCS list(APPEND TINT_TEST_SRCS
reader/spirv/enum_converter_test.cc reader/spirv/enum_converter_test.cc
@ -839,9 +845,10 @@ if(${TINT_BUILD_TESTS})
endif() endif()
if(${TINT_BUILD_SPV_WRITER}) if(${TINT_BUILD_SPV_WRITER})
if(${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_WGSL_WRITER})
list(APPEND TINT_TEST_SRCS transform/spirv_test.cc)
endif()
list(APPEND TINT_TEST_SRCS list(APPEND TINT_TEST_SRCS
transform/msl_test.cc
transform/spirv_test.cc
writer/spirv/binary_writer_test.cc writer/spirv/binary_writer_test.cc
writer/spirv/builder_accessor_expression_test.cc writer/spirv/builder_accessor_expression_test.cc
writer/spirv/builder_assign_test.cc writer/spirv/builder_assign_test.cc
@ -940,6 +947,9 @@ if(${TINT_BUILD_TESTS})
endif() endif()
if(${TINT_BUILD_MSL_WRITER}) if(${TINT_BUILD_MSL_WRITER})
if(${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_WGSL_WRITER})
list(APPEND TINT_TEST_SRCS transform/msl_test.cc)
endif()
list(APPEND TINT_TEST_SRCS list(APPEND TINT_TEST_SRCS
writer/msl/generator_impl_array_accessor_test.cc writer/msl/generator_impl_array_accessor_test.cc
writer/msl/generator_impl_assign_test.cc writer/msl/generator_impl_assign_test.cc
@ -973,8 +983,10 @@ if(${TINT_BUILD_TESTS})
endif() endif()
if (${TINT_BUILD_HLSL_WRITER}) if (${TINT_BUILD_HLSL_WRITER})
if(${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_WGSL_WRITER})
list(APPEND TINT_TEST_SRCS transform/hlsl_test.cc)
endif()
list(APPEND TINT_TEST_SRCS list(APPEND TINT_TEST_SRCS
transform/hlsl_test.cc
writer/hlsl/generator_impl_array_accessor_test.cc writer/hlsl/generator_impl_array_accessor_test.cc
writer/hlsl/generator_impl_assign_test.cc writer/hlsl/generator_impl_assign_test.cc
writer/hlsl/generator_impl_binary_test.cc writer/hlsl/generator_impl_binary_test.cc

View File

@ -22,7 +22,10 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#if TINT_BUILD_SPV_READER
#include "source/opt/ir_context.h" #include "source/opt/ir_context.h"
#endif
#include "src/program_builder.h" #include "src/program_builder.h"
#include "src/reader/reader.h" #include "src/reader/reader.h"
#include "src/reader/spirv/entry_point_info.h" #include "src/reader/spirv/entry_point_info.h"

View File

@ -21,8 +21,11 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "gtest/gtest.h" #if TINT_BUILD_SPV_READER
#include "source/opt/ir_context.h" #include "source/opt/ir_context.h"
#endif
#include "gtest/gtest.h"
#include "src/demangler.h" #include "src/demangler.h"
#include "src/reader/spirv/fail_stream.h" #include "src/reader/spirv/fail_stream.h"
#include "src/reader/spirv/function.h" #include "src/reader/spirv/function.h"

View File

@ -14,8 +14,14 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/program.h" #include "src/program.h"
#if TINT_BUILD_SPV_READER
#include "src/reader/spirv/parser_impl_test_helper.h" #include "src/reader/spirv/parser_impl_test_helper.h"
#endif
#if TINT_BUILD_WGSL_WRITER
#include "src/writer/wgsl/generator.h" #include "src/writer/wgsl/generator.h"
#endif
namespace { namespace {