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 "LIBBOLT_RT_HUGIFY=",
49 "LIBBOLT_RT_INSTR=",
50 "LLVM_HOST_TRIPLE=$llvm_current_triple",
51 "LLVM_USE_SANITIZER=",
52 "Python3_EXECUTABLE=$python_path",
53 ]
54
55 if (host_os == "win") {
56 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
57 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
58 } else {
59 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
60 }
61
62 if (host_cpu == "x64") {
63 extra_values += [ "HOST_ARCH=x86_64" ]
64 } else if (host_cpu == "arm64") {
65 extra_values += [ "HOST_ARCH=arm64" ]
66 } else if (host_cpu == "ppc64") {
67 extra_values += [ "HOST_ARCH=powerpc64le" ]
68 } else {
69 assert(false, "unimplemented host_cpu " + host_cpu)
70 }
71 }
72
73 write_lit_config("lit_unit_site_cfg") {
74 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
75 input = "//bolt/test/Unit/lit.site.cfg.py.in"
76 output = bolt_lit_unit_site_cfg_file
77 extra_values = [ "LLVM_BUILD_MODE=." ]
78 }
79
80 # This target should contain all dependencies of check-bolt.
81 # //:default depends on it, so that ninja's default target builds all
82 # prerequisites for check-bolt but doesn't run check-bolt itself.
83 group("test") {
84 deps = [
85 ":lit_site_cfg",
86 ":lit_unit_site_cfg",
87 "//bolt/tools/bat-dump:llvm-bat-dump",
88 "//bolt/tools/driver:symlinks",
89 "//bolt/tools/heatmap:llvm-bolt-heatmap",
90 "//bolt/tools/merge-fdata",
91 "//bolt/unittests",
92 "//clang/tools/driver:symlinks",
93 "//lld/tools/lld:symlinks",
94 "//llvm/tools/llc",
95 "//llvm/tools/llvm-config",
96 "//llvm/tools/llvm-dwarfdump",
97 "//llvm/tools/llvm-dwp",
98 "//llvm/tools/llvm-mc",
99 "//llvm/tools/llvm-nm:symlinks",
100 "//llvm/tools/llvm-objcopy:symlinks",
101 "//llvm/tools/llvm-objdump:symlinks",
102 "//llvm/tools/yaml2obj",
103 "//llvm/utils/FileCheck",
104 "//llvm/utils/count",
105 "//llvm/utils/not",
106 ]
107
108 testonly = true
109 }
110
111 action("check-bolt") {
112 script = "$root_out_dir/bin/llvm-lit"
113 if (host_os == "win") {
114 script += ".py"
115 }
116 args = [
117 "-sv",
118 rebase_path(".", root_out_dir),
119 ]
120 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
121 # each time.
122
123 # Since check-bolt is always dirty, //:default doesn't depend on it so that
124 # it's not part of the default ninja target. Hence, check-bolt shouldn't
125 # have any deps except :test. so that the default target is sure to build
126 # all the deps.
127 deps = [ ":test" ]
128 testonly = true
129
130 pool = "//:console"
131 }