xref: /llvm-project/llvm/utils/gn/secondary/BUILD.gn (revision 6d8d7a3acdebf5979b93629a2641ba1bf06c574b)
1import("//clang/lib/ARCMigrate/enable.gni")
2import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
3import("//llvm/utils/gn/build/toolchain/compiler.gni")
4
5group("default") {
6  deps = [
7    "//clang-tools-extra/clangd/test",
8    "//clang-tools-extra/test",
9    "//clang/test",
10    "//clang/tools/scan-build",
11    "//compiler-rt",
12    "//compiler-rt/include",
13    "//compiler-rt/lib/scudo",
14    "//lld/test",
15    "//lldb/test",
16    "//llvm/test",
17  ]
18  # FIXME: Reenable once libc hand-in-hand is figured out.
19  if (false && current_os == "linux") {
20    deps += [
21      "//libcxx",
22      "//libcxxabi",
23    ]
24  }
25  if (current_os == "linux" || current_os == "win" || current_os == "mac") {
26    deps += [ "//compiler-rt/test/asan" ]
27  }
28
29  if (current_os == "linux" || current_os == "mac") {
30    deps += [ "//compiler-rt/test/lsan" ]
31  }
32
33  if (current_os == "linux" || current_os == "android") {
34    deps += [ "//compiler-rt/test/hwasan" ]
35  }
36  if (current_os == "linux" || current_os == "mac") {
37    deps += [ "//libunwind" ]
38  }
39
40  # FIXME: Add this on win after testing that it builds.
41  if (current_os != "win") {
42    deps += [ "//bolt/test" ]
43  }
44
45  testonly = true
46}
47
48# Symlink handling.
49# On POSIX, symlinks to the target can be created before the target exist,
50# and the target can depend on the symlink targets, so that building the
51# target ensures the symlinks exist.
52# However, symlinks didn't exist on Windows until recently, so there the
53# binary needs to be copied -- which requires it to exist. So the symlink step
54# needs to run after the target that creates the binary.
55# In the cmake build, this is done via a "postbuild" on the target, which just
56# tacks on "&& copy out.exe out2.exe" to the link command.
57# GN doesn't have a way to express postbuild commands.  It could probably be
58# emulated by having the link command in the toolchain be a wrapper script that
59# reads a ".symlinks" file next to the target, and have an action write that
60# and make the target depend on that, but then every single link has to use the
61# wrapper (unless we do further acrobatics to use a different toolchain for
62# targets that need symlinks) even though most links don't need symlinks.
63# Instead, have a top-level target for each target that needs symlinks, and
64# make that depend on the symlinks. Then the symlinks can depend on the
65# executable.  This has the effect that `ninja lld` builds lld and then creates
66# symlinks (via this target), while `ninja bin/lld` only builds lld and doesn't
67# update symlinks (in particular, on Windows it doesn't copy the new lld to its
68# new locations).
69# That seems simpler, more explicit, and good enough.
70group("clang") {
71  deps = [ "//clang/tools/driver:symlinks" ]
72}
73group("lld") {
74  deps = [ "//lld/tools/lld:symlinks" ]
75}
76group("llvm-ar") {
77  deps = [ "//llvm/tools/llvm-ar:symlinks" ]
78}
79if (current_os == "mac") {
80  group("llvm-bolt") {
81    deps = [ "//bolt/tools/driver:symlinks" ]
82  }
83}
84group("llvm-dwp") {
85  deps = [ "//llvm/tools/llvm-dwp:symlinks" ]
86}
87group("llvm-nm") {
88  deps = [ "//llvm/tools/llvm-nm:symlinks" ]
89}
90group("llvm-cxxfilt") {
91  deps = [ "//llvm/tools/llvm-cxxfilt:symlinks" ]
92}
93group("llvm-debuginfod") {
94  deps = [ "//llvm/tools/llvm-debuginfod:symlinks" ]
95}
96group("llvm-debuginfod-find") {
97  deps = [ "//llvm/tools/llvm-debuginfod-find:symlinks" ]
98}
99group("llvm-libtool-darwin") {
100  deps = [ "//llvm/tools/llvm-libtool-darwin:symlinks" ]
101}
102group("llvm-lipo") {
103  deps = [ "//llvm/tools/llvm-lipo:symlinks" ]
104}
105group("llvm-objcopy") {
106  deps = [ "//llvm/tools/llvm-objcopy:symlinks" ]
107}
108group("llvm-objdump") {
109  deps = [ "//llvm/tools/llvm-objdump:symlinks" ]
110}
111group("llvm-rc") {
112  deps = [ "//llvm/tools/llvm-rc:symlinks" ]
113}
114group("llvm-readobj") {
115  deps = [ "//llvm/tools/llvm-readobj:symlinks" ]
116}
117group("llvm-size") {
118  deps = [ "//llvm/tools/llvm-size:symlinks" ]
119}
120group("llvm-strings") {
121  deps = [ "//llvm/tools/llvm-strings:symlinks" ]
122}
123group("llvm-symbolizer") {
124  deps = [ "//llvm/tools/llvm-symbolizer:symlinks" ]
125}
126
127# A pool called "console" in the root BUILD.gn is magic and represents ninja's
128# built-in console pool. (Requires a GN with `gn --version` >= 552353.)
129pool("console") {
130  depth = 1
131}
132