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"
17 build_mode = "release"
20 # FIXME: Why doesn't llvm-config do this, why is this done in
21 # llvm-config/CMakeLists.txt?
22 if (host_os == "win") {
30 # Windows doesn't use any of libxml2,terminfo, zlib by default.
31 # Make GN not warn about these variables being unused.
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"
46 if (host_os == "linux") {
47 system_libs += " -lrt -ldl"
49 if (llvm_enable_threads) {
50 system_libs += " -llibpthreads"
51 if (host_os == "linux") {
52 system_libs += " -latomic"
56 if (llvm_enable_libxml2) {
57 system_libs += " ${l}xml2${lib}"
59 if (llvm_enable_terminfo) {
60 system_libs += " ${l}ncurses${lib}"
62 if (llvm_enable_zlib) {
63 system_libs += " ${l}z${lib}"
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",
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=",
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"
100 "--native-target=$native_target",
101 "--enable-targets=$llvm_targets_to_build_string",
102 "--write-library-table=" + rebase_path(output, root_out_dir),
109 executable("llvm-config") {
111 ":BuildVariables.inc",
112 ":LibraryDependencies.inc",
113 "//llvm/include/llvm/Config:config",
114 "//llvm/include/llvm/Config:llvm-config",
115 "//llvm/lib/Support",
118 # To pick up the generated inc files.
119 include_dirs = [ "$target_gen_dir" ]