-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: trying to parse version info from header
- Loading branch information
Showing
3 changed files
with
93 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ build-backend = "scikit_build_core.build" | |
[project] | ||
name = "liquid-dsp" | ||
description = "software-defined radio digital signal processing library" | ||
version = "1.6.0" | ||
#dynamic = ["version"] | ||
#version = "1.6.0" | ||
dynamic = ["version"] # set automatically from cmake | ||
requires-python = ">= 3.7" | ||
authors = [{name = "Joseph D. Gaeddert", email = "[email protected]"}] | ||
dependencies = [] | ||
|
@@ -32,8 +32,28 @@ Repository = "https://github.com/jgaeddert/liquid-dsp" | |
Issues = "https://github.com/jgaeddert/liquid-dsp/issues" | ||
Changelog = "https://github.com/jgaeddert/liquid-dsp/blob/master/CHANGELOG.md" | ||
|
||
[tool.scikit-build] | ||
cmake.verbose = true | ||
logging.level = "INFO" | ||
#metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" | ||
#sdist.include = ["_version.py"] | ||
|
||
|
||
[tool.scikit-build.metadata.version] | ||
provider = "scikit_build_core.metadata.regex" | ||
input = "include/liquid.h" | ||
regex = '''(?sx) | ||
\#define \s+ LIQUID_VERSION_MAJOR \s+ (?P<major>\d+) .*? | ||
\#define \s+ LIQUID_VERSION_MINOR \s+ (?P<minor>\d+) .*? | ||
\#define \s+ LIQUID_VERSION_PATCH \s+ (?P<patch>\d+) .*? | ||
\#define \s+ LIQUID_VERSION_DEV \s+ (?P<dev>\d+) .*? | ||
''' | ||
result = "{major}.{minor}.{patch}dev{dev}" | ||
remove = "dev0" | ||
|
||
#[tool.setuptools_scm] # Section required | ||
#write_to = "_version.py" | ||
|
||
#[project.scripts] | ||
#liquid = "liquid:main_cli" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/sh | ||
|
||
# This script parses the global header and extracts the major.minor.patch version for | ||
# liquid-dsp and prints to the screen. This is a simplified version of: | ||
# https://github.com/tinyalsa/tinyalsa/blob/master/scripts/version.sh | ||
|
||
INCLUDE_FILE="include/liquid.h" | ||
|
||
# exit program with error | ||
die() | ||
{ | ||
echo "error: $@" 1>&2 | ||
exit 1 | ||
} | ||
|
||
# check that file exists | ||
check_files() | ||
{ | ||
[ -f ${INCLUDE_FILE} ] || die "No ${INCLUDE_FILE} found!"; | ||
} | ||
|
||
# get a part of the version from the header, e.g. LIQUID_VERSION_MAJOR | ||
get_version_part() | ||
{ | ||
set -- "$1" "$(grep -m 1 "^#define\([ \t]*\)$1" ${INCLUDE_FILE} | sed 's/[^0-9]*//g')" | ||
|
||
if [ -z "$2" ]; then | ||
die "Could not get $1 from ${INCLUDE_FILE}" | ||
fi | ||
|
||
echo "$2" | ||
} | ||
|
||
# gets the complete version from the include file | ||
get_version() | ||
{ | ||
VERSION_MAJOR=$(get_version_part "LIQUID_VERSION_MAJOR") | ||
VERSION_MINOR=$(get_version_part "LIQUID_VERSION_MINOR") | ||
VERSION_PATCH=$(get_version_part "LIQUID_VERSION_PATCH") | ||
} | ||
|
||
print_version() | ||
{ | ||
printf "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${LF}" | ||
return 0 | ||
} | ||
|
||
check_files | ||
get_version | ||
print_version "$2" | ||
exit $? | ||
|
||
# The script should never reach this place. | ||
die "Internal error. Please report this." | ||
|