reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
import("//llvm/lib/Target/targets_string.gni")
import("//llvm/utils/gn/build/buildflags.gni")
import("//llvm/utils/gn/build/libs/pthread/enable.gni")
import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni")

write_cmake_config("BuildVariables.inc") {
  input = "BuildVariables.inc.in"
  output = "$target_gen_dir/BuildVariables.inc"

  if (is_debug) {
    build_mode = "debug"
  } else {
    build_mode = "release"
  }

  # FIXME: Why doesn't llvm-config do this, why is this done in
  # llvm-config/CMakeLists.txt?
  if (host_os == "win") {
    l = ""
    lib = ".lib"
  } else {
    l = "-l"
    lib = ""
  }

  # Windows doesn't use any of libxml2,terminfo, zlib by default.
  # Make GN not warn about these variables being unused.
  not_needed([
               "l",
               "lib",
             ])

  system_libs = ""
  if (host_os == "win") {
    # libuuid required for FOLDERID_Profile usage in
    # lib/Support/Windows/Path.inc.
    # advapi32 required for CryptAcquireContextW in
    # lib/Support/Windows/Path.inc
    system_libs = "psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib"
  } else {
    system_libs += "-lm"
    if (host_os == "linux") {
      system_libs += " -lrt -ldl"
    }
    if (llvm_enable_threads) {
      system_libs += " -llibpthreads"
      if (host_os == "linux") {
        system_libs += " -latomic"
      }
    }
  }
  if (llvm_enable_libxml2) {
    system_libs += " ${l}xml2${lib}"
  }
  if (llvm_enable_terminfo) {
    system_libs += " ${l}ncurses${lib}"
  }
  if (llvm_enable_zlib) {
    system_libs += " ${l}z${lib}"
  }

  values = [
    "LLVM_SRC_ROOT=" + rebase_path("//llvm"),
    "LLVM_OBJ_ROOT=" + rebase_path(root_out_dir),

    # FIXME: Only the bits needed to run LLVM's test are implemented.
    "LLVM_CPPFLAGS=.",  # FIXME
    "LLVM_CFLAGS=.",  # FIXME
    "LLVM_LDFLAGS=.",  # FIXME
    "LLVM_CXXFLAGS=.",  # FIXME
    "LLVM_BUILDMODE=$build_mode",
    "LLVM_LIBDIR_SUFFIX=",
    "LLVM_TARGETS_BUILT=$llvm_targets_to_build_string",
    "LLVM_SYSTEM_LIBS=$system_libs",
    "LLVM_BUILD_SYSTEM=gn",
    "LLVM_HAS_RTTI=0",
    "LLVM_BUILD_LLVM_DYLIB=0",
    "LLVM_LINK_LLVM_DYLIB=0",
    "BUILD_SHARED_LIBS=0",
    "LLVM_DYLIB_COMPONENTS_expanded=all",
    "LLVM_DYLIB_VERSION=${llvm_version_major}svn",
    "LLVM_HAS_GLOBAL_ISEL=1",
    "LLVM_TOOLS_INSTALL_DIR=",
  ]
}

# FIXME: It'd be nice to not depend on llvm-build on this, Depending on all the
# LLVMBuild.txt files just for this seems a bit overkill.  `gn desc` should
# have all this information too and could be called at build time.
# When this is removed, update llvm/test/BUILD.gn to no longer have unnecessary
# deps on a couple llvm/lib/ targets.
action("LibraryDependencies.inc") {
  script = "//llvm/utils/llvm-build/llvm-build"
  output = "$target_gen_dir/LibraryDependencies.inc"
  args = [
    "--native-target=$native_target",
    "--enable-targets=$llvm_targets_to_build_string",
    "--write-library-table=" + rebase_path(output, root_out_dir),
  ]
  outputs = [
    output,
  ]
}

executable("llvm-config") {
  deps = [
    ":BuildVariables.inc",
    ":LibraryDependencies.inc",
    "//llvm/include/llvm/Config:config",
    "//llvm/include/llvm/Config:llvm-config",
    "//llvm/lib/Support",
  ]

  # To pick up the generated inc files.
  include_dirs = [ "$target_gen_dir" ]
  sources = [
    "llvm-config.cpp",
  ]
}