2023-01-15 01:52:59 +08:00
|
|
|
#!/usr/bin/env sh
|
2019-08-30 02:58:36 +08:00
|
|
|
|
2021-05-21 06:15:20 +08:00
|
|
|
# Output a version_pm3.c file that includes information about the current build
|
2019-08-30 02:58:36 +08:00
|
|
|
# From mkversion.pl
|
|
|
|
# pure sh POSIX as now even on Windows we use WSL or ProxSpace with sh available
|
|
|
|
|
|
|
|
# Clear environment locale so that git will not use localized strings
|
|
|
|
export LC_ALL="C"
|
|
|
|
export LANG="C"
|
|
|
|
|
2021-09-05 07:18:42 +08:00
|
|
|
SHORT=false
|
|
|
|
if [ "$1" = "--short" ]; then
|
|
|
|
SHORT=true
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2019-08-30 02:58:36 +08:00
|
|
|
# if you are making your own fork, change this line to reflect your fork-name
|
2022-02-27 00:15:32 +08:00
|
|
|
fullgitinfo="Iceman"
|
2019-08-30 02:58:36 +08:00
|
|
|
# GIT status 0 = dirty, 1 = clean , 2 = undecided
|
|
|
|
clean=2
|
|
|
|
|
2021-10-17 05:43:31 +08:00
|
|
|
# Do we have access to git command?
|
2019-09-02 01:30:29 +08:00
|
|
|
commandGIT=$(env git)
|
2019-08-30 02:58:36 +08:00
|
|
|
|
|
|
|
if [ "$commandGIT" != "" ]; then
|
|
|
|
|
|
|
|
# now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
|
|
|
|
gitversion=$(git describe --dirty --always)
|
|
|
|
gitbranch=$(git rev-parse --abbrev-ref HEAD)
|
2020-05-21 17:50:03 +08:00
|
|
|
if [ "$1" != "--undecided" ]; then
|
|
|
|
if [ "$gitversion" != "${gitversion%-dirty}" ]; then
|
|
|
|
clean=0
|
|
|
|
else
|
|
|
|
clean=1
|
|
|
|
fi
|
2019-08-30 02:58:36 +08:00
|
|
|
fi
|
|
|
|
if [ "$gitbranch" != "" ] && [ "$gitversion" != "" ]; then
|
|
|
|
fullgitinfo="${fullgitinfo}/${gitbranch}/${gitversion}"
|
|
|
|
ctime="$(date '+%Y-%m-%d %H:%M:%S')"
|
|
|
|
else
|
|
|
|
fullgitinfo="${fullgitinfo}/master/release (git)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
fullgitinfo="${fullgitinfo}/master/release (no_git)"
|
|
|
|
dl_time=$(stat --printf="%y" ../README.md)
|
|
|
|
# POSIX way...
|
|
|
|
ctime=${dl_time%.*}
|
|
|
|
fi
|
2021-09-05 07:18:42 +08:00
|
|
|
if $SHORT; then
|
|
|
|
echo "$fullgitinfo"
|
|
|
|
exit 0
|
|
|
|
fi
|
2019-08-30 02:58:36 +08:00
|
|
|
|
|
|
|
# Crop so it fits within 50 characters C string, so max 49 chars
|
|
|
|
# POSIX way
|
|
|
|
fullgitinfoextra="${fullgitinfo#??????????????????????????????????????????????}"
|
|
|
|
if [ "$fullgitinfoextra" != "$fullgitinfo" ]; then
|
|
|
|
fullgitinfo46="${fullgitinfo%"${fullgitinfoextra}"}"
|
|
|
|
fullgitinfo="${fullgitinfo46}..."
|
|
|
|
fi
|
2022-02-14 09:57:10 +08:00
|
|
|
sha=$(
|
2022-02-14 20:37:20 +08:00
|
|
|
pm3path=$(dirname -- "$0")/..
|
|
|
|
cd "$pm3path" || return
|
|
|
|
# did we find the src?
|
|
|
|
[ -f armsrc/appmain.c ] || return
|
2022-03-27 14:03:07 +08:00
|
|
|
ls armsrc/*.[ch] common_arm/*.[ch]|grep -E -v "(disabled|version_pm3|fpga_version_info)"|sort|xargs sha256sum -t|sha256sum|cut -c -9
|
2022-02-14 09:57:10 +08:00
|
|
|
)
|
2022-02-27 19:46:55 +08:00
|
|
|
if [ "$sha" = "" ]; then
|
|
|
|
sha="no sha256"
|
|
|
|
fi
|
2019-08-30 02:58:36 +08:00
|
|
|
cat <<EOF
|
2020-05-20 21:53:47 +08:00
|
|
|
#include "common.h"
|
2019-08-30 02:58:36 +08:00
|
|
|
/* Generated file, do not edit */
|
2020-05-21 02:54:37 +08:00
|
|
|
#ifndef ON_DEVICE
|
|
|
|
#define SECTVERSINFO
|
|
|
|
#else
|
|
|
|
#define SECTVERSINFO __attribute__((section(".version_information")))
|
|
|
|
#endif
|
|
|
|
|
2021-08-22 02:11:14 +08:00
|
|
|
const struct version_information_t SECTVERSINFO g_version_information = {
|
2019-08-30 02:58:36 +08:00
|
|
|
VERSION_INFORMATION_MAGIC,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
$clean,
|
|
|
|
"$fullgitinfo",
|
|
|
|
"$ctime",
|
2022-02-14 09:57:10 +08:00
|
|
|
"$sha"
|
2019-08-30 02:58:36 +08:00
|
|
|
};
|
|
|
|
EOF
|