Include one single copy of Git commit information
This commit is contained in:
Родитель
815c450f56
Коммит
cde19502c5
|
@ -77,6 +77,15 @@ namespace clang {
|
|||
/// for use in the CPP __VERSION__ macro, which includes the clang version
|
||||
/// number, the repository version, and the vendor tag.
|
||||
std::string getClangFullCPPVersion();
|
||||
|
||||
// HLSL Change Starts
|
||||
#ifdef SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
/// \brief Returns the number of Git commits in current branch.
|
||||
uint32_t getGitCommitCount();
|
||||
/// \brief Returns the hash of the current Git commit.
|
||||
const char *getGitCommitHash();
|
||||
#endif // SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
// HLSL Change Ends
|
||||
}
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_VERSION_H
|
||||
|
|
|
@ -90,3 +90,25 @@ add_clang_library(clangBasic
|
|||
${version_inc}
|
||||
)
|
||||
|
||||
# HLSL Change Starts
|
||||
if ( HLSL_SUPPORT_QUERY_GIT_COMMIT_INFO )
|
||||
set(GIT_COMMIT_INFO_FILE ${CMAKE_CURRENT_BINARY_DIR}/GitCommitInfo.inc)
|
||||
set(GET_GIT_COMMIT_SCRIPT ${PROJECT_SOURCE_DIR}/utils/GetCommitInfo.py)
|
||||
add_custom_command(
|
||||
OUTPUT ${GIT_COMMIT_INFO_FILE}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${GET_GIT_COMMIT_SCRIPT}
|
||||
${PROJECT_SOURCE_DIR} ${GIT_COMMIT_INFO_FILE}
|
||||
DEPENDS ${GET_GIT_COMMIT_SCRIPT} GIT_COMMIT_INFO_ALWAYS_REBUILD
|
||||
COMMENT "Collect Git commit info for versioning"
|
||||
)
|
||||
add_custom_target(
|
||||
GIT_COMMIT_INFO_ALWAYS_REBUILD
|
||||
${CMAKE_COMMAND} -E touch ${GET_GIT_COMMIT_SCRIPT}
|
||||
COMMENT "Touch GetCommitInfo.py to trigger rebuild"
|
||||
)
|
||||
set_property(TARGET GIT_COMMIT_INFO_ALWAYS_REBUILD
|
||||
PROPERTY FOLDER "Utils")
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp
|
||||
PROPERTIES OBJECT_DEPENDS "${GIT_COMMIT_INFO_FILE}")
|
||||
endif()
|
||||
# HLSL Change Ends
|
||||
|
|
|
@ -180,4 +180,12 @@ std::string getClangFullCPPVersion() {
|
|||
#endif // HLSL Change Ends
|
||||
}
|
||||
|
||||
// HLSL Change Starts
|
||||
#ifdef SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
#include "GitCommitInfo.inc"
|
||||
uint32_t getGitCommitCount() { return kGitCommitCount; }
|
||||
const char *getGitCommitHash() { return kGitCommitHash; }
|
||||
#endif // SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
// HLSL Change Ends
|
||||
|
||||
} // end namespace clang
|
||||
|
|
|
@ -125,29 +125,6 @@ else ()
|
|||
include_directories(AFTER ${LLVM_INCLUDE_DIR}/dxc/Tracing)
|
||||
endif (WIN32)
|
||||
|
||||
if ( HLSL_SUPPORT_QUERY_GIT_COMMIT_INFO )
|
||||
set(GIT_COMMIT_INFO_FILE ${CMAKE_CURRENT_BINARY_DIR}/GitCommitInfo.inc)
|
||||
set(GET_GIT_COMMIT_SCRIPT ${PROJECT_SOURCE_DIR}/utils/GetCommitInfo.py)
|
||||
add_custom_command(
|
||||
OUTPUT ${GIT_COMMIT_INFO_FILE}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${GET_GIT_COMMIT_SCRIPT}
|
||||
${PROJECT_SOURCE_DIR} ${GIT_COMMIT_INFO_FILE}
|
||||
DEPENDS ${GET_GIT_COMMIT_SCRIPT} GIT_COMMIT_INFO_ALWAYS_REBUILD
|
||||
COMMENT "Collect Git commit info for versioning"
|
||||
)
|
||||
add_custom_target(
|
||||
GIT_COMMIT_INFO_ALWAYS_REBUILD
|
||||
${CMAKE_COMMAND} -E touch ${GET_GIT_COMMIT_SCRIPT}
|
||||
COMMENT "Touch GetCommitInfo.py to trigger rebuild"
|
||||
)
|
||||
set_property(TARGET GIT_COMMIT_INFO_ALWAYS_REBUILD
|
||||
PROPERTY FOLDER "Utils")
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/dxcompilerobj.cpp
|
||||
PROPERTIES OBJECT_DEPENDS "${GIT_COMMIT_INFO_FILE}")
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/dxcvalidator.cpp
|
||||
PROPERTIES OBJECT_DEPENDS "${GIT_COMMIT_INFO_FILE}")
|
||||
endif()
|
||||
|
||||
set_target_properties(dxcompiler
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "dxcompiler"
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
// SPIRV change ends
|
||||
|
||||
#ifdef SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
#include "GitCommitInfo.inc" // Auto generated file containing Git commit info
|
||||
#include "clang/Basic/Version.h"
|
||||
#endif // SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
|
||||
#define CP_UTF16 1200
|
||||
|
@ -961,13 +961,13 @@ public:
|
|||
if (pCommitCount == nullptr || pCommitHash == nullptr)
|
||||
return E_INVALIDARG;
|
||||
|
||||
char *const hash = (char *)CoTaskMemAlloc(ARRAYSIZE(kGitCommitHash) + 1);
|
||||
char *const hash = (char *)CoTaskMemAlloc(8 + 1); // 8 is guaranteed by utils/GetCommitInfo.py
|
||||
if (hash == nullptr)
|
||||
return E_OUTOFMEMORY;
|
||||
std::strcpy(hash, kGitCommitHash);
|
||||
std::strcpy(hash, getGitCommitHash());
|
||||
|
||||
*pCommitHash = hash;
|
||||
*pCommitCount = kGitCommitCount;
|
||||
*pCommitCount = getGitCommitCount();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
#include "GitCommitInfo.inc" // Auto generated file containing Git commit info
|
||||
#include "clang/Basic/Version.h"
|
||||
#endif // SUPPORT_QUERY_GIT_COMMIT_INFO
|
||||
|
||||
using namespace llvm;
|
||||
|
@ -177,13 +177,13 @@ HRESULT STDMETHODCALLTYPE DxcValidator::GetCommitInfo(
|
|||
if (pCommitCount == nullptr || pCommitHash == nullptr)
|
||||
return E_INVALIDARG;
|
||||
|
||||
char *const hash = (char *)CoTaskMemAlloc(ARRAYSIZE(kGitCommitHash) + 1);
|
||||
char *const hash = (char *)CoTaskMemAlloc(8 + 1); // 8 is guaranteed by utils/GetCommitInfo.py
|
||||
if (hash == nullptr)
|
||||
return E_OUTOFMEMORY;
|
||||
std::strcpy(hash, kGitCommitHash);
|
||||
std::strcpy(hash, clang::getGitCommitHash());
|
||||
|
||||
*pCommitHash = hash;
|
||||
*pCommitCount = kGitCommitCount;
|
||||
*pCommitCount = clang::getGitCommitCount();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import subprocess
|
|||
|
||||
def git_get_commit_hash():
|
||||
return subprocess.check_output(
|
||||
['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
|
||||
['git', 'rev-parse', '--short=8', 'HEAD']).decode('ascii').strip()
|
||||
|
||||
|
||||
def git_get_commit_count():
|
||||
|
|
Загрузка…
Ссылка в новой задаче