OpenHantek
Loading...
Searching...
No Matches
OH_VERSION.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3// set OH_VERSION to define a release
4// if defined in this file it will tag the commit automatically
5// via .git/hooks/post-commit (see below)
6// the hook will then renamed from OH_VERSION to LAST_OH_VERSION
7//
8
9
10// next line shall define either OH_VERSION or LAST_OH_VERSION
11//
12#define LAST_OH_VERSION "3.3.3"
13
14
15// do not edit below
16
17// VERSION (git describe --tags --dirty) will be shown by OpenHantek
18// if VERSION is not defined then use OH_VERSION
19// if this is also not defined fall back to build date
20
21#ifndef VERSION
22#ifdef OH_VERSION
23#define VERSION OH_VERSION
24#else
25#define VERSION __DATE__
26#endif
27#endif
28
29/* content of ".git/hooks/post-commit":
30
31#!/bin/bash
32
33# this file is called automatically after a commit
34# it tags the commit if a version is defined in the version file
35# inspired by: https://coderwall.com/p/mk18zq/automatic-git-version-tagging-for-npm-modules
36
37# this file was updated during development (by script build/MK_NEW_VER)
38#
39OPENHANTEK="$(git rev-parse --show-toplevel)"
40OH_VERSION_H="$OPENHANTEK/openhantek/src/OH_VERSION.h"
41
42# check if the last commit changed the entry OH_VERSION in file ...OH_VERSION.h and extract the new version
43#
44OH_VERSION=$(git diff HEAD^..HEAD -- ${OH_VERSION_H} | awk '/^\+#define OH_VERSION/ { print $3 }' | tr -d '"')
45
46# if commit was marked as OH_VERSION then tag it accordingly and change entry to LAST_OH_VERSION
47#
48if [ "$OH_VERSION" != "" ]; then
49 git tag -a $OH_VERSION -m "$(git log -1 --format=%s)"
50 sed -i 's|^#define[[:blank:]]*OH_VERSION|#define LAST_OH_VERSION|g' $OH_VERSION_H
51 echo "Created a new tag: $OH_VERSION"
52fi
53
54# update the build system with next build
55touch $OPENHANTEK/CMakeLists.txt
56
57*/