Compiler projects using llvm
import("//llvm/tools/binutils_symlinks.gni")
import("//llvm/utils/TableGen/tablegen.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")

tablegen("Opts") {
  visibility = [ ":llvm-rc" ]
  args = [ "-gen-opt-parser-defs" ]
}

tablegen("WindresOpts") {
  visibility = [ ":llvm-rc" ]
  args = [ "-gen-opt-parser-defs" ]
}

symlinks = [ "llvm-windres" ]
if (llvm_install_binutils_symlinks) {
  symlinks += [ "windres" ]
}

foreach(target, symlinks) {
  symlink_or_copy(target) {
    deps = [ ":llvm-rc" ]
    source = "llvm-rc"
    output = "$root_out_dir/bin/$target"
  }
}

# //:llvm-rc depends on this symlink target, see comment in //BUILD.gn.
group("symlinks") {
  deps = [ ":llvm-rc" ]
  foreach(target, symlinks) {
    deps += [ ":$target" ]
  }
}

executable("llvm-rc") {
  deps = [
    ":Opts",
    ":WindresOpts",
    "//llvm/lib/Object",
    "//llvm/lib/Option",
    "//llvm/lib/Support",
  ]
  sources = [
    "ResourceFileWriter.cpp",
    "ResourceScriptCppFilter.cpp",
    "ResourceScriptParser.cpp",
    "ResourceScriptStmt.cpp",
    "ResourceScriptToken.cpp",
    "llvm-rc.cpp",
  ]
}