build-info : cleanup

This commit is contained in:
Cebtenzzre 2023-09-03 13:55:20 -04:00
parent b1593bc17c
commit 98a6004aa1

View file

@ -1,23 +1,21 @@
#!/bin/sh #!/bin/sh
BUILD_NUMBER="0" build_number="0"
BUILD_COMMIT="unknown" build_commit="unknown"
# git is broken on WSL so we need to strip extra newlines # git is broken on WSL so we need to strip extra newlines
REV_LIST=$(git rev-list --count HEAD | tr -d '\n') if out=$(git rev-list --count HEAD | tr -d '\n'); then
if [ $? -eq 0 ]; then build_number=$out
BUILD_NUMBER=$REV_LIST
fi fi
REV_PARSE=$(git rev-parse --short HEAD | tr -d '\n') if out=$(git rev-parse --short HEAD | tr -d '\n'); then
if [ $? -eq 0 ]; then build_commit=$out
BUILD_COMMIT=$REV_PARSE
fi fi
echo "#ifndef BUILD_INFO_H" echo "#ifndef BUILD_INFO_H"
echo "#define BUILD_INFO_H" echo "#define BUILD_INFO_H"
echo echo
echo "#define BUILD_NUMBER $BUILD_NUMBER" echo "#define BUILD_NUMBER $build_number"
echo "#define BUILD_COMMIT \"$BUILD_COMMIT\"" echo "#define BUILD_COMMIT \"$build_commit\""
echo echo
echo "#endif // BUILD_INFO_H" echo "#endif // BUILD_INFO_H"