Skip to content

Commit e007afe

Browse files
Detect RTL_AIRBAND_VERION when building from a release archive (#456)
* add script to get version string either from git or parent dir name
1 parent 68e7783 commit e007afe

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required (VERSION 3.1)
22
project (RTLSDR-Airband CXX)
33

4-
execute_process(COMMAND git describe --tags --abbrev --dirty --always
4+
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/find_version
55
OUTPUT_VARIABLE RTL_AIRBAND_VERSION
66
OUTPUT_STRIP_TRAILING_WHITESPACE
77
ERROR_VARIABLE RTL_AIRBAND_VERSION_ERROR

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ WORKDIR /rtl_airband_build
4545
# WARNING: not copying in the whole repo, this may need to be updated if build files are added outside of src/
4646
COPY ./.git/ .git/
4747
COPY ./src/ src/
48+
COPY ./scripts/ scripts/
4849
COPY ./CMakeLists.txt .
4950

5051
# configure and build

scripts/find_version

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
PROJECT_ROOT_PATH="$(cd $(dirname "$0")/../ ; pwd)"
4+
PROJECT_GIT_DIR_PATH="${PROJECT_ROOT_PATH}/.git"
5+
PROJECT_DIR_NAME="$(basename ${PROJECT_ROOT_PATH})"
6+
7+
# if there is a .git directory at the project root then rely on git for the version string
8+
if [ -d "${PROJECT_GIT_DIR_PATH}" ] ; then
9+
git describe --tags --abbrev --dirty --always
10+
exit 0
11+
fi
12+
13+
# if the proejct root directory matches the naming convetion of an extracted archive then
14+
# get the version number out of that
15+
if [[ "${PROJECT_DIR_NAME}" =~ ^RTLSDR-Airband-[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
16+
echo ${PROJECT_DIR_NAME} | cut -d '-' -f 3
17+
exit 0
18+
fi
19+
20+
# print an error string to stderr (any output to stdout is considered success)
21+
>&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 commit comments

Comments
 (0)