187 lines · plain
1import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")2import("//llvm/triples.gni")3import("//llvm/utils/gn/build/libs/pthread/enable.gni")4import("//llvm/utils/gn/build/libs/xml/enable.gni")5import("//llvm/utils/gn/build/libs/zlib/enable.gni")6import("//llvm/utils/gn/build/libs/zstd/enable.gni")7import("//llvm/utils/gn/build/write_cmake_config.gni")8import("//llvm/utils/llvm-lit/lit_path_function.gni")9import("lld_lit_site_cfg_files.gni")10 11# The bits common to writing lit.site.cfg.py.in and Unit/lit.site.cfg.py.in.12template("write_lit_cfg") {13 write_cmake_config(target_name) {14 input = invoker.input15 output = invoker.output16 dir = get_path_info(output, "dir")17 values = [18 "LIT_SITE_CFG_IN_HEADER=" +19 "## Autogenerated from $input, do not edit\n\n" + lit_path_function,20 "LLD_BINARY_DIR=" +21 rebase_path(get_label_info("//lld", "target_out_dir"), dir),22 "LLD_SOURCE_DIR=" + rebase_path("//lld", dir),23 ]24 if (host_os == "win") {25 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn26 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]27 } else {28 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]29 }30 values += invoker.extra_values31 }32}33 34write_lit_cfg("lit_site_cfg") {35 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.36 input = "//lld/test/lit.site.cfg.py.in"37 output = lld_lit_site_cfg_file38 dir = get_path_info(output, "dir")39 40 extra_values = [41 "CURRENT_LIBS_DIR=", # FIXME: for shared builds only (?)42 "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),43 "ENABLE_BACKTRACES=1",44 "LLVM_BINARY_DIR=" +45 rebase_path(get_label_info("//llvm", "target_out_dir"), dir),46 "LLVM_HOST_TRIPLE=$llvm_current_triple",47 "LLVM_LIBS_DIR=", # needed only for shared builds48 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.49 "LLVM_SOURCE_DIR=" + rebase_path("//llvm", dir),50 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),51 "Python3_EXECUTABLE=$python_path",52 "LLVM_TARGET_TRIPLE=$llvm_target_triple",53 54 "LLD_DEFAULT_LD_LLD_IS_MINGW=0",55 "LLVM_BUILD_EXAMPLES=0",56 "LLVM_BYE_LINK_INTO_TOOLS=0",57 ]58 59 if (host_os == "win") {60 extra_values += [61 "LLVM_LIT_ERRC_MESSAGES=no such file or directory;is a directory;" +62 "invalid argument;permission denied",63 "LLVM_ENABLE_PLUGINS=0",64 ]65 } else {66 extra_values += [67 "LLVM_LIT_ERRC_MESSAGES=",68 "LLVM_ENABLE_PLUGINS=1",69 ]70 }71 72 if (host_os == "mac") {73 extra_values += [ "SHLIBEXT=.dylib" ]74 } else if (host_os == "win") {75 extra_values += [ "SHLIBEXT=.dll" ]76 } else {77 extra_values += [ "SHLIBEXT=.so" ]78 }79 80 if (llvm_enable_dia_sdk) {81 extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]82 } else {83 extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0.84 }85 86 if (llvm_enable_libxml2) {87 extra_values += [ "LLVM_ENABLE_LIBXML2=1" ]88 } else {89 extra_values += [ "LLVM_ENABLE_LIBXML2=0" ] # Must be 0.90 }91 92 if (llvm_enable_threads) {93 extra_values += [ "LLVM_ENABLE_THREADS=1" ]94 } else {95 extra_values += [ "LLVM_ENABLE_THREADS=0" ] # Must be 0.96 }97 98 if (llvm_enable_zlib) {99 extra_values += [ "LLVM_ENABLE_ZLIB=1" ]100 } else {101 extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.102 }103 104 if (llvm_enable_zstd) {105 extra_values += [ "LLVM_ENABLE_ZSTD=1" ]106 } else {107 extra_values += [ "LLVM_ENABLE_ZSTD=0" ] # Must be 0.108 }109 110 if (current_cpu == "x64" || current_cpu == "arm64" ||111 current_cpu == "ppc64") {112 extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ]113 } else {114 extra_values += [ "CMAKE_SIZEOF_VOID_P=4" ]115 }116}117 118write_lit_cfg("lit_unit_site_cfg") {119 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.120 input = "//lld/test/Unit/lit.site.cfg.py.in"121 output = lld_lit_unit_site_cfg_file122 extra_values = [ "LLVM_BUILD_MODE=." ]123}124 125# This target should contain all dependencies of check-lld.126# //:default depends on it, so that ninja's default target builds all127# prerequisites for check-lld but doesn't run check-lld itself.128group("test") {129 deps = [130 ":lit_site_cfg",131 ":lit_unit_site_cfg",132 "//lld/tools/lld:symlinks",133 "//lld/unittests",134 "//llvm/tools/dsymutil",135 "//llvm/tools/llc",136 "//llvm/tools/llvm-ar:symlinks",137 "//llvm/tools/llvm-as",138 "//llvm/tools/llvm-bcanalyzer",139 "//llvm/tools/llvm-cgdata",140 "//llvm/tools/llvm-cvtres",141 "//llvm/tools/llvm-dis",142 "//llvm/tools/llvm-dwarfdump",143 "//llvm/tools/llvm-lipo:symlinks",144 "//llvm/tools/llvm-mc",145 "//llvm/tools/llvm-nm:symlinks",146 "//llvm/tools/llvm-objcopy:symlinks",147 "//llvm/tools/llvm-objdump:symlinks",148 "//llvm/tools/llvm-pdbutil",149 "//llvm/tools/llvm-profdata",150 "//llvm/tools/llvm-readobj:symlinks",151 "//llvm/tools/llvm-strings:symlinks",152 "//llvm/tools/llvm-symbolizer:symlinks",153 "//llvm/tools/obj2yaml",154 "//llvm/tools/opt",155 "//llvm/tools/yaml2obj",156 "//llvm/utils/FileCheck",157 "//llvm/utils/count",158 "//llvm/utils/llvm-lit",159 "//llvm/utils/not",160 "//llvm/utils/split-file",161 ]162 testonly = true163}164 165# This is the action that runs all of lld's tests, check-lld.166action("check-lld") {167 script = "$root_out_dir/bin/llvm-lit"168 if (host_os == "win") {169 script += ".py"170 }171 args = [172 "-sv",173 rebase_path(".", root_out_dir),174 ]175 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it176 # each time.177 178 # Since check-lld is always dirty, //:default doesn't depend on it so that179 # it's not part of the default ninja target. Hence, check-lld shouldn't180 # have any deps except :test, so that the default target is sure to build181 # all the deps.182 deps = [ ":test" ]183 testonly = true184 185 pool = "//:console"186}187