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
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
import("//llvm/triples.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("lld_lit_site_cfg_files.gni")

# The bits common to writing lit.site.cfg.py.in and Unit/lit.site.cfg.py.in.
template("write_lit_cfg") {
  write_cmake_config(target_name) {
    input = invoker.input
    output = invoker.output
    values = [
      "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
      "LLD_BINARY_DIR=" +
          rebase_path(get_label_info("//lld", "target_out_dir")),
      "LLD_SOURCE_DIR=" + rebase_path("//lld"),
      "LLVM_BINARY_DIR=" +
          rebase_path(get_label_info("//llvm", "target_out_dir")),
      "LLVM_LIBRARY_OUTPUT_INTDIR=",  # FIXME: for shared builds only (?)
      "LLVM_LIBS_DIR=",  # needed only for shared builds
      "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
      "LLVM_RUNTIME_OUTPUT_INTDIR=" + rebase_path("$root_out_dir/bin"),
      "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
      "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
      "PYTHON_EXECUTABLE=$python_path",
      "TARGET_TRIPLE=$llvm_target_triple",
    ]
    values += invoker.extra_values
  }
}

write_lit_cfg("lit_site_cfg") {
  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
  input = "//lld/test/lit.site.cfg.py.in"
  output = lld_lit_site_cfg_file

  extra_values = []
  if (llvm_enable_dia_sdk) {
    extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]
  } else {
    extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ]  # Must be 0.
  }

  if (llvm_enable_libxml2) {
    extra_values += [ "LLVM_LIBXML2_ENABLED=1" ]
  } else {
    extra_values += [ "LLVM_LIBXML2_ENABLED=0" ]  # Must be 0.
  }

  if (llvm_enable_zlib) {
    extra_values += [ "HAVE_LIBZ=1" ]
  } else {
    extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
  }

  if (current_cpu == "x64" || current_cpu == "arm64" ||
      current_cpu == "ppc64") {
    extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ]
  } else {
    extra_values += [ "CMAKE_SIZEOF_VOID_P=4" ]
  }
}

write_lit_cfg("lit_unit_site_cfg") {
  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
  input = "//lld/test/Unit/lit.site.cfg.py.in"
  output = lld_lit_unit_site_cfg_file
  extra_values = [ "LLVM_BUILD_MODE=." ]
}

# This target should contain all dependencies of check-lld.
# //:default depends on it, so that ninja's default target builds all
# prerequisites for check-lld but doesn't run check-lld itself.
group("test") {
  deps = [
    ":lit_site_cfg",
    ":lit_unit_site_cfg",
    "//lld/tools/lld:symlinks",
    "//lld/unittests",
    "//llvm/tools/llc",
    "//llvm/tools/llvm-ar:symlinks",
    "//llvm/tools/llvm-as",
    "//llvm/tools/llvm-bcanalyzer",
    "//llvm/tools/llvm-cvtres",
    "//llvm/tools/llvm-dis",
    "//llvm/tools/llvm-dwarfdump",
    "//llvm/tools/llvm-mc",
    "//llvm/tools/llvm-nm:symlinks",
    "//llvm/tools/llvm-objcopy:symlinks",
    "//llvm/tools/llvm-objdump:symlinks",
    "//llvm/tools/llvm-pdbutil",
    "//llvm/tools/llvm-readobj:symlinks",
    "//llvm/tools/obj2yaml",
    "//llvm/tools/opt",
    "//llvm/tools/yaml2obj",
    "//llvm/utils/FileCheck",
    "//llvm/utils/count",
    "//llvm/utils/llvm-lit",
    "//llvm/utils/not",
  ]
  testonly = true
}

# This is the action that runs all of lld's tests, check-lld.
action("check-lld") {
  script = "$root_out_dir/bin/llvm-lit"
  if (host_os == "win") {
    script += ".py"
  }
  args = [
    "-sv",
    "--param",
    "lld_site_config=" + rebase_path(lld_lit_site_cfg_file, root_out_dir),
    "--param",
    "lld_unit_site_config=" +
        rebase_path(lld_lit_unit_site_cfg_file, root_out_dir),
    rebase_path(".", root_out_dir),
  ]
  outputs = [
    "$target_gen_dir/run-lit",  # Non-existing, so that ninja runs it each time.
  ]

  # Since check-lld is always dirty, //:default doesn't depend on it so that
  # it's not part of the default ninja target.  Hence, check-lld shouldn't
  # have any deps except :test, so that the default target is sure to build
  # all the deps.
  deps = [
    ":test",
  ]
  testonly = true

  pool = "//:console"
}