-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Materialise a header file containing version info
This approach makes the bpftrace build easier to integrate into non-CMake build systems.
- Loading branch information
Showing
8 changed files
with
57 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file generates the file "version.h", containing an up-to-date version | ||
# string on each build. | ||
|
||
# Inputs: | ||
# File names: | ||
# VERSION_H_IN - name of template source file | ||
# VERSION_H - name of populated file to be generated | ||
# Fallback version numbers when not building in a Git repository: | ||
# bpftrace_VERSION_MAJOR | ||
# bpftrace_VERSION_MINOR | ||
# bpftrace_VERSION_PATCH | ||
|
||
# Try and get a version string from Git tags | ||
execute_process( | ||
COMMAND git describe --abbrev=4 --dirty --tags | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE BPFTRACE_VERSION | ||
ERROR_VARIABLE GIT_DESCRIBE_ERROR | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
RESULT_VARIABLE retcode | ||
) | ||
|
||
# If the build is not done from a git repo, get the version information from | ||
# the version variables in main CMakeLists.txt | ||
if(NOT ${retcode} EQUAL 0) | ||
set(BPFTRACE_VERSION "v${bpftrace_VERSION_MAJOR}.${bpftrace_VERSION_MINOR}.${bpftrace_VERSION_PATCH}") | ||
message(STATUS "Could not obtain version string from Git. Falling back to CMake version string.") | ||
endif() | ||
|
||
configure_file(${VERSION_H_IN} ${VERSION_H} @ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
|
||
#include "build_info.h" | ||
|
||
#include "version.h" | ||
|
||
namespace bpftrace { | ||
|
||
std::string BuildInfo::report() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include <string_view> | ||
|
||
constexpr std::string_view BPFTRACE_VERSION = "@BPFTRACE_VERSION@"; |