forked from mockingbirdnest/Principia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_version_translation_unit.sh
executable file
·37 lines (32 loc) · 1.14 KB
/
generate_version_translation_unit.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
34
35
36
37
#!/bin/bash
TEMPORARY_FILE="/tmp/${RANDOM}"
VERSION_TEMPLATE="\xef\xbb\xbf
#include \"base/version.hpp\"
namespace principia {
namespace base {
namespace _version {
namespace internal {
char const BuildDate[] = \"%%DATE%%\";
char const Version[] =
u8\"%%VERSION%%\";
} // namespace internal
} // namespace _version
} // namespace base
} // namespace principia"
PLATFORM=$(uname -s)
if [ "$PLATFORM" == "Darwin" ]; then
echo -e "$VERSION_TEMPLATE" |
sed "s/%%DATE%%/`date -j -u -f \"%Y-%m-%d %H:%M:%S %z\" -u +%Y-%m-%dT%H:%M:%SZ \"$(git log -1 --format=%cd --date=iso)\"`/" |
sed "s/%%VERSION%%/`git describe --tags --always --dirty --abbrev=40 --long`/" > $TEMPORARY_FILE
else
echo -e "$VERSION_TEMPLATE" |
sed "s/%%DATE%%/`date -d $(git log -1 --format=%cd --date=iso-strict) -u +%Y-%m-%dT%H:%M:%SZ`/" |
sed "s/%%VERSION%%/`git describe --tags --always --dirty --abbrev=40 --long`/" > $TEMPORARY_FILE
fi
if cmp -s base/version.generated.cc $TEMPORARY_FILE
then
echo "No change to git describe, leaving base/version.generated.cc untouched"
else
echo "Updating base/version.generated.cc"
mv $TEMPORARY_FILE base/version.generated.cc
fi