config("third_party_config") {
  include_dirs = [
    "vulkan/include",
    "glslang",
  ]

  if (target_os == "linux") {
    defines = [ "VK_USE_PLATFORM_XLIB_KHR" ]
  }

  if (target_os == "win") {
    defines = [ "VK_USE_PLATFORM_WIN32_KHR" ]
  }
}

source_set("third_party") {
  public_configs = [ ":third_party_config" ]

  sources = [
    "glslang/OGLCompilersDLL/InitializeDll.cpp",
    "glslang/SPIRV/GlslangToSpv.cpp",
    "glslang/SPIRV/InReadableOrder.cpp",
    "glslang/SPIRV/Logger.cpp",
    "glslang/SPIRV/SPVRemapper.cpp",
    "glslang/SPIRV/SpvBuilder.cpp",
    "glslang/SPIRV/SpvPostProcess.cpp",
    "glslang/SPIRV/SpvTools.cpp",
    "glslang/SPIRV/disassemble.cpp",
    "glslang/SPIRV/doc.cpp",
    "glslang/glslang/GenericCodeGen/CodeGen.cpp",
    "glslang/glslang/GenericCodeGen/Link.cpp",
    "glslang/glslang/MachineIndependent/Constant.cpp",
    "glslang/glslang/MachineIndependent/InfoSink.cpp",
    "glslang/glslang/MachineIndependent/Initialize.cpp",
    "glslang/glslang/MachineIndependent/IntermTraverse.cpp",
    "glslang/glslang/MachineIndependent/Intermediate.cpp",
    "glslang/glslang/MachineIndependent/ParseContextBase.cpp",
    "glslang/glslang/MachineIndependent/ParseHelper.cpp",
    "glslang/glslang/MachineIndependent/PoolAlloc.cpp",
    "glslang/glslang/MachineIndependent/RemoveTree.cpp",
    "glslang/glslang/MachineIndependent/Scan.cpp",
    "glslang/glslang/MachineIndependent/ShaderLang.cpp",
    "glslang/glslang/MachineIndependent/SpirvIntrinsics.cpp",
    "glslang/glslang/MachineIndependent/SymbolTable.cpp",
    "glslang/glslang/MachineIndependent/Versions.cpp",
    "glslang/glslang/MachineIndependent/attribute.cpp",
    "glslang/glslang/MachineIndependent/glslang_tab.cpp",
    "glslang/glslang/MachineIndependent/intermOut.cpp",
    "glslang/glslang/MachineIndependent/iomapper.cpp",
    "glslang/glslang/MachineIndependent/limits.cpp",
    "glslang/glslang/MachineIndependent/linkValidate.cpp",
    "glslang/glslang/MachineIndependent/parseConst.cpp",
    "glslang/glslang/MachineIndependent/preprocessor/Pp.cpp",
    "glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp",
    "glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp",
    "glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp",
    "glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp",
    "glslang/glslang/MachineIndependent/propagateNoContraction.cpp",
    "glslang/glslang/MachineIndependent/reflection.cpp",
    # "glslang/glslang/OSDependent/Unix/ossource.cpp",
    "glslang/glslang/OSDependent/Windows/ossource.cpp",
    "jsoncpp/json.h",
    "jsoncpp/jsoncpp.cpp",
    "minimp3/minimp3.h",
    "minimp3/minimp3_ex.h",
    "spirv-reflect/spirv_reflect.c",
    "stb/stb_image.h",
    "stb/stb_truetype.h",
    "texture_compressor/dxt_encoder.cc",
    "texture_compressor/dxt_encoder.h",
    "texture_compressor/dxt_encoder_implementation_autogen.h",
    "texture_compressor/dxt_encoder_internals.cc",
    "texture_compressor/dxt_encoder_internals.h",
    "texture_compressor/texture_compressor.cc",
    "texture_compressor/texture_compressor.h",
    "texture_compressor/texture_compressor_etc1.cc",
    "texture_compressor/texture_compressor_etc1.h",
    "vma/vk_mem_alloc.cpp",
    "volk/volk.c",
  ]

  defines = [ "VMA_STATIC_VULKAN_FUNCTIONS=1" ]

  if (target_os == "linux") {
    sources += [
      "glew/glew.c",
      "glew/glew.h",
      "glew/glxew.h",
    ]
  }

  if (target_os == "win") {
    sources += [
      "glew/glew.c",
      "glew/glew.h",
      "glew/wglew.h",
    ]

    libs = [ "opengl32.lib" ]
  }

  configs -= [ "//build:warnings" ]

  deps = []
}
