From a393e9eedcc28b25f521a4feceb3b56e3d0d360f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 16 Mar 2009 23:06:59 +0000 Subject: [PATCH] Build system changes to use TableGen to generate the various diagnostics. This builds on the patch that Sebastian committed and then revert. Major differences are: - We don't remove or use the current ".def" files. Instead, for now, we just make sure that we're building the ".inc" files. - Fixed CMake makefiles to run TableGen and build the ".inc" files when needed. Tested with both the Xcode and Makefile generators provided by CMake, so it should be solid. - Fixed normal makefiles to handle out-of-source builds that involve the ".inc" files. I'll send a separate patch to the list with Sebastian's changes that eliminate the use of the .def files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67058 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 3 +++ Driver/Makefile | 2 +- Makefile | 2 +- include/CMakeLists.txt | 1 + include/Makefile | 4 ++++ include/clang/Basic/CMakeLists.txt | 16 ++++++++++++++++ include/clang/Basic/Makefile | 9 +++++++++ include/clang/CMakeLists.txt | 1 + include/clang/Makefile | 4 ++++ lib/AST/CMakeLists.txt | 2 ++ lib/AST/Makefile | 2 +- lib/Analysis/CMakeLists.txt | 2 ++ lib/Analysis/Makefile | 2 +- lib/Basic/CMakeLists.txt | 10 ++++++++++ lib/Basic/Makefile | 2 +- lib/CodeGen/Makefile | 2 +- lib/Driver/Makefile | 2 +- lib/Frontend/Makefile | 2 +- lib/Lex/CMakeLists.txt | 2 ++ lib/Lex/Makefile | 2 +- lib/Parse/CMakeLists.txt | 2 ++ lib/Parse/Makefile | 2 +- lib/Rewrite/Makefile | 2 +- lib/Sema/CMakeLists.txt | 2 ++ lib/Sema/Makefile | 2 +- tools/driver/Makefile | 2 +- 26 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 include/CMakeLists.txt create mode 100644 include/Makefile create mode 100644 include/clang/Basic/CMakeLists.txt create mode 100644 include/clang/Basic/Makefile create mode 100644 include/clang/CMakeLists.txt create mode 100644 include/clang/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index 3575d88391..6a46c5a785 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ macro(add_clang_library name) if( LLVM_COMMON_DEPENDS ) add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) endif( LLVM_COMMON_DEPENDS ) + add_dependencies(${name} ClangDiagnosticCommon) if(MSVC) get_target_property(cflag ${name} COMPILE_FLAGS) if(NOT cflag) @@ -38,6 +39,7 @@ endmacro(add_clang_executable) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/include ) install(DIRECTORY include @@ -47,6 +49,7 @@ install(DIRECTORY include add_definitions( -D_GNU_SOURCE ) +add_subdirectory(include) add_subdirectory(lib) add_subdirectory(Driver) diff --git a/Driver/Makefile b/Driver/Makefile index 84a484ed0f..962e3fd1bb 100644 --- a/Driver/Makefile +++ b/Driver/Makefile @@ -1,6 +1,6 @@ LEVEL = ../../.. TOOLNAME = clang -CPPFLAGS += -I$(PROJ_SRC_DIR)/../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../include -I$(PROJ_OBJ_DIR)/../include CXXFLAGS = -fno-rtti # Clang has no plugins, optimize startup time. diff --git a/Makefile b/Makefile index 72bfaa78e6..660f0e922b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ LEVEL = ../.. -DIRS := lib Driver docs tools +DIRS := include lib Driver docs tools include $(LEVEL)/Makefile.common diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000000..253a09b101 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(clang) diff --git a/include/Makefile b/include/Makefile new file mode 100644 index 0000000000..47daabc7fa --- /dev/null +++ b/include/Makefile @@ -0,0 +1,4 @@ +LEVEL = ../../.. +DIRS := clang + +include $(LEVEL)/Makefile.common diff --git a/include/clang/Basic/CMakeLists.txt b/include/clang/Basic/CMakeLists.txt new file mode 100644 index 0000000000..9d6e14f85d --- /dev/null +++ b/include/clang/Basic/CMakeLists.txt @@ -0,0 +1,16 @@ +macro(clang_diag_gen component) + tablegen(Diagnostic${component}Kinds.inc + -gen-clang-diags-defs -clang-component=${component}) + add_custom_target(ClangDiagnostic${component} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Diagnostic${component}Kinds.inc) +endmacro(clang_diag_gen) + +set(LLVM_TARGET_DEFINITIONS Diagnostic.td) +clang_diag_gen(Analysis) +clang_diag_gen(AST) +clang_diag_gen(Common) +clang_diag_gen(Driver) +clang_diag_gen(Frontend) +clang_diag_gen(Lex) +clang_diag_gen(Parse) +clang_diag_gen(Sema) \ No newline at end of file diff --git a/include/clang/Basic/Makefile b/include/clang/Basic/Makefile new file mode 100644 index 0000000000..39193111b3 --- /dev/null +++ b/include/clang/Basic/Makefile @@ -0,0 +1,9 @@ +LEVEL = ../../../../.. +BUILT_SOURCES = DiagnosticAnalysisKinds.inc DiagnosticASTKinds.inc \ + DiagnosticCommonKinds.inc DiagnosticDriverKinds.inc \ + DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \ + DiagnosticParseKinds.inc DiagnosticSemaKinds.inc + +CLANG_BUILD_DIAGNOSTICS_INC = 1 + +include $(LEVEL)/Makefile.common diff --git a/include/clang/CMakeLists.txt b/include/clang/CMakeLists.txt new file mode 100644 index 0000000000..39e3698a16 --- /dev/null +++ b/include/clang/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Basic) diff --git a/include/clang/Makefile b/include/clang/Makefile new file mode 100644 index 0000000000..82a16d53ea --- /dev/null +++ b/include/clang/Makefile @@ -0,0 +1,4 @@ +LEVEL = ../../../.. +DIRS := Basic + +include $(LEVEL)/Makefile.common diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt index 9687f34be8..48b1971112 100644 --- a/lib/AST/CMakeLists.txt +++ b/lib/AST/CMakeLists.txt @@ -29,3 +29,5 @@ add_clang_library(clangAST Type.cpp TypeSerialization.cpp ) + +add_dependencies(clangAST ClangDiagnosticAST) diff --git a/lib/AST/Makefile b/lib/AST/Makefile index cdfc64caca..f7d4e9f62d 100644 --- a/lib/AST/Makefile +++ b/lib/AST/Makefile @@ -16,7 +16,7 @@ LIBRARYNAME := clangAST BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Analysis/CMakeLists.txt b/lib/Analysis/CMakeLists.txt index 64aa3a499f..72bc3aea4a 100644 --- a/lib/Analysis/CMakeLists.txt +++ b/lib/Analysis/CMakeLists.txt @@ -31,3 +31,5 @@ add_clang_library(clangAnalysis SymbolManager.cpp UninitializedValues.cpp ) + +add_dependencies(clangAnalysis ClangDiagnosticAnalysis) diff --git a/lib/Analysis/Makefile b/lib/Analysis/Makefile index b1d9178182..c597254fd2 100644 --- a/lib/Analysis/Makefile +++ b/lib/Analysis/Makefile @@ -16,7 +16,7 @@ LIBRARYNAME := clangAnalysis BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt index 37fa210df8..26568598f6 100644 --- a/lib/Basic/CMakeLists.txt +++ b/lib/Basic/CMakeLists.txt @@ -11,3 +11,13 @@ add_clang_library(clangBasic Targets.cpp TokenKinds.cpp ) + +add_dependencies(clangBasic + ClangDiagnosticAnalysis + ClangDiagnosticAST + ClangDiagnosticCommon + ClangDiagnosticDriver + ClangDiagnosticFrontend + ClangDiagnosticLex + ClangDiagnosticParse + ClangDiagnosticSema) diff --git a/lib/Basic/Makefile b/lib/Basic/Makefile index e95d6dbfa3..3fd6c2c153 100644 --- a/lib/Basic/Makefile +++ b/lib/Basic/Makefile @@ -16,7 +16,7 @@ LIBRARYNAME := clangBasic BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/CodeGen/Makefile b/lib/CodeGen/Makefile index 4d7828ef67..e716fe78bc 100644 --- a/lib/CodeGen/Makefile +++ b/lib/CodeGen/Makefile @@ -17,7 +17,7 @@ LIBRARYNAME := clangCodeGen BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Driver/Makefile b/lib/Driver/Makefile index a43033acbe..fb437d2644 100644 --- a/lib/Driver/Makefile +++ b/lib/Driver/Makefile @@ -12,7 +12,7 @@ LIBRARYNAME := clangDriver BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Frontend/Makefile b/lib/Frontend/Makefile index 70edfd5230..8d70847578 100644 --- a/lib/Frontend/Makefile +++ b/lib/Frontend/Makefile @@ -12,7 +12,7 @@ LIBRARYNAME := clangFrontend BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Lex/CMakeLists.txt b/lib/Lex/CMakeLists.txt index 6347142ada..a7237a7b76 100644 --- a/lib/Lex/CMakeLists.txt +++ b/lib/Lex/CMakeLists.txt @@ -22,3 +22,5 @@ add_clang_library(clangLex TokenLexer.cpp TokenConcatenation.cpp ) + +add_dependencies(clangLex ClangDiagnosticLex) diff --git a/lib/Lex/Makefile b/lib/Lex/Makefile index 187448c992..a2437da812 100644 --- a/lib/Lex/Makefile +++ b/lib/Lex/Makefile @@ -22,7 +22,7 @@ ifeq ($(ARCH),PowerPC) CXXFLAGS += -maltivec endif -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Parse/CMakeLists.txt b/lib/Parse/CMakeLists.txt index 91355844e7..8fb7cd23b8 100644 --- a/lib/Parse/CMakeLists.txt +++ b/lib/Parse/CMakeLists.txt @@ -17,3 +17,5 @@ add_clang_library(clangParse ParseTentative.cpp ParseTemplate.cpp ) + +add_dependencies(clangParse ClangDiagnosticParse) diff --git a/lib/Parse/Makefile b/lib/Parse/Makefile index b5d2653bb0..5d69029edc 100644 --- a/lib/Parse/Makefile +++ b/lib/Parse/Makefile @@ -16,7 +16,7 @@ LIBRARYNAME := clangParse BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Rewrite/Makefile b/lib/Rewrite/Makefile index 3c0b5a5727..61fdf4006f 100644 --- a/lib/Rewrite/Makefile +++ b/lib/Rewrite/Makefile @@ -16,7 +16,7 @@ LIBRARYNAME := clangRewrite BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Sema/CMakeLists.txt b/lib/Sema/CMakeLists.txt index 23809b9309..e90c7e30c2 100644 --- a/lib/Sema/CMakeLists.txt +++ b/lib/Sema/CMakeLists.txt @@ -24,3 +24,5 @@ add_clang_library(clangSema SemaTemplateInstantiate.cpp SemaType.cpp ) + +add_dependencies(clangSema ClangDiagnosticSema) diff --git a/lib/Sema/Makefile b/lib/Sema/Makefile index 9193a546ca..0f4c7965dc 100644 --- a/lib/Sema/Makefile +++ b/lib/Sema/Makefile @@ -17,7 +17,7 @@ LIBRARYNAME := clangSema BUILD_ARCHIVE = 1 CXXFLAGS = -fno-rtti -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/tools/driver/Makefile b/tools/driver/Makefile index ca2253a9b0..0ba65e516b 100644 --- a/tools/driver/Makefile +++ b/tools/driver/Makefile @@ -9,7 +9,7 @@ LEVEL = ../../../.. TOOLNAME = clang-driver -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include CXXFLAGS = -fno-rtti # FIXME: It is unfortunate we need to pull in the bitcode reader and