[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / utils / gn / secondary / clang / tools / driver / BUILD.gn
blob7324e047ade6b830547a2136275dcff69cd8898e
1 import("//llvm/utils/gn/build/symlink_or_copy.gni")
2 import("//llvm/utils/gn/build/write_cmake_config.gni")
3 import("//llvm/version.gni")
5 symlinks = [
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   ],
20 foreach(target, symlinks) {
21   symlink_or_copy(target[0]) {
22     deps = [
23       ":clang",
24     ]
25     source = "clang"
26     output = "$root_out_dir/bin/${target[1]}"
27   }
30 # //:clang depends on this symlink target, see comment in //BUILD.gn.
31 group("symlinks") {
32   deps = []
33   foreach(target, symlinks) {
34     deps += [ ":${target[0]}" ]
35   }
38 if (host_os == "mac") {
39   write_cmake_config("write_info_plist") {
40     input = "Info.plist.in"
41     output = "$target_gen_dir/Info.plist"
42     values = [
43       "TOOL_INFO_BUILD_VERSION=$llvm_version_major.$llvm_version_minor",
44       "TOOL_INFO_NAME=clang",
45       "TOOL_INFO_UTI=org.llvm.clang",
46       "TOOL_INFO_VERSION=$llvm_version",
47     ]
48   }
51 executable("clang") {
52   configs += [ "//llvm/utils/gn/build:clang_code" ]
53   deps = [
54     "//clang/include/clang/Config",
55     "//clang/lib/Basic",
56     "//clang/lib/CodeGen",
57     "//clang/lib/Driver",
58     "//clang/lib/Frontend",
59     "//clang/lib/FrontendTool",
60     "//clang/lib/Headers",
61     "//clang/tools/clang-offload-bundler",
62     "//llvm/include/llvm/Config:llvm-config",
63     "//llvm/lib/Analysis",
64     "//llvm/lib/CodeGen",
65     "//llvm/lib/IR",
66     "//llvm/lib/MC",
67     "//llvm/lib/MC/MCParser",
68     "//llvm/lib/Option",
69     "//llvm/lib/Support",
70     "//llvm/lib/Target:TargetsToBuild",
71     "//llvm/lib/Transforms/IPO",
72     "//llvm/lib/Transforms/InstCombine",
73     "//llvm/lib/Transforms/Instrumentation",
74     "//llvm/lib/Transforms/ObjCARC",
75     "//llvm/lib/Transforms/Scalar",
76     "//llvm/lib/Transforms/Utils",
77     "//llvm/lib/Transforms/Vectorize",
78   ]
79   if (host_os == "mac") {
80     deps += [ ":write_info_plist" ]
81     plist = get_target_outputs(":write_info_plist")
82     ldflags = [ "-Wl,-sectcreate,__TEXT,__info_plist," +
83                 rebase_path(plist[0], root_out_dir) ]
84   }
85   sources = [
86     "cc1_main.cpp",
87     "cc1as_main.cpp",
88     "cc1gen_reproducer_main.cpp",
89     "driver.cpp",
90   ]