Fix gn check in Chromium

 - Move headers from libtint_sem_src into libtint_core_all_src so that
there is no circular header dependency between headers of these two
targets. libtint_sem_src is now just a hack to have a different name for
a few .cc files.
 - Made libtint_core_src publicly depend on its deps so that headers of
libtint_core_all_src are made visible through it.
 - Added spvtools dependencies in a couple places that were mistakenly
removed in a previous commit.
 - Moved helpers common to multiple unittest targets out of
tint_unittests_core_src and into a tint_test_helpers target that
all tint_unittests_source_set depend on.
 - Ran GN format that reordered some lists a bit.

Bug: None
Change-Id: I544a73d73366be9dd2ac8e56c7593fd9f2b86cf8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48600
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/BUILD.gn b/src/BUILD.gn
index 2a940b6..335a04f 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -253,31 +253,6 @@
   }
 }
 
-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",
@@ -286,12 +261,13 @@
     "ast/access_decoration.h",
     "ast/alias.cc",
     "ast/alias.h",
-    "ast/array_accessor_expression.cc",
-    "ast/array_accessor_expression.h",
     "ast/array.cc",
     "ast/array.h",
+    "ast/array_accessor_expression.cc",
+    "ast/array_accessor_expression.h",
     "ast/assignment_statement.cc",
     "ast/assignment_statement.h",
+    "ast/ast_type.cc",  # TODO(bclayton) - rename to type.cc
     "ast/binary_expression.cc",
     "ast/binary_expression.h",
     "ast/binding_decoration.cc",
@@ -300,16 +276,16 @@
     "ast/bitcast_expression.h",
     "ast/block_statement.cc",
     "ast/block_statement.h",
-    "ast/bool_literal.cc",
-    "ast/bool_literal.h",
     "ast/bool.cc",
     "ast/bool.h",
+    "ast/bool_literal.cc",
+    "ast/bool_literal.h",
     "ast/break_statement.cc",
     "ast/break_statement.h",
-    "ast/builtin_decoration.cc",
-    "ast/builtin_decoration.h",
     "ast/builtin.cc",
     "ast/builtin.h",
+    "ast/builtin_decoration.cc",
+    "ast/builtin_decoration.h",
     "ast/call_expression.cc",
     "ast/call_expression.h",
     "ast/call_statement.cc",
@@ -392,38 +368,37 @@
     "ast/storage_texture.h",
     "ast/stride_decoration.cc",
     "ast/stride_decoration.h",
+    "ast/struct.cc",
+    "ast/struct.h",
     "ast/struct_block_decoration.cc",
     "ast/struct_block_decoration.h",
+    "ast/struct_member.cc",
+    "ast/struct_member.h",
     "ast/struct_member_align_decoration.cc",
     "ast/struct_member_align_decoration.h",
     "ast/struct_member_offset_decoration.cc",
     "ast/struct_member_offset_decoration.h",
     "ast/struct_member_size_decoration.cc",
     "ast/struct_member_size_decoration.h",
-    "ast/struct_member.cc",
-    "ast/struct_member.h",
-    "ast/struct.cc",
-    "ast/struct.h",
     "ast/switch_statement.cc",
     "ast/switch_statement.h",
     "ast/texture.cc",
     "ast/texture.h",
+    "ast/type.h",
     "ast/type_constructor_expression.cc",
     "ast/type_constructor_expression.h",
-    "ast/ast_type.cc",  # TODO(bclayton) - rename to type.cc
-    "ast/type.h",
     "ast/u32.cc",
     "ast/u32.h",
     "ast/uint_literal.cc",
     "ast/uint_literal.h",
-    "ast/unary_op_expression.cc",
-    "ast/unary_op_expression.h",
     "ast/unary_op.cc",
     "ast/unary_op.h",
-    "ast/variable_decl_statement.cc",
-    "ast/variable_decl_statement.h",
+    "ast/unary_op_expression.cc",
+    "ast/unary_op_expression.h",
     "ast/variable.cc",
     "ast/variable.h",
