Initial commit
This commit is contained in:
53
sys/version.sh
Executable file
53
sys/version.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Скрипт генерирует версию сборки в файл version.h
|
||||
|
||||
OUTFILE=libs/Version.h
|
||||
|
||||
# rm $OUTFILE > /dev/null 2>&1
|
||||
|
||||
# echo -e "\033[0;32m~~~ Version generation ~~~\033[0m";
|
||||
printf "version: "
|
||||
|
||||
if ! git --version > /dev/null 2>&1; then
|
||||
printf "\n\033[0;31mGIT is not found!\033[0m\n"; exit 1;
|
||||
fi
|
||||
|
||||
if ! git status > /dev/null 2>&1; then
|
||||
printf "\n\033[0;31mThis is not a git repo!\033[0m\n"; exit 1;
|
||||
fi
|
||||
|
||||
version=$(git describe --tags --always --dirty --abbrev=8 || echo unknown);
|
||||
# Remove tag prefix from version
|
||||
# Версия git в последнем поле после '_'
|
||||
if echo "$version" | grep -q "_"; then
|
||||
printf "%s => " "$version"
|
||||
version=$(echo "$version" | awk -F '_' '{print $NF}')
|
||||
fi
|
||||
version=$(echo "$version" | sed "s/-g/-/") # Remove 'g' from git hash
|
||||
echo "$version"
|
||||
|
||||
git_build="0x$(git rev-parse --short=8 HEAD | tr 'a-f' 'A-F')"
|
||||
date="$(date +0x00%y%m%d)"
|
||||
|
||||
# Пишем в файл.
|
||||
cat << --- > $OUTFILE
|
||||
#ifndef __VERSION_H_
|
||||
#define __VERSION_H_
|
||||
|
||||
// Данный файл обновляется автоматически из скрипта version.sh
|
||||
|
||||
// Хеш коммита в репозитории GIT.
|
||||
#define GIT_BUILD $git_build
|
||||
|
||||
// Дата компиляции, YYMMDD, всё в bcd.
|
||||
#define BUILD_DATE $date
|
||||
|
||||
// Версия CAN-прошивки.
|
||||
#define CAN_FW_VERSION 1
|
||||
|
||||
// Версия из GIT.
|
||||
#define GIT_VERSION "$version"
|
||||
|
||||
#endif /* __VERSION_H_ */
|
||||
---
|
||||
Reference in New Issue
Block a user