mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-06-29 11:16:59 +00:00
[rocm-libraries] ROCm/rocm-libraries#6900 (commit 28608c2)
[CK] Fix and expand CK's commit records in version.h ## Motivation In `version.h` of a CK installation `CK_COMMIT_ID` would be empty for out-of-source builds. Additionally, if it worked, it would show the parent repo's (`rocm-libraries`) commit. ## Technical Details Dropped "required" constraint so "unknown" string becomes a graceful option. Changed process of determining the CK commit, now uses `WORKING_DIRECTORY`. Thus, `CK_COMMIT_ID` holds only the last CK-relevant commit. Added `CK_PARENT_COMMIT_ID` which holds the parent's, e.g. `rocm-libraries`, commit. This can be the same as `CK_COMMIT_ID`, or not even applicable, depending on the scenario. ## Test Plan Ran CMake configuration and installation of CK to verify happy path. ## Test Result Commit SHA's showed the expected values depending on the repo state. ## Submission Checklist - [ x ] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
This commit is contained in:
committed by
assistant-librarian[bot]
parent
4bc276a722
commit
a56c8d6017
@@ -172,8 +172,48 @@ endif()
|
||||
include(getopt)
|
||||
|
||||
# CK version file to record release version as well as git commit hash
|
||||
find_package(Git REQUIRED)
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD OUTPUT_VARIABLE COMMIT_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# identifying the CK source tree.
|
||||
#
|
||||
# NOTE: execute_process() runs in the build directory by default, so we must
|
||||
# pin WORKING_DIRECTORY to the source tree -- otherwise out-of-source builds
|
||||
# (where the build dir is not inside a git checkout) would silently produce
|
||||
# an empty CK_COMMIT_ID. We use `git log -1 -- .` (the last commit touching
|
||||
# CK's sources) rather than `git rev-parse HEAD` so unrelated changes
|
||||
# elsewhere in a containing monorepo (e.g. rocm-libraries) do not bump the
|
||||
# CK identity. RESULT_VARIABLE/ERROR_QUIET also let us degrade gracefully
|
||||
# when building from a release tarball without a .git directory.
|
||||
find_package(Git)
|
||||
set(COMMIT_ID "unknown")
|
||||
set(CK_PARENT_COMMIT_ID "unknown")
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%H -- .
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE GIT_COMMIT_ID
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE GIT_LOG_RESULT
|
||||
ERROR_QUIET
|
||||
)
|
||||
if(GIT_LOG_RESULT EQUAL 0 AND GIT_COMMIT_ID)
|
||||
set(COMMIT_ID "${GIT_COMMIT_ID}")
|
||||
endif()
|
||||
|
||||
# Containing-repo HEAD. Captures the surrounding repository's exact
|
||||
# snapshot, including shared infrastructure that lives outside CK
|
||||
# (e.g. rocm-libraries top-level CMake/codegen helpers). When CK is
|
||||
# built standalone, this is just CK's own HEAD.
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE GIT_REPO_HEAD
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE GIT_REV_PARSE_RESULT
|
||||
ERROR_QUIET
|
||||
)
|
||||
if(GIT_REV_PARSE_RESULT EQUAL 0 AND GIT_REPO_HEAD)
|
||||
set(CK_PARENT_COMMIT_ID "${GIT_REPO_HEAD}")
|
||||
endif()
|
||||
endif()
|
||||
configure_file(include/ck/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/ck/version.h)
|
||||
|
||||
set(ROCM_SYMLINK_LIBS OFF)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#define CK_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@
|
||||
#define CK_VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@
|
||||
#define CK_COMMIT_ID @COMMIT_ID@
|
||||
#define CK_PARENT_COMMIT_ID @CK_PARENT_COMMIT_ID@
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user