build: use meson for version info

This commit is contained in:
Jan Vaclav
2024-09-02 12:51:59 +02:00
parent 8d672a46d5
commit 6707ce0754
3 changed files with 5 additions and 19 deletions

View File

@@ -76,14 +76,7 @@ abs_path() {
}
get_version() {
local major minor micro
local F="${1:-"$GITDIR/configure.ac"}"
vars="$(sed -n 's/^m4_define(\[nm_\(major\|minor\|micro\)_version\], *\[\([0-9]\+\)\]) *$/local \1='\''\2'\''/p' "$F" 2>/dev/null)"
eval "$vars"
[[ -n "$major" && -n "$minor" && "$micro" ]] || return 1
echo "$major.$minor.$micro"
grep -E -m1 '^\s+version:' "$GITDIR/meson.build" | cut -d"'" -f2
}
write_changelog() {

View File

@@ -44,14 +44,7 @@ usage() {
}
get_version() {
local major minor micro
local F="./configure.ac"
vars="$(sed -n 's/^m4_define(\[nm_\(major\|minor\|micro\)_version\], *\[\([0-9]\+\)\]) *$/local \1='\''\2'\''/p' "$F" 2>/dev/null)"
eval "$vars"
[[ -n "$major" && -n "$minor" && "$micro" ]] || return 1
echo "$major.$minor.$micro"
grep -E -m1 '^\s+version:' meson.build | cut -d"'" -f2
}
bool() {

View File

@@ -94,9 +94,9 @@ do_command() {
}
parse_version() {
local MAJ="$(sed -n '1,20 s/^m4_define(\[nm_major_version\], \[\([0-9]\+\)\])$/\1/p' ./configure.ac)"
local MIN="$(sed -n '1,20 s/^m4_define(\[nm_minor_version\], \[\([0-9]\+\)\])$/\1/p' ./configure.ac)"
local MIC="$(sed -n '1,20 s/^m4_define(\[nm_micro_version\], \[\([0-9]\+\)\])$/\1/p' ./configure.ac)"
local VERSION=$(grep -E -m1 '^\s+version:' "$GITDIR/meson.build" \
| cut -d"'" -f2 \
| sed 's/\./ /g')
re='^(0|[1-9][0-9]*) (0|[1-9][0-9]*) (0|[1-9][0-9]*)$'
[[ "$MAJ $MIN $MIC" =~ $re ]] || return 1