Skip to content

Commit 97849b8

Browse files
committed
build/version.sh: Move version calculation here
1 parent f6940f3 commit 97849b8

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ ${OBJS}: gen/config.mk
6868
# Save the version number to this file, but only update version.c if it changes
6969
gen/version.i.new::
7070
@${MKDIR} ${@D}
71-
@if [ "$$VERSION" ]; then \
72-
printf '%s' "$$VERSION"; \
73-
elif test -e src/../.git && command -v git >/dev/null 2>&1; then \
74-
git -C src/.. describe --always --dirty; \
75-
else \
76-
echo "4.0.1"; \
77-
fi | tr -d '\n' | build/embed.sh >$@
71+
@build/version.sh | tr -d '\n' | build/embed.sh >$@
7872

7973
gen/version.i: gen/version.i.new
8074
@test -e $@ && cmp -s $@ ${.ALLSRC} && ${RM} ${.ALLSRC} || mv ${.ALLSRC} $@

build/version.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
# Copyright © Tavian Barnes <tavianator@tavianator.com>
4+
# SPDX-License-Identifier: 0BSD
5+
6+
# Print the version number
7+
8+
set -eu
9+
10+
DIR="$(dirname -- "$0")/.."
11+
12+
if [ "${VERSION-}" ]; then
13+
printf '%s' "$VERSION"
14+
elif [ -e "$DIR/.git" ] && command -v git >/dev/null 2>&1; then
15+
git -C "$DIR" describe --always --dirty
16+
else
17+
echo "4.0.1"
18+
fi

0 commit comments

Comments
 (0)