diff --git a/src/BUILD.gn b/src/BUILD.gn index 863faa41eb..76dcd28a5c 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -221,7 +221,64 @@ tint_language_header("cldebuginfo100") { # use the build flags to control what is included, instead of trying to specify # the subsets that they want. -source_set("libtint_core_src") { +template("libtint_source_set") { + source_set(target_name) { + forward_variables_from(invoker, "*", [ "configs" ]) + + if (!defined(invoker.deps)) { + deps = [] + } + deps += [ + ":tint_core_enums_unified1", + ":tint_core_tables_unified1", + ":tint_language_header_cldebuginfo100", + ":tint_language_header_debuginfo", + "${tint_spirv_headers_dir}:spv_headers", + "${tint_spirv_tools_dir}:spvtools_headers", + ] + + if (defined(invoker.configs)) { + configs += invoker.configs + } + configs += [ ":tint_common_config" ] + if (build_with_chromium) { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + } + + if (!defined(invoker.public_configs)) { + public_configs = [] + } + public_configs += [ ":tint_public_config" ] + } +} + +libtint_source_set("libtint_sem_src") { + sources = [ + "sem/array.cc", + "sem/array.h", + "sem/call.cc", + "sem/call.h", + "sem/call_target.cc", + "sem/call_target.h", + "sem/expression.cc", + "sem/expression.h", + "sem/function.cc", + "sem/info.cc", + "sem/info.h", + "sem/intrinsic.cc", + "sem/intrinsic.h", + "sem/member_accessor_expression.cc", + "sem/node.cc", + "sem/node.h", + "sem/statement.cc", + "sem/struct.cc", + "sem/type_mappings.h", + "sem/variable.cc", + ] +} + +libtint_source_set("libtint_core_all_src") { sources = [ "ast/access_control.cc", "ast/access_control.h", @@ -373,26 +430,6 @@ source_set("libtint_core_src") { "resolver/resolver.cc", "resolver/resolver.h", "scope_stack.h", - "sem/array.h", - "sem/call.h", - "sem/call_target.h", - "sem/expression.h", - "sem/info.h", - "sem/intrinsic.h", - "sem/node.h", - "sem/sem_array.cc", - "sem/sem_call.cc", - "sem/sem_call_target.cc", - "sem/sem_expression.cc", - "sem/sem_function.cc", - "sem/sem_info.cc", - "sem/sem_intrinsic.cc", - "sem/sem_member_accessor_expression.cc", - "sem/sem_node.cc", - "sem/sem_statement.cc", - "sem/sem_struct.cc", - "sem/sem_variable.cc", - "sem/type_mappings.h", "source.cc", "source.h", "symbol.cc", @@ -486,26 +523,16 @@ source_set("libtint_core_src") { } else { sources += [ "diagnostic/printer_other.cc" ] } - - public_deps = [ - ":tint_core_enums_unified1", - ":tint_core_tables_unified1", - ":tint_language_header_cldebuginfo100", - ":tint_language_header_debuginfo", - "${tint_spirv_headers_dir}:spv_headers", - "${tint_spirv_tools_dir}:spvtools_headers", - ] - - configs += [ ":tint_common_config" ] - public_configs = [ ":tint_public_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } } -source_set("libtint_spv_reader_src") { +libtint_source_set("libtint_core_src") { + deps = [ + ":libtint_core_all_src", + ":libtint_sem_src", + ] +} + +libtint_source_set("libtint_spv_reader_src") { sources = [ "reader/spirv/construct.cc", "reader/spirv/construct.h", @@ -525,28 +552,10 @@ source_set("libtint_spv_reader_src") { "reader/spirv/usage.h", ] - deps = [ - ":tint_core_enums_unified1", - ":tint_core_tables_unified1", - ":tint_language_header_cldebuginfo100", - ":tint_language_header_debuginfo", - "${tint_spirv_tools_dir}/:spvtools", - "${tint_spirv_tools_dir}/:spvtools_opt", - "${tint_spirv_tools_dir}/:spvtools_val", - ] - - configs += [ ":tint_common_config" ] - public_configs = [ ":tint_public_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - public_deps = [ ":libtint_core_src" ] } -source_set("libtint_spv_writer_src") { +libtint_source_set("libtint_spv_writer_src") { sources = [ "transform/spirv.cc", "transform/spirv.h", @@ -565,18 +574,10 @@ source_set("libtint_spv_writer_src") { "writer/spirv/scalar_constant.h", ] - configs += [ ":tint_common_config" ] - public_configs = [ ":tint_public_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - public_deps = [ ":libtint_core_src" ] } -source_set("libtint_wgsl_reader_src") { +libtint_source_set("libtint_wgsl_reader_src") { sources = [ "reader/wgsl/lexer.cc", "reader/wgsl/lexer.h", @@ -589,18 +590,10 @@ source_set("libtint_wgsl_reader_src") { "reader/wgsl/token.h", ] - configs += [ ":tint_common_config" ] - public_configs = [ ":tint_public_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - public_deps = [ ":libtint_core_src" ] } -source_set("libtint_wgsl_writer_src") { +libtint_source_set("libtint_wgsl_writer_src") { sources = [ "writer/wgsl/generator.cc", "writer/wgsl/generator.h", @@ -608,18 +601,10 @@ source_set("libtint_wgsl_writer_src") { "writer/wgsl/generator_impl.h", ] - configs += [ ":tint_common_config" ] - public_configs = [ ":tint_public_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - public_deps = [ ":libtint_core_src" ] } -source_set("libtint_msl_writer_src") { +libtint_source_set("libtint_msl_writer_src") { sources = [ "transform/msl.cc", "transform/msl.h", @@ -629,18 +614,10 @@ source_set("libtint_msl_writer_src") { "writer/msl/generator_impl.h", ] - configs += [ ":tint_common_config" ] - public_configs = [ ":tint_public_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - public_deps = [ ":libtint_core_src" ] } -source_set("libtint_hlsl_writer_src") { +libtint_source_set("libtint_hlsl_writer_src") { sources = [ "transform/hlsl.cc", "transform/hlsl.h", @@ -650,14 +627,6 @@ source_set("libtint_hlsl_writer_src") { "writer/hlsl/generator_impl.h", ] - configs += [ ":tint_common_config" ] - public_configs = [ ":tint_public_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - public_deps = [ ":libtint_core_src" ] } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6767a8d71..6dd5985b00 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,18 +195,18 @@ set(TINT_LIB_SRCS sem/info.h sem/intrinsic.h sem/node.h - sem/sem_array.cc - sem/sem_call.cc - sem/sem_call_target.cc - sem/sem_expression.cc - sem/sem_member_accessor_expression.cc - sem/sem_function.cc - sem/sem_info.cc - sem/sem_intrinsic.cc - sem/sem_node.cc - sem/sem_statement.cc - sem/sem_struct.cc - sem/sem_variable.cc + sem/array.cc + sem/call.cc + sem/call_target.cc + sem/expression.cc + sem/member_accessor_expression.cc + sem/function.cc + sem/info.cc + sem/intrinsic.cc + sem/node.cc + sem/statement.cc + sem/struct.cc + sem/variable.cc sem/type_mappings.h source.cc source.h @@ -496,7 +496,7 @@ if(${TINT_BUILD_TESTS}) resolver/type_validation_test.cc resolver/validation_test.cc scope_stack_test.cc - sem/sem_intrinsic_test.cc + sem/intrinsic_test.cc symbol_table_test.cc symbol_test.cc traits_test.cc diff --git a/src/sem/sem_array.cc b/src/sem/array.cc similarity index 100% rename from src/sem/sem_array.cc rename to src/sem/array.cc diff --git a/src/sem/sem_call.cc b/src/sem/call.cc similarity index 100% rename from src/sem/sem_call.cc rename to src/sem/call.cc diff --git a/src/sem/sem_call_target.cc b/src/sem/call_target.cc similarity index 100% rename from src/sem/sem_call_target.cc rename to src/sem/call_target.cc diff --git a/src/sem/sem_expression.cc b/src/sem/expression.cc similarity index 100% rename from src/sem/sem_expression.cc rename to src/sem/expression.cc diff --git a/src/sem/sem_function.cc b/src/sem/function.cc similarity index 100% rename from src/sem/sem_function.cc rename to src/sem/function.cc diff --git a/src/sem/sem_info.cc b/src/sem/info.cc similarity index 100% rename from src/sem/sem_info.cc rename to src/sem/info.cc diff --git a/src/sem/sem_intrinsic.cc b/src/sem/intrinsic.cc similarity index 100% rename from src/sem/sem_intrinsic.cc rename to src/sem/intrinsic.cc diff --git a/src/sem/sem_intrinsic_test.cc b/src/sem/intrinsic_test.cc similarity index 100% rename from src/sem/sem_intrinsic_test.cc rename to src/sem/intrinsic_test.cc diff --git a/src/sem/sem_member_accessor_expression.cc b/src/sem/member_accessor_expression.cc similarity index 98% rename from src/sem/sem_member_accessor_expression.cc rename to src/sem/member_accessor_expression.cc index d0307748e8..aa73c0d264 100644 --- a/src/sem/sem_member_accessor_expression.cc +++ b/src/sem/member_accessor_expression.cc @@ -15,6 +15,8 @@ #include "src/ast/member_accessor_expression.h" #include "src/sem/member_accessor_expression.h" +#include + TINT_INSTANTIATE_TYPEINFO(tint::sem::MemberAccessorExpression); TINT_INSTANTIATE_TYPEINFO(tint::sem::StructMemberAccess); TINT_INSTANTIATE_TYPEINFO(tint::sem::Swizzle); diff --git a/src/sem/sem_node.cc b/src/sem/node.cc similarity index 100% rename from src/sem/sem_node.cc rename to src/sem/node.cc diff --git a/src/sem/sem_statement.cc b/src/sem/statement.cc similarity index 100% rename from src/sem/sem_statement.cc rename to src/sem/statement.cc diff --git a/src/sem/sem_struct.cc b/src/sem/struct.cc similarity index 98% rename from src/sem/sem_struct.cc rename to src/sem/struct.cc index 3bd32f6e3c..e4d0c3cfd7 100644 --- a/src/sem/sem_struct.cc +++ b/src/sem/struct.cc @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/struct_member.h" #include "src/sem/struct.h" +#include "src/ast/struct_member.h" + +#include TINT_INSTANTIATE_TYPEINFO(tint::sem::Struct); TINT_INSTANTIATE_TYPEINFO(tint::sem::StructMember); diff --git a/src/sem/struct.h b/src/sem/struct.h index 695303dccd..8d3c93dd48 100644 --- a/src/sem/struct.h +++ b/src/sem/struct.h @@ -22,6 +22,7 @@ #include "src/ast/storage_class.h" #include "src/sem/node.h" +#include "src/symbol.h" namespace tint { diff --git a/src/sem/sem_variable.cc b/src/sem/variable.cc similarity index 100% rename from src/sem/sem_variable.cc rename to src/sem/variable.cc diff --git a/test/BUILD.gn b/test/BUILD.gn index fc6afae627..6845d77109 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -107,7 +107,36 @@ config("tint_unittests_config") { ] } -source_set("tint_unittests_core_src") { +template("tint_unittests_source_set") { + source_set(target_name) { + forward_variables_from(invoker, "*", [ "configs" ]) + + if (defined(invoker.configs)) { + configs += invoker.configs + } + configs += [ ":tint_unittests_config" ] + if (build_with_chromium) { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + } + + testonly = true + + if (!defined(invoker.deps)) { + deps = [] + } + deps += [ + ":gmock_and_gtest", + "${tint_root_dir}/src:libtint_core_src", + ] + } +} + +tint_unittests_source_set("tint_unittests_core_sem_src") { + sources = [ "../src/sem/intrinsic_test.cc" ] +} + +tint_unittests_source_set("tint_unittests_core_src") { sources = [ "../src/ast/access_decoration_test.cc", "../src/ast/array_accessor_expression_test.cc", @@ -190,7 +219,6 @@ source_set("tint_unittests_core_src") { "../src/resolver/type_validation_test.cc", "../src/resolver/validation_test.cc", "../src/scope_stack_test.cc", - "../src/sem/sem_intrinsic_test.cc", "../src/symbol_table_test.cc", "../src/symbol_test.cc", "../src/traits_test.cc", @@ -245,24 +273,14 @@ source_set("tint_unittests_core_src") { sources += [ "../src/utils/tmpfile_other.cc" ] } - configs += [ ":tint_unittests_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - - testonly = true - deps = [ - ":gmock_and_gtest", - "${tint_root_dir}/src:libtint_core_src", + ":tint_unittests_core_sem_src", "${tint_root_dir}/src:libtint_wgsl_reader_src", "${tint_root_dir}/src:libtint_wgsl_writer_src", ] } -source_set("tint_unittests_spv_reader_src") { +tint_unittests_source_set("tint_unittests_spv_reader_src") { sources = [ "../src/reader/spirv/enum_converter_test.cc", "../src/reader/spirv/fail_stream_test.cc", @@ -296,23 +314,10 @@ source_set("tint_unittests_spv_reader_src") { "../src/reader/spirv/usage_test.cc", ] - configs += [ ":tint_unittests_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - - testonly = true - - deps = [ - ":gmock_and_gtest", - ":tint_unittests_core_src", - "${tint_root_dir}/src:libtint_spv_reader_src", - ] + deps = [ "${tint_root_dir}/src:libtint_spv_reader_src" ] } -source_set("tint_unittests_spv_writer_src") { +tint_unittests_source_set("tint_unittests_spv_writer_src") { sources = [ "../src/transform/spirv_test.cc", "../src/writer/spirv/binary_writer_test.cc", @@ -349,23 +354,10 @@ source_set("tint_unittests_spv_writer_src") { "../src/writer/spirv/test_helper.h", ] - configs += [ ":tint_unittests_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - - testonly = true - - deps = [ - ":gmock_and_gtest", - ":tint_unittests_core_src", - "${tint_root_dir}/src:libtint_spv_writer_src", - ] + deps = [ "${tint_root_dir}/src:libtint_spv_writer_src" ] } -source_set("tint_unittests_wgsl_reader_src") { +tint_unittests_source_set("tint_unittests_wgsl_reader_src") { sources = [ "../src/reader/wgsl/lexer_test.cc", "../src/reader/wgsl/parser_impl_additive_expression_test.cc", @@ -443,23 +435,10 @@ source_set("tint_unittests_wgsl_reader_src") { "../src/reader/wgsl/token_test.cc", ] - configs += [ ":tint_unittests_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - - testonly = true - - deps = [ - ":gmock_and_gtest", - ":tint_unittests_core_src", - "${tint_root_dir}/src:libtint_wgsl_reader_src", - ] + deps = [ "${tint_root_dir}/src:libtint_wgsl_reader_src" ] } -source_set("tint_unittests_wgsl_writer_src") { +tint_unittests_source_set("tint_unittests_wgsl_writer_src") { sources = [ "../src/writer/wgsl/generator_impl_alias_type_test.cc", "../src/writer/wgsl/generator_impl_array_accessor_test.cc", @@ -492,23 +471,10 @@ source_set("tint_unittests_wgsl_writer_src") { "../src/writer/wgsl/test_helper.h", ] - configs += [ ":tint_unittests_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - - testonly = true - - deps = [ - ":gmock_and_gtest", - ":tint_unittests_core_src", - "${tint_root_dir}/src:libtint_wgsl_writer_src", - ] + deps = [ "${tint_root_dir}/src:libtint_wgsl_writer_src" ] } -source_set("tint_unittests_msl_writer_src") { +tint_unittests_source_set("tint_unittests_msl_writer_src") { sources = [ "../src/transform/msl_test.cc", "../src/writer/msl/generator_impl_alias_type_test.cc", @@ -544,23 +510,10 @@ source_set("tint_unittests_msl_writer_src") { "../src/writer/msl/test_helper.h", ] - configs += [ ":tint_unittests_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - - testonly = true - - deps = [ - ":gmock_and_gtest", - ":tint_unittests_core_src", - "${tint_root_dir}/src:libtint_msl_writer_src", - ] + deps = [ "${tint_root_dir}/src:libtint_msl_writer_src" ] } -source_set("tint_unittests_hlsl_writer_src") { +tint_unittests_source_set("tint_unittests_hlsl_writer_src") { sources = [ "../src/transform/hlsl_test.cc", "../src/writer/hlsl/generator_impl_alias_type_test.cc", @@ -598,20 +551,7 @@ source_set("tint_unittests_hlsl_writer_src") { "../src/writer/hlsl/test_helper.h", ] - configs += [ ":tint_unittests_config" ] - - if (build_with_chromium) { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - - testonly = true - - deps = [ - ":gmock_and_gtest", - ":tint_unittests_core_src", - "${tint_root_dir}/src:libtint_hlsl_writer_src", - ] + deps = [ "${tint_root_dir}/src:libtint_hlsl_writer_src" ] } source_set("tint_unittests_src") {