+    "ast/variable_decl_statement.cc",
+    "ast/variable_decl_statement.h",
     "ast/vector.cc",
     "ast/vector.h",
     "ast/void.cc",
@@ -453,12 +428,12 @@
     "inspector/scalar.h",
     "intrinsic_table.cc",
     "intrinsic_table.h",
+    "program.cc",
+    "program.h",
     "program_builder.cc",
     "program_builder.h",
     "program_id.cc",
     "program_id.h",
-    "program.cc",
-    "program.h",
     "reader/reader.cc",
     "reader/reader.h",
     "resolver/resolver.cc",
@@ -468,22 +443,29 @@
     "sem/access_control_type.h",
     "sem/alias_type.cc",
     "sem/alias_type.h",
+    "sem/array.h",
     "sem/array_type.cc",
     "sem/array_type.h",
     "sem/bool_type.cc",
     "sem/bool_type.h",
+    "sem/call.h",
+    "sem/call_target.h",
     "sem/depth_texture_type.cc",
     "sem/depth_texture_type.h",
+    "sem/expression.h",
     "sem/external_texture_type.cc",
     "sem/external_texture_type.h",
     "sem/f32_type.cc",
     "sem/f32_type.h",
     "sem/i32_type.cc",
     "sem/i32_type.h",
+    "sem/info.h",
+    "sem/intrinsic.h",
     "sem/matrix_type.cc",
     "sem/matrix_type.h",
     "sem/multisampled_texture_type.cc",
     "sem/multisampled_texture_type.h",
+    "sem/node.h",
     "sem/pointer_type.cc",
     "sem/pointer_type.h",
     "sem/sampled_texture_type.cc",
@@ -500,6 +482,7 @@
     "sem/type.h",
     "sem/type_manager.cc",
     "sem/type_manager.h",
+    "sem/type_mappings.h",
     "sem/u32_type.cc",
     "sem/u32_type.h",
     "sem/vector_type.cc",
@@ -508,10 +491,10 @@
     "sem/void_type.h",
     "source.cc",
     "source.h",
-    "symbol_table.cc",
-    "symbol_table.h",
     "symbol.cc",
     "symbol.h",
+    "symbol_table.cc",
+    "symbol_table.h",
     "traits.h",
     "transform/binding_point.h",
     "transform/binding_remapper.cc",
@@ -544,10 +527,10 @@
     "writer/append_vector.h",
     "writer/float_to_string.cc",
     "writer/float_to_string.h",
-    "writer/text_generator.cc",
-    "writer/text_generator.h",
     "writer/text.cc",
     "writer/text.h",
+    "writer/text_generator.cc",
+    "writer/text_generator.h",
     "writer/writer.cc",
     "writer/writer.h",
   ]
@@ -561,8 +544,27 @@
   }
 }
 
+libtint_source_set("libtint_sem_src") {
+  sources = [
+    "sem/array.cc",
+    "sem/call.cc",
+    "sem/call_target.cc",
+    "sem/expression.cc",
+    "sem/function.cc",
+    "sem/info.cc",
+    "sem/intrinsic.cc",
+    "sem/member_accessor_expression.cc",
+    "sem/node.cc",
+    "sem/statement.cc",
+    "sem/struct.cc",
+    "sem/variable.cc",
+  ]
+
+  public_deps = [ ":libtint_core_all_src" ]
+}
+
 libtint_source_set("libtint_core_src") {
-  deps = [
+  public_deps = [
     ":libtint_core_all_src",
     ":libtint_sem_src",
   ]
@@ -588,7 +590,10 @@
     "reader/spirv/usage.h",
   ]
 
-  public_deps = [ ":libtint_core_src" ]
+  public_deps = [
+    ":libtint_core_src",
+    "${tint_spirv_tools_dir}/:spvtools_opt",
+  ]
 }
 
 libtint_source_set("libtint_spv_writer_src") {
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 2b19a60..4dd0453 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -107,6 +107,27 @@
   ]
 }
 
