[cfe-commits] r106863 - in /cfe/trunk: CMakeLists.txt Makefile include/clang/Basic/Makefile include/clang/Basic/Version.h include/clang/Basic/Version.inc.in

Daniel Dunbar daniel at zuster.org
Fri Jun 25 10:33:47 PDT 2010


Author: ddunbar
Date: Fri Jun 25 12:33:46 2010
New Revision: 106863

URL: http://llvm.org/viewvc/llvm-project?rev=106863&view=rev
Log:
build: Add a generated Version.inc file instead of duplicating information.

Added:
    cfe/trunk/include/clang/Basic/Version.inc.in
Modified:
    cfe/trunk/CMakeLists.txt
    cfe/trunk/Makefile
    cfe/trunk/include/clang/Basic/Makefile
    cfe/trunk/include/clang/Basic/Version.h

Modified: cfe/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=106863&r1=106862&r2=106863&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Jun 25 12:33:46 2010
@@ -34,6 +34,23 @@
   ${CLANG_VERSION_DATA})
 message(STATUS "Clang version: ${CLANG_VERSION}")
 
+string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" CLANG_VERSION_MAJOR
+  ${CLANG_VERSION})
+string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" CLANG_VERSION_MINOR
+  ${CLANG_VERSION})
+if (${CLANG_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
+  set(CLANG_HAS_VERSION_PATCHLEVEL 1)
+  string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" CLANG_VERSION_PATCHLEVEL
+    ${CLANG_VERSION})
+else()
+  set(CLANG_HAS_VERSION_PATCHLEVEL 0)
+endif()
+
+# Configure the Version.inc file.
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/include/clang/Basic/Version.inc.in
+  ${CMAKE_CURRENT_BINARY_DIR}/include/clang/Basic/Version.inc)
+
 # Add appropriate flags for GCC
 if (CMAKE_COMPILER_IS_GNUCXX)
   # FIXME: Turn off exceptions, RTTI:

Modified: cfe/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Makefile?rev=106863&r1=106862&r2=106863&view=diff
==============================================================================
--- cfe/trunk/Makefile (original)
+++ cfe/trunk/Makefile Fri Jun 25 12:33:46 2010
@@ -42,6 +42,11 @@
 ifdef CLANG_VENDOR
 CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
 endif
+ifdef CLANG_VERSION
+CPP.Flags += \
+	-DCLANG_VERSION='"$(CLANG_VERSION)"'
+	-DCLANG_VERSION='"$(CLANG_VERSION)"'
+endif
 
 # Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't
 # work with it enabled with GCC), Clang/llvm-gc don't support it yet, and newer
@@ -74,7 +79,7 @@
 
 clean::
 	@ $(MAKE) -C test clean
-	
+
 libs-only: all
 
 tags::

Modified: cfe/trunk/include/clang/Basic/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Makefile?rev=106863&r1=106862&r2=106863&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Makefile (original)
+++ cfe/trunk/include/clang/Basic/Makefile Fri Jun 25 12:33:46 2010
@@ -1,9 +1,11 @@
 CLANG_LEVEL := ../../..
-BUILT_SOURCES = DiagnosticAnalysisKinds.inc DiagnosticASTKinds.inc \
+BUILT_SOURCES = \
+	DiagnosticAnalysisKinds.inc DiagnosticASTKinds.inc \
 	DiagnosticCommonKinds.inc DiagnosticDriverKinds.inc \
 	DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \
 	DiagnosticParseKinds.inc DiagnosticSemaKinds.inc \
-  DiagnosticGroups.inc AttrList.inc arm_neon.inc
+	DiagnosticGroups.inc AttrList.inc arm_neon.inc \
+	Version.inc
 
 TABLEGEN_INC_FILES_COMMON = 1
 
@@ -11,6 +13,17 @@
 
 INPUT_TDS = $(wildcard $(PROJ_SRC_DIR)/Diagnostic*.td)
 
+CLANG_VERSION := $(shell cat $(PROJ_SRC_DIR)/../../../VER)
+CLANG_VERSION_COMPONENTS := $(subst ., ,$(CLANG_VERSION))
+CLANG_VERSION_MAJOR := $(word 1,$(CLANG_VERSION_COMPONENTS))
+CLANG_VERSION_MINOR := $(word 2,$(CLANG_VERSION_COMPONENTS))
+CLANG_VERSION_PATCHLEVEL := $(word 3,$(CLANG_VERSION_COMPONENTS))
+ifeq ($(CLANG_VERSION_PATCHLEVEL),)
+CLANG_HAS_VERSION_PATCHLEVEL := 0
+else
+CLANG_HAS_VERSION_PATCHLEVEL := 1
+endif
+
 $(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(TBLGEN) $(ObjDir)/.dir
 	$(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
 	$(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
@@ -27,3 +40,12 @@
 $(ObjDir)/arm_neon.inc.tmp : arm_neon.td $(TBLGEN) $(ObjDir)/.dir
 	$(Echo) "Building Clang arm_neon.inc with tblgen"
 	$(Verb) $(TableGen) -gen-arm-neon-sema -o $(call SYSPATH, $@) $<
+
+$(ObjDir)/Version.inc.tmp : Version.inc.in $(PROJ_SRC_DIR)/../../../VER $(ObjDir)/.dir
+	$(Echo) "Updating Clang version info."
+	$(Verb)sed -e "s#@CLANG_VERSION@#$(CLANG_VERSION)#g" \
+	           -e "s#@CLANG_VERSION_MAJOR@#$(CLANG_VERSION_MAJOR)#g" \
+	           -e "s#@CLANG_VERSION_MINOR@#$(CLANG_VERSION_MINOR)#g" \
+	           -e "s#@CLANG_VERSION_PATCHLEVEL@#$(CLANG_VERSION_PATCHLEVEL)#g" \
+	           -e "s#@CLANG_HAS_VERSION_PATCHLEVEL@#$(CLANG_HAS_VERSION_PATCHLEVEL)#g" \
+	           $< > $@

Modified: cfe/trunk/include/clang/Basic/Version.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Version.h?rev=106863&r1=106862&r2=106863&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Version.h (original)
+++ cfe/trunk/include/clang/Basic/Version.h Fri Jun 25 12:33:46 2010
@@ -17,15 +17,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
-/// \brief Clang major version
-#define CLANG_VERSION_MAJOR 2
-
-// FIXME: Updates to this file must also update CMakeLists.txt and VER.
-/// \brief Clang minor version
-#define CLANG_VERSION_MINOR 0
-
-/// \brief Clang patchlevel version
-// #define CLANG_VERSION_PATCHLEVEL 1
+#include "clang/Basic/Version.inc"
 
 /// \brief Helper macro for CLANG_VERSION_STRING.
 #define CLANG_MAKE_VERSION_STRING2(X) #X

Added: cfe/trunk/include/clang/Basic/Version.inc.in
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Version.inc.in?rev=106863&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/Version.inc.in (added)
+++ cfe/trunk/include/clang/Basic/Version.inc.in Fri Jun 25 12:33:46 2010
@@ -0,0 +1,6 @@
+#define CLANG_VERSION @CLANG_VERSION@
+#define CLANG_VERSION_MAJOR @CLANG_VERSION_MAJOR@
+#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
+#if @CLANG_HAS_VERSION_PATCHLEVEL@
+#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
+#endif





More information about the cfe-commits mailing list