1import("//clang/lib/ARCMigrate/enable.gni") 2import("//clang/tools/libclang/include_clang_tools_extra.gni") 3import("//llvm/version.gni") 4 5# This build file is just enough to get check-clang to pass, it's missing 6# several things from the CMake build: 7# - using libclang.exports 8# - a build target copying the Python bindings 9# - the GN linux build always builds without -fPIC (as if LLVM_ENABLE_PIC=OFF 10# in the CMake build), so libclang is always a static library on linux 11# - the GN build doesn't have LIBCLANG_BUILD_STATIC 12 13libclang_target_type = "shared_library" 14if (host_os != "win" && host_os != "mac") { 15 # ELF targets need -fPIC to build shared libs but they aren't on by default. 16 # For now, make libclang a static lib there. 17 libclang_target_type = "static_library" 18} 19 20target(libclang_target_type, "libclang") { 21 configs += [ "//llvm/utils/gn/build:clang_code" ] 22 deps = [ 23 "//clang/include/clang/Config", 24 "//clang/lib/AST", 25 "//clang/lib/Basic", 26 "//clang/lib/Frontend", 27 "//clang/lib/Headers", 28 "//clang/lib/Index", 29 "//clang/lib/Lex", 30 "//clang/lib/Sema", 31 "//clang/lib/Tooling", 32 "//llvm/include/llvm/Config:llvm-config", 33 "//llvm/lib/IR", 34 "//llvm/lib/Support", 35 "//llvm/lib/Target:TargetsToBuild", 36 ] 37 if (clang_enable_arcmt) { 38 deps += [ "//clang/lib/ARCMigrate" ] 39 } 40 41 defines = [] 42 43 # FIXME: Once the GN build has a way to select which bits to build, 44 # only include this dependency if clang-tools-extra is part of the build. 45 if (libclang_include_clang_tools_extra) { 46 defines += [ "CLANG_TOOL_EXTRA_BUILD" ] 47 deps += [ 48 "//clang-tools-extra/clang-include-fixer/plugin", 49 "//clang-tools-extra/clang-tidy/plugin", 50 ] 51 } 52 53 if (host_os == "win") { 54 defines += [ "_CINDEX_LIB_" ] 55 } 56 57 sources = [ 58 "../../include/clang-c/Index.h", 59 "ARCMigrate.cpp", 60 "BuildSystem.cpp", 61 "CIndex.cpp", 62 "CIndexCXX.cpp", 63 "CIndexCodeCompletion.cpp", 64 "CIndexDiagnostic.cpp", 65 "CIndexDiagnostic.h", 66 "CIndexHigh.cpp", 67 "CIndexInclusionStack.cpp", 68 "CIndexUSRs.cpp", 69 "CIndexer.cpp", 70 "CIndexer.h", 71 "CXComment.cpp", 72 "CXCompilationDatabase.cpp", 73 "CXCursor.cpp", 74 "CXCursor.h", 75 "CXIndexDataConsumer.cpp", 76 "CXLoadedDiagnostic.cpp", 77 "CXLoadedDiagnostic.h", 78 "CXSourceLocation.cpp", 79 "CXSourceLocation.h", 80 "CXStoredDiagnostic.cpp", 81 "CXString.cpp", 82 "CXString.h", 83 "CXTranslationUnit.h", 84 "CXType.cpp", 85 "CXType.h", 86 "FatalErrorHandler.cpp", 87 "Index_Internal.h", 88 "Indexing.cpp", 89 "Rewrite.cpp", 90 ] 91 if (host_os == "mac") { 92 ldflags = [ 93 "-Wl,-compatibility_version,1", 94 "-Wl,-current_version,$llvm_version", 95 96 # See llvm_setup_rpath() in CMake. 97 "-Wl,-install_name,@rpath/libclang.dylib", 98 "-Wl,-rpath,@loader_path/../lib", 99 ] 100 } 101 102 # FIXME: Use libclang.exports 103} 104