llvm/llvm/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn

import("//llvm/tools/binutils_symlinks.gni")
import("//llvm/tools/cctools_symlinks.gni")
import("//llvm/utils/TableGen/tablegen.gni")
import("//llvm/utils/gn/build/driver_executable.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")

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

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

symlinks = [ "llvm-otool" ]
if (llvm_install_binutils_symlinks) {
  symlinks += [ "objdump" ]
}
if (llvm_install_cctools_symlinks) {
  symlinks += [ "otool" ]
}

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

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

driver_executable("llvm-objdump") {
  deps = [
    ":ObjdumpOpts",
    ":OtoolOpts",
    "//llvm/include/llvm/Config:config",
    "//llvm/lib/CodeGen",
    "//llvm/lib/DebugInfo/DWARF",
    "//llvm/lib/DebugInfo/PDB",
    "//llvm/lib/DebugInfo/Symbolize",
    "//llvm/lib/Debuginfod",
    "//llvm/lib/Demangle",
    "//llvm/lib/MC",
    "//llvm/lib/MC/MCDisassembler",
    "//llvm/lib/Object",
    "//llvm/lib/Option",
    "//llvm/lib/Support",
    "//llvm/lib/Target:AllTargetsDescs",
    "//llvm/lib/Target:AllTargetsDisassemblers",
    "//llvm/lib/Target:AllTargetsInfos",
    "//llvm/lib/TargetParser",
    "//llvm/utils/gn/build/libs/xar",
  ]
  sources = [
    "COFFDump.cpp",
    "ELFDump.cpp",
    "MachODump.cpp",
    "OffloadDump.cpp",
    "SourcePrinter.cpp",
    "WasmDump.cpp",
    "XCOFFDump.cpp",
    "llvm-objdump.cpp",
  ]
}