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/utils/llvm-lit/lit_path_function.gni")
import("lld_lit_site_cfg_files.gni")
-write_cmake_config("lit_site_cfg") {
+# 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\n\n" + lit_path_function,
+ "LLD_BINARY_DIR=" +
+ rebase_path(get_label_info("//lld", "target_out_dir")),
+ "CURRENT_LIBS_DIR=", # FIXME: for shared builds only (?)
+ "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+ "LLD_SOURCE_DIR=" + rebase_path("//lld"),
+ "LLVM_BINARY_DIR=" +
+ rebase_path(get_label_info("//llvm", "target_out_dir")),
+ "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
+ "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+ ]
+ 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
dir = get_path_info(output, "dir")
- values = [
- "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
- "LLD_BINARY_DIR=" + rebase_path(get_label_info("//lld", "target_out_dir")),
- "CURRENT_LIBS_DIR=", # FIXME: for shared builds only (?)
- "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+ extra_values = [
"ENABLE_BACKTRACES=1",
- "LLD_SOURCE_DIR=" + rebase_path("//lld"),
- "LLVM_BINARY_DIR=" +
- rebase_path(get_label_info("//llvm", "target_out_dir")),
"LLVM_HOST_TRIPLE=$llvm_current_triple",
"LLVM_LIBS_DIR=", # needed only for shared builds
"LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
- "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
- "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
"Python3_EXECUTABLE=$python_path",
"LLVM_TARGET_TRIPLE=$llvm_target_triple",
]
if (host_os == "win") {
- values += [
+ extra_values += [
"LLVM_LIT_ERRC_MESSAGES=no such file or directory;is a directory;" +
"invalid argument;permission denied",
"LLVM_ENABLE_PLUGINS=0",
"SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir),
]
} else {
- values += [
+ extra_values += [
"LLVM_LIT_ERRC_MESSAGES=",
"LLVM_ENABLE_PLUGINS=1",
"SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir),
}
if (host_os == "mac") {
- values += [ "SHLIBEXT=.dylib" ]
+ extra_values += [ "SHLIBEXT=.dylib" ]
} else if (host_os == "win") {
- values += [ "SHLIBEXT=.dll" ]
+ extra_values += [ "SHLIBEXT=.dll" ]
} else {
- values += [ "SHLIBEXT=.so" ]
+ extra_values += [ "SHLIBEXT=.so" ]
}
if (llvm_enable_dia_sdk) {
- values += [ "LLVM_ENABLE_DIA_SDK=1" ]
+ extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]
} else {
- values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0.
+ extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0.
}
if (llvm_enable_libxml2) {
- values += [ "LLVM_ENABLE_LIBXML2=1" ]
+ extra_values += [ "LLVM_ENABLE_LIBXML2=1" ]
} else {
- values += [ "LLVM_ENABLE_LIBXML2=0" ] # Must be 0.
+ extra_values += [ "LLVM_ENABLE_LIBXML2=0" ] # Must be 0.
}
if (llvm_enable_zlib) {
- values += [ "LLVM_ENABLE_ZLIB=1" ]
+ extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
} else {
- values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.
+ extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.
}
if (current_cpu == "x64" || current_cpu == "arm64" ||
current_cpu == "ppc64") {
- values += [ "CMAKE_SIZEOF_VOID_P=8" ]
+ 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 = [
+ "ENABLE_SHARED=0",
+ "LLVM_BUILD_MODE=.",
+ ]
+ dir = get_path_info(output, "dir")
+ if (host_os == "win") {
+ # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
+ extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
} else {
- values += [ "CMAKE_SIZEOF_VOID_P=4" ]
+ extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
}
}
group("test") {
deps = [
":lit_site_cfg",
+ ":lit_unit_site_cfg",
"//lld/tools/lld:symlinks",
+ "//lld/unittests",
"//llvm/tools/dsymutil",
"//llvm/tools/llc",
"//llvm/tools/llvm-ar:symlinks",