Fix GN Header checks.

This fixes a few missing dependencies for the Chromium uses of
SwiftShader. It will allow us to turn on the 'gn check' in
Chromium.

Bug: angleproject:3876
Bug: b/140251624
Change-Id: I875a59701a4437cf94b503f6430d858a5285a961
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/35811
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/Device/BUILD.gn b/src/Device/BUILD.gn
index 2a61fff9..9d99aac 100644
--- a/src/Device/BUILD.gn
+++ b/src/Device/BUILD.gn
@@ -14,39 +14,44 @@
 
 import("../swiftshader.gni")
 
+swiftshader_source_set("Device_headers") {
+  sources = [
+    "Blitter.hpp",
+    "Clipper.hpp",
+    "Color.hpp",
+    "Config.hpp",
+    "Context.hpp",
+    "ETC_Decoder.hpp",
+    "Matrix.hpp",
+    "Memset.hpp",
+    "PixelProcessor.hpp",
+    "Plane.hpp",
+    "Point.hpp",
+    "QuadRasterizer.hpp",
+    "Renderer.hpp",
+    "SetupProcessor.hpp",
+    "Vector.hpp",
+    "VertexProcessor.hpp",
+  ]
+}
+
 swiftshader_source_set("Device") {
   sources = [
     "Blitter.cpp",
-    "Blitter.hpp",
     "Clipper.cpp",
-    "Clipper.hpp",
     "Color.cpp",
-    "Color.hpp",
     "Config.cpp",
-    "Config.hpp",
     "Context.cpp",
-    "Context.hpp",
     "ETC_Decoder.cpp",
-    "ETC_Decoder.hpp",
     "Matrix.cpp",
-    "Matrix.hpp",
-    "Memset.hpp",
     "PixelProcessor.cpp",
-    "PixelProcessor.hpp",
     "Plane.cpp",
-    "Plane.hpp",
     "Point.cpp",
-    "Point.hpp",
     "QuadRasterizer.cpp",
-    "QuadRasterizer.hpp",
     "Renderer.cpp",
-    "Renderer.hpp",
     "SetupProcessor.cpp",
-    "SetupProcessor.hpp",
     "Vector.cpp",
-    "Vector.hpp",
     "VertexProcessor.cpp",
-    "VertexProcessor.hpp",
   ]
 
   include_dirs = [
@@ -54,4 +59,15 @@
     "../../include",
     "../../third_party/SPIRV-Headers/include",
   ]
+
+  deps = [
+    "../Pipeline:Pipeline_headers",
+    "../System:System_headers",
+    "../Vulkan:swiftshader_libvulkan_headers",
+    "../Yarn:Yarn_headers",
+  ]
+
+  public_deps = [
+    ":Device_headers",
+  ]
 }
diff --git a/src/Pipeline/BUILD.gn b/src/Pipeline/BUILD.gn
index b1d2988..72c6a3d 100644
--- a/src/Pipeline/BUILD.gn
+++ b/src/Pipeline/BUILD.gn
@@ -14,32 +14,35 @@
 
 import("../swiftshader.gni")
 
+swiftshader_source_set("Pipeline_headers") {
+  sources = [
+    "ComputeProgram.hpp",
+    "Constants.hpp",
+    "PixelProgram.hpp",
+    "PixelRoutine.hpp",
+    "SamplerCore.hpp",
+    "SetupRoutine.hpp",
+    "ShaderCore.hpp",
+    "SpirvShader.hpp",
+    "VertexProgram.hpp",
+    "VertexRoutine.hpp",
+  ]
+}
+
 swiftshader_source_set("Pipeline") {
   sources = [
     "ComputeProgram.cpp",
-    "ComputeProgram.hpp",
     "Constants.cpp",
-    "Constants.hpp",
     "PixelProgram.cpp",
-    "PixelProgram.hpp",
     "PixelRoutine.cpp",
-    "PixelRoutine.hpp",
     "SamplerCore.cpp",
-    "SamplerCore.hpp",
     "SetupRoutine.cpp",
-    "SetupRoutine.hpp",
     "ShaderCore.cpp",
-    "ShaderCore.hpp",
     "SpirvShader.cpp",
-    "SpirvShader.hpp",
     "SpirvShaderSampling.cpp",
-    "SpirvShaderSampling.hpp",
     "SpirvShader_dbg.cpp",
-    "SpirvShader_dbg.hpp",
     "VertexProgram.cpp",
-    "VertexProgram.hpp",
     "VertexRoutine.cpp",
-    "VertexRoutine.hpp",
   ]
 
   include_dirs = [
@@ -47,4 +50,15 @@
     "../../include",
     "../../third_party/SPIRV-Headers/include",
   ]
+
+  deps = [
+    "../Device:Device_headers",
+    "../System:System_headers",
+    "../Vulkan:swiftshader_libvulkan_headers",
+    "../Yarn:Yarn_headers",
+  ]
+
+  public_deps = [
+    ":Pipeline_headers",
+  ]
 }
