[lit] Improve lit.Run class
[llvm-complete.git] / utils / gn / secondary / llvm / tools / llvm-config / BUILD.gn
blob58334c8caf6373d9e742418192660ef71c168edd
1 import("//llvm/lib/Target/targets_string.gni")
2 import("//llvm/utils/gn/build/buildflags.gni")
3 import("//llvm/utils/gn/build/libs/pthread/enable.gni")
4 import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
5 import("//llvm/utils/gn/build/libs/xml/enable.gni")
6 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
7 import("//llvm/utils/gn/build/write_cmake_config.gni")
8 import("//llvm/version.gni")
10 write_cmake_config("BuildVariables.inc") {
11   input = "BuildVariables.inc.in"
12   output = "$target_gen_dir/BuildVariables.inc"
14   if (is_debug) {
15     build_mode = "debug"
16   } else {
17     build_mode = "release"
18   }
20   # FIXME: Why doesn't llvm-config do this, why is this done in
21   # llvm-config/CMakeLists.txt?
22   if (host_os == "win") {
23     l = ""
24     lib = ".lib"
25   } else {
26     l = "-l"
27     lib = ""
28   }
30   # Windows doesn't use any of libxml2,terminfo, zlib by default.
31   # Make GN not warn about these variables being unused.
32   not_needed([
33                "l",
34                "lib",
35              ])
37   system_libs = ""
38   if (host_os == "win") {
39     # libuuid required for FOLDERID_Profile usage in
40     # lib/Support/Windows/Path.inc.
41     # advapi32 required for CryptAcquireContextW in
42     # lib/Support/Windows/Path.inc
43     system_libs = "psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib"
44   } else {
45     system_libs += "-lm"
46     if (host_os == "linux") {
47       system_libs += " -lrt -ldl"
48     }
49     if (llvm_enable_threads) {
50       system_libs += " -llibpthreads"
51       if (host_os == "linux") {
52         system_libs += " -latomic"
53       }
54     }
55   }
56   if (llvm_enable_libxml2) {
57     system_libs += " ${l}xml2${lib}"
58   }
59   if (llvm_enable_terminfo) {
60     system_libs += " ${l}ncurses${lib}"
61   }
62   if (llvm_enable_zlib) {
63     system_libs += " ${l}z${lib}"
64   }
66   values = [
67     "LLVM_SRC_ROOT=" + rebase_path("//llvm"),
68     "LLVM_OBJ_ROOT=" + rebase_path(root_out_dir),
70     # FIXME: Only the bits needed to run LLVM's test are implemented.
71     "LLVM_CPPFLAGS=.",  # FIXME
72     "LLVM_CFLAGS=.",  # FIXME
73     "LLVM_LDFLAGS=.",  # FIXME
74     "LLVM_CXXFLAGS=.",  # FIXME
75     "LLVM_BUILDMODE=$build_mode",
76     "LLVM_LIBDIR_SUFFIX=",
77     "LLVM_TARGETS_BUILT=$llvm_targets_to_build_string",
78     "LLVM_SYSTEM_LIBS=$system_libs",
79     "LLVM_BUILD_SYSTEM=gn",
80     "LLVM_HAS_RTTI=0",
81     "LLVM_BUILD_LLVM_DYLIB=0",
82     "LLVM_LINK_LLVM_DYLIB=0",
83     "BUILD_SHARED_LIBS=0",
84     "LLVM_DYLIB_COMPONENTS_expanded=all",
85     "LLVM_DYLIB_VERSION=${llvm_version_major}svn",
86     "LLVM_HAS_GLOBAL_ISEL=1",
87     "LLVM_TOOLS_INSTALL_DIR=",
88   ]
91 # FIXME: It'd be nice to not depend on llvm-build on this, Depending on all the
92 # LLVMBuild.txt files just for this seems a bit overkill.  `gn desc` should
93 # have all this information too and could be called at build time.
94 # When this is removed, update llvm/test/BUILD.gn to no longer have unnecessary
95 # deps on a couple llvm/lib/ targets.
96 action("LibraryDependencies.inc") {
97   script = "//llvm/utils/llvm-build/llvm-build"
98   output = "$target_gen_dir/LibraryDependencies.inc"
99   args = [
100     "--native-target=$native_target",
101     "--enable-targets=$llvm_targets_to_build_string",
102     "--write-library-table=" + rebase_path(output, root_out_dir),
103   ]
104   outputs = [
105     output,
106   ]
109 executable("llvm-config") {
110   deps = [
111     ":BuildVariables.inc",
112     ":LibraryDependencies.inc",
113     "//llvm/include/llvm/Config:config",
114     "//llvm/include/llvm/Config:llvm-config",
115     "//llvm/lib/Support",
116   ]
118   # To pick up the generated inc files.
119   include_dirs = [ "$target_gen_dir" ]
120   sources = [
121     "llvm-config.cpp",
122   ]