Skip to content

Commit

Permalink
Detect RTL_AIRBAND_VERION when building from a release archive (#456)
Browse files Browse the repository at this point in the history
* add script to get version string either from git or parent dir name
  • Loading branch information
charlie-foxtrot authored Jan 25, 2024
1 parent 68e7783 commit e007afe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 3.1)
project (RTLSDR-Airband CXX)

execute_process(COMMAND git describe --tags --abbrev --dirty --always
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/find_version
OUTPUT_VARIABLE RTL_AIRBAND_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE RTL_AIRBAND_VERSION_ERROR
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ WORKDIR /rtl_airband_build
# WARNING: not copying in the whole repo, this may need to be updated if build files are added outside of src/
COPY ./.git/ .git/
COPY ./src/ src/
COPY ./scripts/ scripts/
COPY ./CMakeLists.txt .

# configure and build
Expand Down
21 changes: 21 additions & 0 deletions scripts/find_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

PROJECT_ROOT_PATH="$(cd $(dirname "$0")/../ ; pwd)"
PROJECT_GIT_DIR_PATH="${PROJECT_ROOT_PATH}/.git"
PROJECT_DIR_NAME="$(basename ${PROJECT_ROOT_PATH})"

# if there is a .git directory at the project root then rely on git for the version string
if [ -d "${PROJECT_GIT_DIR_PATH}" ] ; then
git describe --tags --abbrev --dirty --always
exit 0
fi

# if the proejct root directory matches the naming convetion of an extracted archive then
# get the version number out of that
if [[ "${PROJECT_DIR_NAME}" =~ ^RTLSDR-Airband-[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
echo ${PROJECT_DIR_NAME} | cut -d '-' -f 3
exit 0
fi

# print an error string to stderr (any output to stdout is considered success)
>&2 echo "did not find a git root directory at ${PROJECT_GIT_DIR_PATH} and failed to extract a version from ${PROJECT_DIR_NAME}"

0 comments on commit e007afe

Please sign in to comment.