mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
Use script to calculate the build version
This commit is contained in:
parent
d57ac3c6a1
commit
aafca3813a
|
@ -6,39 +6,18 @@ SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
# N2n release information
|
# N2n release information
|
||||||
|
set(N2N_OSNAME ${CMAKE_SYSTEM_NAME})
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND cat VERSION
|
COMMAND scripts/version.sh
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE PACKAGE_VERSION
|
OUTPUT_VARIABLE PACKAGE_VERSION
|
||||||
)
|
)
|
||||||
string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION)
|
string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION)
|
||||||
set(N2N_OSNAME ${CMAKE_SYSTEM_NAME})
|
MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}")
|
||||||
execute_process(
|
|
||||||
COMMAND git status
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE GIT_OUTPUT
|
|
||||||
RESULT_VARIABLE GIT_ERROR_CODE
|
|
||||||
)
|
|
||||||
if (GIT_ERROR_CODE EQUAL 0)
|
|
||||||
execute_process(
|
|
||||||
COMMAND git rev-list --count HEAD
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE GIT_REV
|
|
||||||
)
|
|
||||||
execute_process(
|
|
||||||
COMMAND git rev-parse --short HEAD
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE GIT_ID
|
|
||||||
)
|
|
||||||
string(REGEX REPLACE "\n$" "" GIT_REV "${GIT_REV}")
|
|
||||||
string(REGEX REPLACE "\n$" "" GIT_ID "${GIT_ID}")
|
|
||||||
set(N2N_VERSION "${N2N_VERSION}.r${GIT_REV}.${GIT_ID}")
|
|
||||||
MESSAGE(STATUS "Build from git rev: ${N2N_VERSION}")
|
|
||||||
endif (GIT_ERROR_CODE EQUAL 0)
|
|
||||||
|
|
||||||
add_definitions(-DCMAKE_BUILD)
|
add_definitions(-DCMAKE_BUILD)
|
||||||
add_definitions(-DPACKAGE_OSNAME="${N2N_OSNAME}")
|
add_definitions(-DPACKAGE_OSNAME="${N2N_OSNAME}" -DN2N_OSNAME="${N2N_OSNAME}")
|
||||||
add_definitions(-DPACKAGE_VERSION="${PACKAGE_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}")
|
add_definitions(-DPACKAGE_VERSION="${PACKAGE_VERSION}")
|
||||||
|
|
||||||
|
|
||||||
# Build information
|
# Build information
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
odnl> Do not add anything above
|
odnl> Do not add anything above
|
||||||
AC_INIT([edge], m4_esyscmd([cat VERSION | tr -d '\n']))
|
AC_INIT([edge], m4_esyscmd([scripts/version.sh | tr -d '\n']))
|
||||||
dnl> Do not add anything above
|
dnl> Do not add anything above
|
||||||
|
|
||||||
N2N_VERSION_SHORT=${PACKAGE_VERSION}
|
N2N_VERSION_SHORT=$(scripts/version.sh short)
|
||||||
|
|
||||||
if test -d ".git"; then
|
if test -d ".git"; then
|
||||||
# NOTE: keep in sync with the definitions for configure.in files under the packages folder
|
# NOTE: keep in sync with the definitions for configure.in files under the packages folder
|
||||||
|
|
|
@ -59,3 +59,11 @@ This shell script is used to run automated tests during development.
|
||||||
|
|
||||||
A sample script to route all the host traffic towards a remote gateway,
|
A sample script to route all the host traffic towards a remote gateway,
|
||||||
which is reachable via the n2n virtual interface.
|
which is reachable via the n2n virtual interface.
|
||||||
|
|
||||||
|
### `version.sh`
|
||||||
|
|
||||||
|
This script is used to determine the current version number during the
|
||||||
|
build process.
|
||||||
|
|
||||||
|
It looks at both the VERSION file and the GIT tags and outputs the
|
||||||
|
version number to use.
|
||||||
|
|
42
scripts/version.sh
Executable file
42
scripts/version.sh
Executable file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Output the current version number
|
||||||
|
#
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [short]"
|
||||||
|
echo
|
||||||
|
echo "Determine the correct version number for the current build"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: search for the top dir that contains the VERSION file?
|
||||||
|
VER_FILE_SHORT=$(cat VERSION)
|
||||||
|
|
||||||
|
if git status >/dev/null; then
|
||||||
|
VER_GIT_SHORT=$(git describe --abbrev=0)
|
||||||
|
VER_GIT=$(git describe --abbrev=7 --dirty)
|
||||||
|
|
||||||
|
if [ "$VER_FILE_SHORT" != "$VER_GIT_SHORT" ]; then
|
||||||
|
echo "Error: VERSION file does not match tag version ($VER_FILE_SHORT != $VER_GIT_SHORT)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VER_SHORT="$VER_GIT_SHORT"
|
||||||
|
VER="$VER_GIT"
|
||||||
|
else
|
||||||
|
VER_SHORT="$VER_FILE_SHORT"
|
||||||
|
VER="$VER_FILE_SHORT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
short)
|
||||||
|
echo "$VER_SHORT"
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
echo "$VER"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue
Block a user