-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathversion.sh
executable file
·33 lines (29 loc) · 1020 Bytes
/
version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# abort on errors
set -e
set -u
# All paths are relative to this script
cd $(dirname $0)
echo "// AUTOMATICALLY GENERATED" > src/version.c.new
echo "#include <board.h>" >> src/version.c.new
echo "const char * software_version_str = \"$(git rev-parse HEAD)-$(git rev-parse --abbrev-ref HEAD)\";" >> src/version.c.new
echo "const char * hardware_version_str = BOARD_NAME;" >> src/version.c.new
# If version.c does not exist, overwrite it
if [ ! -e src/version.c ]
then
echo "version.c does not exist, creating it..."
mv src/version.c.new src/version.c
else
# If there is a version.c, check if the file should change before
# overriding it.
# If we don't do this, make will detect a new file and always relink the
# project.
if cmp --quiet src/version.c src/version.c.new
then
echo "No change detected in version.c, skipping..."
rm src/version.c.new
else
echo "version.c changed, overwriting it"
mv src/version.c.new src/version.c
fi
fi