Skip to content

Commit

Permalink
[LLVM] Add revision to version and change defines
Browse files Browse the repository at this point in the history
Change-Id: I84db4c2a47c863f8d2706c06457d4e6e38636bd4
Signed-off-by: Jason Edson <jaysonedson@gmail.com>
  • Loading branch information
mydongistiny committed Aug 8, 2022
1 parent 98339ac commit 779f0af
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 14 deletions.
12 changes: 11 additions & 1 deletion clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,20 @@ set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch")
set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
"Vendor-specific text for showing with version information.")

set(CLANG_REVISION_STRING ${PACKAGE_REVISION} CACHE STRING
"Vendor-specific text for showing the LLVM source svn revision.")

if(CLANG_REVISION_STRING)
add_definitions(-DCLANG_REVISION_STRING="${CLANG_REVISION_STRING}")
endif()

set(CLANG_REPOSITORY_STRING "" CACHE STRING
"Vendor-specific text for showing the repository the source is taken from.")

if(CLANG_REPOSITORY_STRING)
if(PACKAGE_REPOSITORY)
add_definitions(-DCLANG_REPOSITORY_STRING="${PACKAGE_REPOSITORY}")
endif()
if(NOT PACKAGE_REPOSITORY AND CLANG_REPOSITORY_STRING)
add_definitions(-DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}")
endif()

Expand Down
38 changes: 26 additions & 12 deletions clang/lib/Basic/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,47 @@ std::string getClangRepositoryPath() {
}

std::string getLLVMRepositoryPath() {
#ifdef CLANG_REPOSITORY_STRING
return CLANG_REPOSITORY_STRING;
#else
#ifdef LLVM_REPOSITORY
return LLVM_REPOSITORY;
#else
return "";
#endif
#endif
}

std::string getClangVersion() {
#ifdef CLANG_VERSION_STRING
return CLANG_VERSION_STRING;
#else
return "";
#endif
}

std::string getClangRevision() {
#ifdef CLANG_REVISION_STRING
return CLANG_REVISION_STRING;
#else
#ifdef CLANG_REVISION
return CLANG_REVISION;
#else
return "";
#endif
#endif
}

std::string getLLVMRevision() {
#ifdef CLANG_REVISION_STRING
return CLANG_REVISION_STRING;
#else
#ifdef LLVM_REVISION
return LLVM_REVISION;
#else
return "";
#endif
#endif
}

std::string getClangFullRepositoryVersion() {
Expand Down Expand Up @@ -95,12 +115,9 @@ std::string getClangToolFullVersion(StringRef ToolName) {
#ifdef CLANG_VENDOR
OS << CLANG_VENDOR;
#endif
OS << ToolName << " version " CLANG_VERSION_STRING;

std::string repo = getClangFullRepositoryVersion();
if (!repo.empty()) {
OS << " " << repo;
}
std::string ClangVersion = getClangVersion();
std::string ToolchainRevision = getLLVMRevision();
OS << ToolName << " version " << ClangVersion << "-" << ToolchainRevision;

return buf;
}
Expand All @@ -113,12 +130,9 @@ std::string getClangFullCPPVersion() {
#ifdef CLANG_VENDOR
OS << CLANG_VENDOR;
#endif
OS << "Clang " CLANG_VERSION_STRING;

std::string repo = getClangFullRepositoryVersion();
if (!repo.empty()) {
OS << " " << repo;
}
std::string ClangVersion = getClangVersion();
std::string ToolchainRevision = getLLVMRevision();
OS << "Clang " << ClangVersion << "-" << ToolchainRevision;

return buf;
}
Expand Down
9 changes: 8 additions & 1 deletion llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()

if (NOT PACKAGE_VERSION)
set(PACKAGE_VERSION
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}-${PACKAGE_REVISION}")
endif()

if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION)
Expand Down Expand Up @@ -278,6 +278,13 @@ set(PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/")
set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING
"Default URL where bug reports are to be submitted.")

# Vendor stuff
set(PACKAGE_REPOSITORY "" CACHE STRING
"Vendor-specific text for showing the repository the source is taken from.")

set(PACKAGE_REVISION "" CACHE STRING
"Vendor-specific text for showing the LLVM source svn revision.")

# Configure CPack.
set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM")
set(CPACK_PACKAGE_VENDOR "LLVM")
Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/Config/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME "${PACKAGE_NAME}"

/* Define to the url of the repository of this package. */
#cmakedefine PACKAGE_REPOSITORY "${PACKAGE_REPOSITORY}"

/* Define to the revision of this package. */
#cmakedefine PACKAGE_REVISION "${PACKAGE_REVISION}"

/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING "${PACKAGE_STRING}"

Expand Down

0 comments on commit 779f0af

Please sign in to comment.