mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 17:43:57 +00:00
build: Add a generated Version.inc file instead of duplicating information.
llvm-svn: 106863
This commit is contained in:
parent
27510cc623
commit
c3275c5440
@ -34,6 +34,23 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
|||||||
${CLANG_VERSION_DATA})
|
${CLANG_VERSION_DATA})
|
||||||
message(STATUS "Clang version: ${CLANG_VERSION}")
|
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
|
# Add appropriate flags for GCC
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
# FIXME: Turn off exceptions, RTTI:
|
# FIXME: Turn off exceptions, RTTI:
|
||||||
|
@ -42,6 +42,11 @@ CPP.Flags += -I$(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -I$(PROJ_OBJ_DIR)/$(CLANG_
|
|||||||
ifdef CLANG_VENDOR
|
ifdef CLANG_VENDOR
|
||||||
CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
|
CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
|
||||||
endif
|
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
|
# 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
|
# work with it enabled with GCC), Clang/llvm-gc don't support it yet, and newer
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
CLANG_LEVEL := ../../..
|
CLANG_LEVEL := ../../..
|
||||||
BUILT_SOURCES = DiagnosticAnalysisKinds.inc DiagnosticASTKinds.inc \
|
BUILT_SOURCES = \
|
||||||
|
DiagnosticAnalysisKinds.inc DiagnosticASTKinds.inc \
|
||||||
DiagnosticCommonKinds.inc DiagnosticDriverKinds.inc \
|
DiagnosticCommonKinds.inc DiagnosticDriverKinds.inc \
|
||||||
DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \
|
DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \
|
||||||
DiagnosticParseKinds.inc DiagnosticSemaKinds.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
|
TABLEGEN_INC_FILES_COMMON = 1
|
||||||
|
|
||||||
@ -11,6 +13,17 @@ include $(CLANG_LEVEL)/Makefile
|
|||||||
|
|
||||||
INPUT_TDS = $(wildcard $(PROJ_SRC_DIR)/Diagnostic*.td)
|
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
|
$(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"
|
$(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, $@) $<
|
$(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
|
||||||
@ -27,3 +40,12 @@ $(ObjDir)/AttrList.inc.tmp : Attr.td $(TBLGEN) $(ObjDir)/.dir
|
|||||||
$(ObjDir)/arm_neon.inc.tmp : arm_neon.td $(TBLGEN) $(ObjDir)/.dir
|
$(ObjDir)/arm_neon.inc.tmp : arm_neon.td $(TBLGEN) $(ObjDir)/.dir
|
||||||
$(Echo) "Building Clang arm_neon.inc with tblgen"
|
$(Echo) "Building Clang arm_neon.inc with tblgen"
|
||||||
$(Verb) $(TableGen) -gen-arm-neon-sema -o $(call SYSPATH, $@) $<
|
$(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" \
|
||||||
|
$< > $@
|
||||||
|
@ -17,15 +17,7 @@
|
|||||||
|
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
|
|
||||||
/// \brief Clang major version
|
#include "clang/Basic/Version.inc"
|
||||||
#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
|
|
||||||
|
|
||||||
/// \brief Helper macro for CLANG_VERSION_STRING.
|
/// \brief Helper macro for CLANG_VERSION_STRING.
|
||||||
#define CLANG_MAKE_VERSION_STRING2(X) #X
|
#define CLANG_MAKE_VERSION_STRING2(X) #X
|
||||||
|
6
clang/include/clang/Basic/Version.inc.in
Normal file
6
clang/include/clang/Basic/Version.inc.in
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user