diff --git a/src/System/BUILD.gn b/src/System/BUILD.gn
index 74d21c8..9976e08 100644
--- a/src/System/BUILD.gn
+++ b/src/System/BUILD.gn
@@ -14,26 +14,34 @@
 
 import("../swiftshader.gni")
 
-swiftshader_source_set("System") {
+swiftshader_source_set("System_headers") {
   sources = [
     "Build.hpp",
-    "CPUID.cpp",
     "CPUID.hpp",
-    "Configurator.cpp",
     "Configurator.hpp",
-    "Debug.cpp",
     "Debug.hpp",
-    "Half.cpp",
     "Half.hpp",
-    "Math.cpp",
     "Math.hpp",
-    "Memory.cpp",
     "Memory.hpp",
     "Socket.cpp",
     "Socket.hpp",
-    "Timer.cpp",
     "Timer.hpp",
   ]
+}
+
+swiftshader_source_set("System") {
+  sources = [
+    "CPUID.cpp",
+    "Configurator.cpp",
+    "Debug.cpp",
+    "Half.cpp",
+    "Math.cpp",
+    "Memory.cpp",
+    "Timer.cpp",
+  ]
 
   include_dirs = [ ".." ]
+  public_deps = [
+    ":System_headers",
+  ]
 }
diff --git a/src/Vulkan/BUILD.gn b/src/Vulkan/BUILD.gn
index b90e231..7da1c59 100644
--- a/src/Vulkan/BUILD.gn
+++ b/src/Vulkan/BUILD.gn
@@ -42,75 +42,80 @@
   ]
 }
 
-swiftshader_shared_library("swiftshader_libvulkan") {
+swiftshader_source_set("swiftshader_libvulkan_headers") {
   sources = [
     "Version.h",
-    "VkBuffer.cpp",
     "VkBuffer.hpp",
-    "VkBufferView.cpp",
     "VkBufferView.hpp",
-    "VkCommandBuffer.cpp",
     "VkCommandBuffer.hpp",
-    "VkCommandPool.cpp",
     "VkCommandPool.hpp",
     "VkConfig.h",
-    "VkDebug.cpp",
     "VkDebug.hpp",
-    "VkDescriptorPool.cpp",
     "VkDescriptorPool.hpp",
     "VkDescriptorSet.hpp",
-    "VkDescriptorSetLayout.cpp",
     "VkDescriptorSetLayout.hpp",
-    "VkDescriptorUpdateTemplate.cpp",
     "VkDescriptorUpdateTemplate.hpp",
     "VkDestroy.h",
-    "VkDevice.cpp",
     "VkDevice.hpp",
-    "VkDeviceMemory.cpp",
     "VkDeviceMemory.hpp",
     "VkEvent.hpp",
     "VkFence.hpp",
-    "VkFormat.cpp",
     "VkFormat.h",
-    "VkFramebuffer.cpp",
     "VkFramebuffer.hpp",
-    "VkGetProcAddress.cpp",
     "VkGetProcAddress.h",
-    "VkImage.cpp",
     "VkImage.hpp",
-    "VkImageView.cpp",
     "VkImageView.hpp",
-    "VkInstance.cpp",
     "VkInstance.hpp",
-    "VkMemory.cpp",
     "VkMemory.h",
     "VkObject.hpp",
-    "VkPhysicalDevice.cpp",
     "VkPhysicalDevice.hpp",
-    "VkPipeline.cpp",
     "VkPipeline.hpp",
-    "VkPipelineCache.cpp",
     "VkPipelineCache.hpp",
-    "VkPipelineLayout.cpp",
     "VkPipelineLayout.hpp",
-    "VkPromotedExtensions.cpp",
-    "VkQueryPool.cpp",
     "VkQueryPool.hpp",
-    "VkQueue.cpp",
     "VkQueue.hpp",
-    "VkRenderPass.cpp",
     "VkRenderPass.hpp",
-    "VkSampler.cpp",
     "VkSampler.hpp",
     "VkSemaphore.hpp",
-    "VkShaderModule.cpp",
     "VkShaderModule.hpp",
-    "Vulkan.rc",
     "VulkanPlatform.h",
+  ]
+}
+
+swiftshader_shared_library("swiftshader_libvulkan") {
+  sources = [
+    "VkBuffer.cpp",
+    "VkBufferView.cpp",
+    "VkCommandBuffer.cpp",
+    "VkCommandPool.cpp",
+    "VkDebug.cpp",
+    "VkDescriptorPool.cpp",
+    "VkDescriptorSetLayout.cpp",
+    "VkDescriptorUpdateTemplate.cpp",
+    "VkDevice.cpp",
+    "VkDeviceMemory.cpp",
+    "VkFormat.cpp",
+    "VkFramebuffer.cpp",
+    "VkGetProcAddress.cpp",
+    "VkImage.cpp",
+    "VkImageView.cpp",
+    "VkInstance.cpp",
+    "VkMemory.cpp",
+    "VkPhysicalDevice.cpp",
+    "VkPipeline.cpp",
+    "VkPipelineCache.cpp",
+    "VkPipelineLayout.cpp",
+    "VkPromotedExtensions.cpp",
+    "VkQueryPool.cpp",
+    "VkQueue.cpp",
+    "VkRenderPass.cpp",
+    "VkSampler.cpp",
+    "VkShaderModule.cpp",
+    "Vulkan.rc",
     "libVulkan.cpp",
-    "vk_swiftshader.def",
     "main.cpp",
     "resource.h",
+    "vk_swiftshader.def",
   ]
 
   configs = [ ":swiftshader_libvulkan_private_config" ]
@@ -133,13 +138,13 @@
   }
 
   deps = [
+    "${swiftshader_spirv_tools_dir}:SPIRV-Tools",
     "../Device",
     "../Pipeline",
     "../Reactor:swiftshader_llvm_reactor",
     "../System",
     "../WSI",
     "../Yarn",
-    "$swiftshader_spirv_tools_dir:SPIRV-Tools",
   ]
 
   include_dirs = [
@@ -148,4 +153,8 @@
     "$swiftshader_spirv_tools_dir/include",
     "$spirv_tools_spirv_headers_dir/include",
   ]
+
+  public_deps = [
+    ":swiftshader_libvulkan_headers",
+  ]
 }