+source_set("tint_test_helpers") {
+  sources = [
+    "../src/ast/intrinsic_texture_helper_test.cc",
+    "../src/ast/intrinsic_texture_helper_test.h",
+    "../src/transform/test_helper.h",
+    "../src/utils/command.h",
+    "../src/utils/tmpfile.h",
+  ]
+
+  if (is_linux || is_mac) {
+    sources += [ "../src/utils/command_posix.cc" ]
+    sources += [ "../src/utils/tmpfile_posix.cc" ]
+  } else if (is_win) {
+    sources += [ "../src/utils/command_windows.cc" ]
+    sources += [ "../src/utils/tmpfile_windows.cc" ]
+  } else {
+    sources += [ "../src/utils/command_other.cc" ]
+    sources += [ "../src/utils/tmpfile_other.cc" ]
+  }
+}
+
 template("tint_unittests_source_set") {
   source_set(target_name) {
     forward_variables_from(invoker, "*", [ "configs" ])
@@ -127,6 +148,7 @@
     }
     deps += [
       ":gmock_and_gtest",
+      ":tint_test_helpers",
       "${tint_root_dir}/src:libtint_core_src",
     ]
   }
@@ -169,8 +191,6 @@
     "../src/ast/identifier_expression_test.cc",
     "../src/ast/if_statement_test.cc",
     "../src/ast/int_literal_test.cc",
-    "../src/ast/intrinsic_texture_helper_test.cc",
-    "../src/ast/intrinsic_texture_helper_test.h",
     "../src/ast/location_decoration_test.cc",
     "../src/ast/loop_statement_test.cc",
     "../src/ast/matrix_test.cc",
@@ -224,9 +244,9 @@
     "../src/resolver/intrinsic_test.cc",
     "../src/resolver/is_host_shareable_test.cc",
     "../src/resolver/is_storeable_test.cc",
+    "../src/resolver/resolver_test.cc",
     "../src/resolver/resolver_test_helper.cc",
     "../src/resolver/resolver_test_helper.h",
-    "../src/resolver/resolver_test.cc",
     "../src/resolver/storage_class_validation_test.cc",
     "../src/resolver/struct_layout_test.cc",
     "../src/resolver/struct_pipeline_stage_use_test.cc",
@@ -265,32 +285,17 @@
     "../src/transform/emit_vertex_point_size_test.cc",
     "../src/transform/first_index_offset_test.cc",
     "../src/transform/renamer_test.cc",
-    "../src/transform/test_helper.h",
     "../src/transform/vertex_pulling_test.cc",
-    "../src/utils/command.h",
     "../src/utils/command_test.cc",
-    "../src/utils/command.h",
     "../src/utils/get_or_create_test.cc",
     "../src/utils/hash_test.cc",
     "../src/utils/math_test.cc",
     "../src/utils/tmpfile_test.cc",
-    "../src/utils/tmpfile.h",
     "../src/utils/unique_vector_test.cc",
     "../src/writer/append_vector_test.cc",
     "../src/writer/float_to_string_test.cc",
   ]
 
-  if (is_linux || is_mac) {
-    sources += [ "../src/utils/command_posix.cc" ]
-    sources += [ "../src/utils/tmpfile_posix.cc" ]
-  } else if (is_win) {
-    sources += [ "../src/utils/command_windows.cc" ]
-    sources += [ "../src/utils/tmpfile_windows.cc" ]
-  } else {
-    sources += [ "../src/utils/command_other.cc" ]
-    sources += [ "../src/utils/tmpfile_other.cc" ]
-  }
-
   deps = [
     ":tint_unittests_core_sem_src",
     "${tint_root_dir}/src:libtint_wgsl_reader_src",
@@ -372,7 +377,10 @@
     "../src/writer/spirv/test_helper.h",
   ]
 
-  deps = [ "${tint_root_dir}/src:libtint_spv_writer_src" ]
+  deps = [
+    "${tint_root_dir}/src:libtint_spv_writer_src",
+    "${tint_spirv_tools_dir}/:spvtools",
+  ]
 }
 
 tint_unittests_source_set("tint_unittests_wgsl_reader_src") {