# Copyright 2019 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("../swiftshader.gni")

# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_libvulkan_private_config") {
  if (is_linux) {
    defines = [
      "VK_USE_PLATFORM_XLIB_KHR",
      "VK_USE_PLATFORM_XCB_KHR",
      "VK_EXPORT=__attribute__((visibility(\"default\")))",
    ]
  } else if (is_fuchsia) {
    defines = [
      "VK_USE_PLATFORM_FUCHSIA=1",
      "VK_EXPORT=__attribute__((visibility(\"default\")))",
    ]
  } else if (is_win) {
    defines = [
      "VK_USE_PLATFORM_WIN32_KHR=1",
      "VK_EXPORT=",
    ]
  } else if (is_mac) {
    defines = [
      "VK_USE_PLATFORM_MACOS_MVK=1",
      "VK_USE_PLATFORM_METAL_EXT=1",
      "VK_EXPORT=__attribute__((visibility(\"default\")))",
    ]
  } else {
    defines = [ "VK_EXPORT=" ]
  }

  if (is_clang) {
    cflags = [
      "-Wno-unused-private-field",
      "-Wno-switch",
    ]
  }
}

swiftshader_source_set("swiftshader_libvulkan_headers") {
  sources = [
    "Version.h",
    "VkBuffer.hpp",
    "VkBufferView.hpp",
    "VkCommandBuffer.hpp",
    "VkCommandPool.hpp",
    "VkConfig.h",
    "VkDebug.hpp",
    "VkDescriptorPool.hpp",
    "VkDescriptorSet.hpp",
    "VkDescriptorSetLayout.hpp",
    "VkDescriptorUpdateTemplate.hpp",
    "VkDestroy.h",
    "VkDevice.hpp",
    "VkDeviceMemory.hpp",
    "VkEvent.hpp",
    "VkFence.hpp",
    "VkFormat.h",
    "VkFramebuffer.hpp",
    "VkGetProcAddress.h",
    "VkImage.hpp",
    "VkImageView.hpp",
    "VkInstance.hpp",
    "VkMemory.h",
    "VkObject.hpp",
    "VkPhysicalDevice.hpp",
    "VkPipeline.hpp",
    "VkPipelineCache.hpp",
    "VkPipelineLayout.hpp",
    "VkQueryPool.hpp",
    "VkQueue.hpp",
    "VkRenderPass.hpp",
    "VkSampler.hpp",
    "VkSemaphore.hpp",
    "VkShaderModule.hpp",
    "VkStringify.hpp",
    "VulkanPlatform.h",
  ]
  if (is_linux || is_android) {
    sources += [
      "VkDeviceMemoryExternalLinux.hpp",
      "VkSemaphoreExternalLinux.hpp",
    ]
  } else if (is_fuchsia) {
    sources += [
      "VkSemaphoreExternalFuchsia.hpp",
    ]
  } else {
    sources += [
      "VkSemaphoreExternalNone.hpp",
    ]
  }
}

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",
    "VkSemaphore.cpp",
    "VkShaderModule.cpp",
    "VkStringify.cpp",
    "Vulkan.rc",
    "libVulkan.cpp",
    "main.cpp",
    "resource.h",
    "vk_swiftshader.def",
  ]

  configs = [ ":swiftshader_libvulkan_private_config" ]

  # TODO(capn): Use the same ICD name on both Windows and non-Windows.
  if (is_win) {
    output_name = "vk_swiftshader"
  } else {
    output_name = "libvk_swiftshader"
  }

  if (is_mac) {
    ldflags = [
      "-Wl,-install_name,@rpath/libvk_swiftshader.dylib",
      "-Wl,-exported_symbols_list," +
          rebase_path("vk_swiftshader.exports", root_build_dir),
    ]
  } else if (is_linux || is_fuchsia) {
    inputs = [
      "vk_swiftshader.lds",
    ]
    ldflags = [ "-Wl,--version-script=" +
                rebase_path("vk_swiftshader.lds", root_build_dir) ]
  }

  deps = [
    "../../third_party/marl:Marl",
    "${swiftshader_spirv_tools_dir}:SPIRV-Tools",
    "../Device",
    "../Pipeline",
    "../Reactor:swiftshader_llvm_reactor",
    "../System",
    "../WSI",
  ]

  include_dirs = [
    "..",
    "../../include",
    "$swiftshader_spirv_tools_dir/include",
    "$spirv_tools_spirv_headers_dir/include",
  ]

  public_deps = [
    ":swiftshader_libvulkan_headers",
  ]
}
