File: BUILD.gn

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (129 lines) | stat: -rw-r--r-- 4,226 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import("//llvm/lib/Target/targets_string.gni")
import("//llvm/triples.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("bolt_lit_site_cfg_files.gni")

template("write_lit_config") {
  write_cmake_config(target_name) {
    input = invoker.input
    output = invoker.output
    values = [
      "BOLT_BINARY_DIR=" +
          rebase_path(get_label_info("//bolt", "target_out_dir")),
      "BOLT_SOURCE_DIR=" + rebase_path("//bolt"),
      "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
      "LLVM_BINARY_DIR=" + get_label_info("//llvm", "target_out_dir"),
      "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"),
      "LLVM_TARGET_TRIPLE=$llvm_target_triple",
    ]
    values += invoker.extra_values
  }
}

write_lit_config("lit_site_cfg") {
  bolt_targets_to_build_string = ""
  if (llvm_build_AArch64) {
    bolt_targets_to_build_string += "AArch64"
  }
  if (llvm_build_X86) {
    if (bolt_targets_to_build_string != "") {
      bolt_targets_to_build_string += " "
    }
    bolt_targets_to_build_string += "X86"
  }

  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
  input = "//bolt/test/lit.site.cfg.py.in"
  output = bolt_lit_site_cfg_file
  dir = get_path_info(output, "dir")
  extra_values = [
    "BOLT_CLANG_EXE=" + rebase_path("$root_build_dir/bin/clang"),
    "BOLT_LLD_EXE=" + rebase_path("$root_build_dir/bin/ld.lld"),
    "BOLT_ENABLE_RUNTIME=0",  # FIXME: enable runtime
    "BOLT_TARGETS_TO_BUILD=$bolt_targets_to_build_string",
    "GNU_LD_EXECUTABLE=",  # FIXME: set sometimes?
    "LLVM_HOST_TRIPLE=$llvm_current_triple",
    "LLVM_USE_SANITIZER=",
    "Python3_EXECUTABLE=$python_path",
  ]

  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 {
    extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
  }

  if (host_cpu == "x64") {
    extra_values += [ "HOST_ARCH=x86_64" ]
  } else if (host_cpu == "arm64") {
    extra_values += [ "HOST_ARCH=arm64" ]
  } else if (host_cpu == "ppc64") {
    extra_values += [ "HOST_ARCH=powerpc64le" ]
  } else {
    assert(false, "unimplemented host_cpu " + host_cpu)
  }
}

write_lit_config("lit_unit_site_cfg") {
  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
  input = "//bolt/test/Unit/lit.site.cfg.py.in"
  output = bolt_lit_unit_site_cfg_file
  extra_values = [ "LLVM_BUILD_MODE=." ]
}

# This target should contain all dependencies of check-bolt.
# //:default depends on it, so that ninja's default target builds all
# prerequisites for check-bolt but doesn't run check-bolt itself.
group("test") {
  deps = [
    ":lit_site_cfg",
    ":lit_unit_site_cfg",
    "//bolt/tools/bat-dump:llvm-bat-dump",
    "//bolt/tools/driver:symlinks",
    "//bolt/tools/heatmap:llvm-bolt-heatmap",
    "//bolt/tools/merge-fdata",
    "//bolt/unittests",
    "//clang/tools/driver:symlinks",
    "//lld/tools/lld:symlinks",
    "//llvm/tools/llc",
    "//llvm/tools/llvm-config",
    "//llvm/tools/llvm-dwarfdump",
    "//llvm/tools/llvm-dwp",
    "//llvm/tools/llvm-mc",
    "//llvm/tools/llvm-nm:symlinks",
    "//llvm/tools/llvm-objcopy:symlinks",
    "//llvm/tools/llvm-objdump:symlinks",
    "//llvm/tools/yaml2obj",
    "//llvm/utils/FileCheck",
    "//llvm/utils/count",
    "//llvm/utils/not",
  ]

  testonly = true
}

action("check-bolt") {
  script = "$root_out_dir/bin/llvm-lit"
  if (host_os == "win") {
    script += ".py"
  }
  args = [
    "-sv",
    rebase_path(".", root_out_dir),
  ]
  outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
                                           # each time.

  # Since check-bolt is always dirty, //:default doesn't depend on it so that
  # it's not part of the default ninja target.  Hence, check-bolt shouldn't
  # have any deps except :test. so that the default target is sure to build
  # all the deps.
  deps = [ ":test" ]
  testonly = true

  pool = "//:console"
}