Debian Codegraph @

llvm/utils/gn/secondary/bolt/test/BUILD.gn

raw
1 import("//llvm/lib/Target/targets_string.gni")
2 import("//llvm/triples.gni")
3 import("//llvm/utils/gn/build/write_cmake_config.gni")
4 import("bolt_lit_site_cfg_files.gni")
5
6 template("write_lit_config") {
7 write_cmake_config(target_name) {
8 input = invoker.input
9 output = invoker.output
10 values = [
11 "BOLT_BINARY_DIR=" +
12 rebase_path(get_label_info("//bolt", "target_out_dir")),
13 "BOLT_SOURCE_DIR=" + rebase_path("//bolt"),
14 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
15 "LLVM_BINARY_DIR=" + get_label_info("//llvm", "target_out_dir"),
16 "LLVM_LIBS_DIR=", # needed only for shared builds
17 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
18 "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
19 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
20 "LLVM_TARGET_TRIPLE=$llvm_target_triple",
21 ]
22 values += invoker.extra_values
23 }
24 }
25
26 write_lit_config("lit_site_cfg") {
27 bolt_targets_to_build_string = ""
28 if (llvm_build_AArch64) {
29 bolt_targets_to_build_string += "AArch64"
30 }
31 if (llvm_build_X86) {
32 if (bolt_targets_to_build_string != "") {
33 bolt_targets_to_build_string += " "
34 }
35 bolt_targets_to_build_string += "X86"
36 }
37
38 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
39 input = "//bolt/test/lit.site.cfg.py.in"
40 output = bolt_lit_site_cfg_file
41 dir = get_path_info(output, "dir")
42 extra_values = [
43 "BOLT_CLANG_EXE=" + rebase_path("$root_build_dir/bin/clang"),
44 "BOLT_LLD_EXE=" + rebase_path("$root_build_dir/bin/ld.lld"),
45 "BOLT_ENABLE_RUNTIME=0", # FIXME: enable runtime
46 "BOLT_TARGETS_TO_BUILD=$bolt_targets_to_build_string",
47 "GNU_LD_EXECUTABLE=", # FIXME: set sometimes?
48 "LLVM_HOST_TRIPLE=$llvm_current_triple",
49 "LLVM_USE_SANITIZER=",
50 "Python3_EXECUTABLE=$python_path",
51 ]
52
53 if (host_os == "win") {
54 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
55 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
56 } else {
57 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
58 }
59
60 if (host_cpu == "x64") {
61 extra_values += [ "HOST_ARCH=x86_64" ]
62 } else if (host_cpu == "arm64") {
63 extra_values += [ "HOST_ARCH=arm64" ]
64 } else if (host_cpu == "ppc64") {
65 extra_values += [ "HOST_ARCH=powerpc64le" ]
66 } else {
67 assert(false, "unimplemented host_cpu " + host_cpu)
68 }
69 }
70
71 write_lit_config("lit_unit_site_cfg") {
72 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
73 input = "//bolt/test/Unit/lit.site.cfg.py.in"
74 output = bolt_lit_unit_site_cfg_file
75 extra_values = [ "LLVM_BUILD_MODE=." ]
76 }
77
78 # This target should contain all dependencies of check-bolt.
79 # //:default depends on it, so that ninja's default target builds all
80 # prerequisites for check-bolt but doesn't run check-bolt itself.
81 group("test") {
82 deps = [
83 ":lit_site_cfg",
84 ":lit_unit_site_cfg",
85 "//bolt/tools/bat-dump:llvm-bat-dump",
86 "//bolt/tools/driver:symlinks",
87 "//bolt/tools/heatmap:llvm-bolt-heatmap",
88 "//bolt/tools/merge-fdata",
89 "//bolt/unittests",
90 "//clang/tools/driver:symlinks",
91 "//lld/tools/lld:symlinks",
92 "//llvm/tools/llc",
93 "//llvm/tools/llvm-config",
94 "//llvm/tools/llvm-dwarfdump",
95 "//llvm/tools/llvm-dwp",
96 "//llvm/tools/llvm-mc",
97 "//llvm/tools/llvm-nm:symlinks",
98 "//llvm/tools/llvm-objcopy:symlinks",
99 "//llvm/tools/llvm-objdump:symlinks",
100 "//llvm/tools/yaml2obj",
101 "//llvm/utils/FileCheck",
102 "//llvm/utils/count",
103 "//llvm/utils/not",
104 ]
105
106 testonly = true
107 }
108
109 action("check-bolt") {
110 script = "$root_out_dir/bin/llvm-lit"
111 if (host_os == "win") {
112 script += ".py"
113 }
114 args = [
115 "-sv",
116 rebase_path(".", root_out_dir),
117 ]
118 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
119 # each time.
120
121 # Since check-bolt is always dirty, //:default doesn't depend on it so that
122 # it's not part of the default ninja target. Hence, check-bolt shouldn't
123 # have any deps except :test. so that the default target is sure to build
124 # all the deps.
125 deps = [ ":test" ]
126 testonly = true
127
128 pool = "//:console"
129 }