Skip to content

Commit

Permalink
Merge branch 'marco-ippolito-feat/include-version-header'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeb01 committed Apr 27, 2023
2 parents da51af3 + a478212 commit d80e30a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ test/perftest
debug
cmake-build-debug
/build-afl
.vscode
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
cmake_minimum_required(VERSION 3.12)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
endif()

file(STRINGS "include/hdr/hdr_histogram_version.h" HDR_VERSION_HEADER)
string(REGEX MATCH ".*#define HDR_HISTOGRAM_VERSION \"(.*)\".*" HDR_BLACK_HOLE ${HDR_VERSION_HEADER})

project(hdr_histogram
VERSION 0.11.6
VERSION ${CMAKE_MATCH_1}
LANGUAGES C
DESCRIPTION "C port of the HdrHistogram"
HOMEPAGE_URL "http://hdrhistogram.github.io/HdrHistogram/")
Expand All @@ -21,7 +28,7 @@ include(CMakePackageConfigHelpers)

set(HDR_SOVERSION_CURRENT 6)
set(HDR_SOVERSION_AGE 1)
set(HDR_SOVERSION_REVISION 2)
set(HDR_SOVERSION_REVISION 3)

set(HDR_VERSION ${HDR_SOVERSION_CURRENT}.${HDR_SOVERSION_AGE}.${HDR_SOVERSION_REVISION})
set(HDR_SOVERSION ${HDR_SOVERSION_CURRENT})
Expand Down
5 changes: 4 additions & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
configure_file(hdr/hdr_histogram_version.h hdr/hdr_histogram_version.h @ONLY)

set(HDR_HISTOGRAM_PUBLIC_HEADERS
hdr/hdr_histogram.h
hdr/hdr_histogram_log.h
hdr/hdr_interval_recorder.h
hdr/hdr_thread.h
hdr/hdr_time.h
hdr/hdr_writer_reader_phaser.h)
hdr/hdr_writer_reader_phaser.h
hdr/hdr_histogram_version.h)

install(
FILES ${HDR_HISTOGRAM_PUBLIC_HEADERS}
Expand Down
11 changes: 11 additions & 0 deletions include/hdr/hdr_histogram_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @file hdr_histogram_version.h
* @brief Definitions for HdrHistogram's version number.
*/

#ifndef HDR_HISTOGRAM_VERSION_H
#define HDR_HISTOGRAM_VERSION_H

#define HDR_HISTOGRAM_VERSION "0.11.7"

#endif // HDR_HISTOGRAM_VERSION_H
30 changes: 30 additions & 0 deletions tools/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
set -e
# Shell script to update HDR_HISTOGRAM_VERSION_H to a specific version

BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
HDR_DIR="$BASE_DIR/include/hdr"
HDR_HISTOGRAM_VERSION_H=$HDR_DIR/hdr_histogram_version.h
NEW_VERSION=$1

if [ "$#" -le 0 ]; then
echo "Error: please provide a version to update to"
exit 1
fi

CURRENT_VERSION=$(grep "#define HDR_HISTOGRAM_VERSION_H" $HDR_HISTOGRAM_VERSION_H | sed -n "s/^.*VERSION_H \"\(.*\)\"/\1/p")

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because is already on the latest version."
exit 0
fi

echo "Replacing $CURRENT_VERSION with new version $NEW_VERSION"

sed -i '' -e "s/#define HDR_HISTOGRAM_VERSION_H \"$CURRENT_VERSION\"/#define HDR_HISTOGRAM_VERSION_H \"$NEW_VERSION\"/g" $HDR_HISTOGRAM_VERSION_H

echo "All done!"

echo "NEW_VERSION=$NEW_VERSION"

0 comments on commit d80e30a

Please sign in to comment.