diff --git a/src/WSI/BUILD.gn b/src/WSI/BUILD.gn
index c111be1..c13463e 100644
--- a/src/WSI/BUILD.gn
+++ b/src/WSI/BUILD.gn
@@ -43,4 +43,8 @@
     "../../include",
     "../../third_party/SPIRV-Headers/include",
   ]
+
+  deps = [
+    "../Vulkan:swiftshader_libvulkan_headers",
+  ]
 }
diff --git a/src/Yarn/BUILD.gn b/src/Yarn/BUILD.gn
index 3236f13..eafe04b 100644
--- a/src/Yarn/BUILD.gn
+++ b/src/Yarn/BUILD.gn
@@ -14,51 +14,58 @@
 
 import("../swiftshader.gni")
 
-swiftshader_source_set("Yarn") {
+swiftshader_source_set("Yarn_headers") {
   sources = [
     "ConditionVariable.hpp",
     "Containers.hpp",
-    "Debug.cpp",
     "Debug.hpp",
     "Defer.hpp",
     "Finally.hpp",
     "OSFiber.hpp",
     "Pool.hpp",
     "SAL.hpp",
-    "Scheduler.cpp",
     "Scheduler.hpp",
-    "Thread.cpp",
     "Thread.hpp",
     "Ticket.hpp",
-    "Trace.cpp",
     "Trace.hpp",
     "Utils.hpp",
     "WaitGroup.hpp",
   ]
 
   if (is_win) {
-    sources += [
-      "OSFiber_windows.hpp",
-    ]
-  } else {
+    sources += [ "OSFiber_windows.hpp" ]
+  }
+}
+
+swiftshader_source_set("Yarn") {
+  sources = [
+    "Debug.cpp",
+    "Scheduler.cpp",
+    "Thread.cpp",
+    "Trace.cpp",
+  ]
+
+  if (!is_win) {
     sources += [
       "OSFiber_aarch64.c",
-      "OSFiber_asm_aarch64.h",
-      "OSFiber_asm_aarch64.S",
       "OSFiber_arm.c",
-      "OSFiber_asm_arm.h",
-      "OSFiber_asm_arm.S",
       "OSFiber_asm.hpp",
-      "OSFiber_x64.c",
-      "OSFiber_asm_x64.h",
+      "OSFiber_asm_aarch64.S",
+      "OSFiber_asm_aarch64.h",
+      "OSFiber_asm_arm.S",
+      "OSFiber_asm_arm.h",
       "OSFiber_asm_x64.S",
-      "OSFiber_x86.c",
-      "OSFiber_asm_x86.h",
+      "OSFiber_asm_x64.h",
       "OSFiber_asm_x86.S",
+      "OSFiber_asm_x86.h",
+      "OSFiber_x64.c",
+      "OSFiber_x86.c",
     ]
   }
 
-  include_dirs = [
-    "..",
+  include_dirs = [ ".." ]
+
+  public_deps = [
+    ":Yarn_headers",
   ]
 }