Skip to content

Commit c2c258e

Browse files
giladreichSiegeLord
authored andcommitted
Update fixver.sh script to rely on base.h version.
Note that this script was relying on the project version set in the CMakeLists.txt and then update the base.h file. This is not great, because if one updates manually (which ideally shouldn't be the case), then they may also forget to update the CMakeLists.txt. Normally cmake should not modify version-controlled sources and be independent from the rest of the project to keep cmake decoupled from the actual project structure considering some projects may use multiple build or meta-build systems. Therefore it makes sense that cmake will instead retrieve the project version during config-time from the base.h file. Will be done next.
1 parent a74c09a commit c2c258e

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

misc/fixver.sh

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
# digits will remain unchanged and the comment will be set to the date.
77
# This is in particular useful for making SVN snapshots.
88

9+
BASE_H_FILE="include/allegro5/base.h"
910

10-
if [ $# -eq 1 -a $1 == "datestamp" ]; then
11-
# Uses GNU grep -o.
12-
ver=$( grep -o "ALLEGRO_VERSION [0-9.]*" CMakeLists.txt | cut -d' ' -f2 )
13-
major_num=$( echo $ver | cut -d. -f1 )
14-
sub_num=$( echo $ver | cut -d. -f2 )
15-
wip_num=$( echo $ver | cut -d. -f3 )
16-
$0 $major_num $sub_num $wip_num `date '+%Y%m%d'`
17-
exit 0
11+
if [ $# -eq 1 ] && [ "$1" = "datestamp" ]; then
12+
major_num=$( awk '/^#define\s+ALLEGRO_VERSION\s+[0-9]+$/ { print $NF }' $BASE_H_FILE )
13+
sub_num=$( awk '/^#define\s+ALLEGRO_SUB_VERSION\s+[0-9]+$/ { print $NF }' $BASE_H_FILE )
14+
wip_num=$( awk '/^#define\s+ALLEGRO_WIP_VERSION\s+[0-9]+$/ { print $NF }' $BASE_H_FILE )
15+
datestamp=`date '+%Y%m%d'`
16+
echo "Re-invoking script with args: [$major_num $sub_num $wip_num $datestamp]"
17+
$0 $major_num $sub_num $wip_num $datestamp
18+
exit $?
1819
fi
1920

2021
case $# in
@@ -81,14 +82,9 @@ echo "s/\#define ALLEGRO_VERSION_STR .*/\#define ALLEGRO_VERSION_STR \"$ver
8182
echo "s/\#define ALLEGRO_DATE_STR .*/\#define ALLEGRO_DATE_STR \"$year\"/" >> fixver.sed
8283
echo "s/\#define ALLEGRO_DATE .*/\#define ALLEGRO_DATE $year$month$day \/\* yyyymmdd \*\//" >> fixver.sed
8384

84-
echo "Patching include/allegro5/base.h..."
85-
cp include/allegro5/base.h fixver.tmp
86-
sed -f fixver.sed fixver.tmp > include/allegro5/base.h
87-
88-
# patch CMakeLists.txt
89-
echo "Patching CMakeLists.txt..."
90-
cp CMakeLists.txt fixver.tmp
91-
sed -e "s/set(ALLEGRO_VERSION [^)]*)/set(ALLEGRO_VERSION $1.$2.$3)/" fixver.tmp > CMakeLists.txt
85+
echo "Patching ${BASE_H_FILE}..."
86+
cp $BASE_H_FILE fixver.tmp
87+
sed -f fixver.sed fixver.tmp > $BASE_H_FILE
9288

9389
# clean up after ourselves
9490
rm fixver.sed fixver.tmp

0 commit comments

Comments
 (0)