• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import("//llvm/utils/gn/build/symlink_or_copy.gni")
2import("//llvm/utils/gn/build/write_cmake_config.gni")
3import("//llvm/version.gni")
4
5symlinks = [
6  # target_name, symlink_target pairs: GN doesn't support '+' in rule names.
7  [
8    "clangxx",
9    "clang++",
10  ],
11  [
12    "clang-cl",
13    "clang-cl",
14  ],
15  [
16    "clang-cpp",
17    "clang-cpp",
18  ],
19]
20foreach(target, symlinks) {
21  symlink_or_copy(target[0]) {
22    deps = [ ":clang" ]
23    source = "clang"
24    output = "$root_out_dir/bin/${target[1]}"
25  }
26}
27
28# //:clang depends on this symlink target, see comment in //BUILD.gn.
29group("symlinks") {
30  deps = []
31  foreach(target, symlinks) {
32    deps += [ ":${target[0]}" ]
33  }
34}
35
36if (host_os == "mac") {
37  write_cmake_config("write_info_plist") {
38    input = "Info.plist.in"
39    output = "$target_gen_dir/Info.plist"
40    values = [
41      "TOOL_INFO_BUILD_VERSION=$llvm_version_major.$llvm_version_minor",
42      "TOOL_INFO_NAME=clang",
43      "TOOL_INFO_UTI=org.llvm.clang",
44      "TOOL_INFO_VERSION=$llvm_version",
45    ]
46  }
47}
48
49executable("clang") {
50  configs += [ "//llvm/utils/gn/build:clang_code" ]
51  deps = [
52    "//clang/include/clang/Config",
53    "//clang/lib/Basic",
54    "//clang/lib/CodeGen",
55    "//clang/lib/Driver",
56    "//clang/lib/Frontend",
57    "//clang/lib/FrontendTool",
58    "//clang/lib/Headers",
59    "//clang/tools/clang-offload-bundler",
60    "//clang/tools/clang-offload-wrapper",
61    "//llvm/include/llvm/Config:llvm-config",
62    "//llvm/lib/Analysis",
63    "//llvm/lib/CodeGen",
64    "//llvm/lib/IR",
65    "//llvm/lib/MC",
66    "//llvm/lib/MC/MCParser",
67    "//llvm/lib/Option",
68    "//llvm/lib/Support",
69    "//llvm/lib/Target:TargetsToBuild",
70    "//llvm/lib/Transforms/IPO",
71    "//llvm/lib/Transforms/InstCombine",
72    "//llvm/lib/Transforms/Instrumentation",
73    "//llvm/lib/Transforms/ObjCARC",
74    "//llvm/lib/Transforms/Scalar",
75    "//llvm/lib/Transforms/Utils",
76    "//llvm/lib/Transforms/Vectorize",
77  ]
78  if (host_os == "mac") {
79    deps += [ ":write_info_plist" ]
80    plist = get_target_outputs(":write_info_plist")
81    ldflags = [ "-Wl,-sectcreate,__TEXT,__info_plist," +
82                rebase_path(plist[0], root_out_dir) ]
83
84    # On macOS, libcxx headers are bundled with the compiler, not with the
85    # sysroot. As a convenience, automatically copy them over when buildling
86    # clang.  This is different from the CMake build, which requires devs to
87    # explicitly build the "libcxx" target (which also needlessly compiles the
88    # libcxx sources) to get a working compiler.
89    deps += [ "//libcxx/include" ]
90  }
91  sources = [
92    "cc1_main.cpp",
93    "cc1as_main.cpp",
94    "cc1gen_reproducer_main.cpp",
95    "driver.cpp",
96  ]
97}
98