# Asset Compiler 
ac_deps = []
ac_sources = []
ac_cargs = []

# DXC for vulkan & directx shaders
if get_option('enable_dxc_shader_compiler')
  # We package dxc binaries under contrib/dxc
  dxc_include = include_directories('../../contrib/dxc/inc')
  dxc_libdir = 'NONE'
  if host_machine.system() == 'windows'
    dxc_libdir = meson.project_source_root() / 'contrib' / 'dxc' / 'lib' / 'x64'
    custom_target('copy dxcompiler.dll',
      input : meson.project_source_root() / 'contrib' / 'dxc' / 'bin' / 'x64' / 'dxcompiler.dll',
      output : 'dxcompiler.dll',
      command : [copy_util, '@INPUT@', '@OUTPUT@'],
      install : false,
      build_by_default : true)
  elif host_machine.system() == 'linux'
    dxc_libdir = meson.project_source_root() / 'contrib' / 'dxc' / 'lib'
    custom_target('copy libdxcompiler.so',
      input : meson.project_source_root() / 'contrib' / 'dxc' / 'lib' / 'libdxcompiler.so', 
      output : 'libdxcompiler.so',
      command : [copy_util, '@INPUT@', '@OUTPUT@'],
      install : false,
      build_by_default : true)
    custom_target('copy libdxil.so',
      input : meson.project_source_root() / 'contrib' / 'dxc' / 'lib' / 'libdxil.so', 
      output : 'libdxil.so',
      command : [copy_util, '@INPUT@', '@OUTPUT@'],
      install : false,
      build_by_default : true)
  endif
  dxc_dep = declare_dependency(link_args : ['-L'+dxc_libdir, '-ldxcompiler'], include_directories : dxc_include)
  ac_deps += dxc_dep
  ac_sources += [
    'dxc_shader_compiler.cpp'
  ]
  ac_cargs += '-DRT_BUILD_DXC_SHADER_COMPILER'
endif

if get_option('enable_dx11_shader_compiler')
  ac_cargs += '-DRT_BUILD_DX11_SHADER_COMPILER'
  ac_sources += ['dx11_shader_compiler.cpp']
  d3dcompiler_dep = declare_dependency(link_args : ['-lD3DCompiler'])
  ac_deps += d3dcompiler_dep
endif

asset_compiler = static_library('asset_compiler',
  'asset_compiler.h',
  'description_parser.h',
  'processor.h',
  'shader_compiler.h',

  'asset_compiler.c',
  'description_parser.c',
  'effect_processor.c',
  'framegraph_processor.c',
  'shader_compiler.c',
  sources : ac_sources,
  include_directories : engine_incdir,
  link_with : runtime_lib,
  c_args : ac_cargs,
  cpp_args : ac_cargs,
  dependencies : ac_deps)
