You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/07/18 00:31:58 UTC

[4/4] mesos git commit: CMake: Defined GIT_SHA, GIT_BRANCH, and GIT_TAG variables.

CMake: Defined GIT_SHA, GIT_BRANCH, and GIT_TAG variables.

This emits some extra build information into a generated header
file (much like BUILD_DATE, BUILD_TIME, and BUILD_USER).
This only has an effect when building from a git clone and results
in some extra fields showing up in the Master/Agent state results.

Review: https://reviews.apache.org/r/60482/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0df6892e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0df6892e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0df6892e

Branch: refs/heads/master
Commit: 0df6892e0792e94c6624b5a86f99260b2a59a43a
Parents: 3c26428
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Mon Jul 17 10:07:35 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 17 17:18:12 2017 -0700

----------------------------------------------------------------------
 cmake/CompilationConfigure.cmake | 26 ++++++++++++++++++++++++++
 src/common/build_config.hpp.in   |  4 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0df6892e/cmake/CompilationConfigure.cmake
----------------------------------------------------------------------
diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake
index 437300f..6fedcd2 100644
--- a/cmake/CompilationConfigure.cmake
+++ b/cmake/CompilationConfigure.cmake
@@ -344,7 +344,33 @@ else ()
   set(BUILD_USER "$ENV{USER}")
 endif ()
 
+# When building from source, from a git clone, emit some extra build info.
+if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
+  execute_process(
+    COMMAND git rev-parse HEAD
+    OUTPUT_VARIABLE BUILD_GIT_SHA
+    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  execute_process(
+    COMMAND git symbolic-ref HEAD
+    OUTPUT_VARIABLE BUILD_GIT_BRANCH
+    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  execute_process(
+    COMMAND git describe --exact --tags
+    OUTPUT_VARIABLE BUILD_GIT_TAG
+    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif ()
+
 # Emit the BUILD_DATE, BUILD_TIME, and BUILD_USER variables into a file.
+# When building from a git clone, the variables BUILD_GIT_SHA,
+# BUILD_GIT_BRANCH, and BUILD_GIT_TAG will also be emitted.
 # This will be updated each time `cmake` is run.
 configure_file(
   "${CMAKE_SOURCE_DIR}/src/common/build_config.hpp.in"

http://git-wip-us.apache.org/repos/asf/mesos/blob/0df6892e/src/common/build_config.hpp.in
----------------------------------------------------------------------
diff --git a/src/common/build_config.hpp.in b/src/common/build_config.hpp.in
index 174d8aa..ac7059a 100644
--- a/src/common/build_config.hpp.in
+++ b/src/common/build_config.hpp.in
@@ -21,6 +21,8 @@
 #cmakedefine BUILD_TIME "@BUILD_TIME@"
 #cmakedefine BUILD_USER "@BUILD_USER@"
 
-// TODO(andschwa): Define GIT_SHA etc. for parity with autotools.
+#cmakedefine BUILD_GIT_SHA "@BUILD_GIT_SHA@"
+#cmakedefine BUILD_GIT_BRANCH "@BUILD_GIT_BRANCH@"
+#cmakedefine BUILD_GIT_TAG "@BUILD_GIT_TAG@"
 
 #endif // __COMMON_BUILD_CONFIG_HPP__