Build libclang.so with libclang tool
Scripts like bionic/libc/kernel/tools/cpp.py use libclang tool to parse
C/C++ files. Change the makefiles of clang to include the support
functions into libclang.so.
Bug: 19426389
Change-Id: Ide7d80cc43a043a92e0282586dc0e6f7d3d79ddb
diff --git a/Android.mk b/Android.mk
index 508814c..d5495b3 100644
--- a/Android.mk
+++ b/Android.mk
@@ -6,6 +6,7 @@
subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
lib/Analysis \
lib/AST \
+ lib/ASTMatchers \
lib/ARCMigrate \
lib/Basic \
lib/CodeGen \
@@ -16,6 +17,7 @@
lib/Frontend/Rewrite \
lib/FrontendTool \
lib/Headers \
+ lib/Index \
lib/Lex \
lib/Parse \
lib/Rewrite \
@@ -24,7 +26,9 @@
lib/StaticAnalyzer/Checkers \
lib/StaticAnalyzer/Core \
lib/StaticAnalyzer/Frontend \
+ lib/Tooling \
tools/driver \
+ tools/libclang \
utils/TableGen \
))
diff --git a/lib/ASTMatchers/Android.mk b/lib/ASTMatchers/Android.mk
new file mode 100644
index 0000000..25395f1
--- /dev/null
+++ b/lib/ASTMatchers/Android.mk
@@ -0,0 +1,43 @@
+LOCAL_PATH:= $(call my-dir)
+
+
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+ AttrList.inc \
+ Attrs.inc \
+ AttrVisitor.inc \
+ CommentCommandList.inc \
+ DeclNodes.inc \
+ DiagnosticCommonKinds.inc \
+ StmtNodes.inc \
+
+clang_astmatchers_SRC_FILES := \
+ ASTMatchFinder.cpp \
+ ASTMatchersInternal.cpp
+
+# For the host
+# =====================================================
+#
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_astmatchers_SRC_FILES)
+LOCAL_MODULE:= libclangASTMatchers
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+# For the target
+# =====================================================
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(clang_astmatchers_SRC_FILES)
+LOCAL_MODULE:= libclangASTMatchers
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_DEVICE_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/Format/Android.mk b/lib/Format/Android.mk
index 302f28f..dc3dfa8 100644
--- a/lib/Format/Android.mk
+++ b/lib/Format/Android.mk
@@ -1,8 +1,5 @@
LOCAL_PATH:= $(call my-dir)
-# For the host only
-# =====================================================
-include $(CLEAR_VARS)
include $(CLEAR_TBLGEN_VARS)
TBLGEN_TABLES := \
@@ -27,17 +24,32 @@
Format.cpp \
FormatToken.cpp \
TokenAnnotator.cpp \
+ UnwrappedLineFormatter.cpp \
UnwrappedLineParser.cpp \
WhitespaceManager.cpp
+# For the host
+# =====================================================
+include $(CLEAR_VARS)
+
LOCAL_SRC_FILES := $(clang_format_SRC_FILES)
-
LOCAL_MODULE:= libclangFormat
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_TAGS := optional
-
include $(CLANG_HOST_BUILD_MK)
include $(CLANG_VERSION_INC_MK)
include $(CLANG_TBLGEN_RULES_MK)
include $(BUILD_HOST_STATIC_LIBRARY)
+
+# For the target
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_format_SRC_FILES)
+LOCAL_MODULE:= libclangFormat
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_DEVICE_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/Index/Android.mk b/lib/Index/Android.mk
new file mode 100644
index 0000000..2c26569
--- /dev/null
+++ b/lib/Index/Android.mk
@@ -0,0 +1,42 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+ AttrList.inc \
+ Attrs.inc \
+ CommentCommandList.inc \
+ CommentNodes.inc \
+ DeclNodes.inc \
+ DiagnosticCommonKinds.inc \
+ StmtNodes.inc
+
+clang_index_SRC_FILES := \
+ CommentToXML.cpp \
+ USRGeneration.cpp \
+
+# For the host
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_index_SRC_FILES)
+LOCAL_MODULE:= libclangIndex
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+# For the target
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_index_SRC_FILES)
+LOCAL_MODULE:= libclangIndex
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_DEVICE_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/Tooling/Android.mk b/lib/Tooling/Android.mk
new file mode 100644
index 0000000..d3dc13b
--- /dev/null
+++ b/lib/Tooling/Android.mk
@@ -0,0 +1,50 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+ AttrList.inc \
+ Attrs.inc \
+ CommentCommandList.inc \
+ DeclNodes.inc \
+ DiagnosticCommonKinds.inc \
+ DiagnosticDriverKinds.inc \
+ DiagnosticFrontendKinds.inc \
+ StmtNodes.inc \
+
+clang_tooling_SRC_FILES := \
+ ArgumentsAdjusters.cpp \
+ CommonOptionsParser.cpp \
+ CompilationDatabase.cpp \
+ Core/Replacement.cpp \
+ FileMatchTrie.cpp \
+ JSONCompilationDatabase.cpp \
+ Refactoring.cpp \
+ RefactoringCallbacks.cpp \
+ Tooling.cpp \
+
+# For the host
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_tooling_SRC_FILES)
+LOCAL_MODULE:= libclangTooling
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+# For the target
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_tooling_SRC_FILES)
+LOCAL_MODULE:= libclangTooling
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_DEVICE_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/shared_clang.mk b/shared_clang.mk
index 6850a2e..151a626 100644
--- a/shared_clang.mk
+++ b/shared_clang.mk
@@ -6,19 +6,24 @@
LOCAL_PATH:= $(call my-dir)
clang_whole_static_libraries := \
- libclangDriver \
- libclangParse \
- libclangSema \
libclangAnalysis \
- libclangCodeGen \
libclangAST \
- libclangEdit \
- libclangLex \
- libclangFrontend \
+ libclangASTMatchers \
libclangBasic \
+ libclangCodeGen \
+ libclangDriver \
+ libclangEdit \
+ libclangFormat \
+ libclangFrontend \
+ libclangIndex \
+ libclangLex \
+ libclangLibclang \
+ libclangParse \
libclangRewrite \
libclangRewriteFrontend \
- libclangSerialization
+ libclangSema \
+ libclangSerialization \
+ libclangTooling
# host
include $(CLEAR_VARS)
diff --git a/tools/libclang/Android.mk b/tools/libclang/Android.mk
new file mode 100644
index 0000000..1176fb4
--- /dev/null
+++ b/tools/libclang/Android.mk
@@ -0,0 +1,68 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+ AttrList.inc \
+ AttrParsedAttrList.inc \
+ Attrs.inc \
+ AttrVisitor.inc \
+ CommentCommandList.inc \
+ CommentNodes.inc \
+ DiagnosticCommonKinds.inc \
+ DiagnosticFrontendKinds.inc \
+ DiagnosticGroups.inc \
+ DiagnosticSerializationKinds.inc \
+ DeclNodes.inc \
+ StmtNodes.inc \
+
+clang_libclang_SRC_FILES := \
+ ARCMigrate.cpp \
+ BuildSystem.cpp \
+ CIndex.cpp \
+ CIndexCXX.cpp \
+ CIndexCodeCompletion.cpp \
+ CIndexDiagnostic.cpp \
+ CIndexHigh.cpp \
+ CIndexInclusionStack.cpp \
+ CIndexUSRs.cpp \
+ CIndexer.cpp \
+ CXComment.cpp \
+ CXCompilationDatabase.cpp \
+ CXCursor.cpp \
+ CXLoadedDiagnostic.cpp \
+ CXSourceLocation.cpp \
+ CXStoredDiagnostic.cpp \
+ CXString.cpp \
+ CXType.cpp \
+ IndexBody.cpp \
+ IndexDecl.cpp \
+ IndexTypeSourceInfo.cpp \
+ Indexing.cpp \
+ IndexingContext.cpp \
+
+# For the host
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_libclang_SRC_FILES)
+LOCAL_MODULE := libclangLibclang
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+# For the target
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(clang_libclang_SRC_FILES)
+LOCAL_MODULE := libclangLibclang
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_DEVICE_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_STATIC_LIBRARY)