You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB

#!/bin/bash
# Copyright (c) Hisilicon Technologies Co., Ltd.. 2012-2019. All rights reserved.
# Description: ssm version script
# Author: sdk
# Create: 2022-03-03
set -e
SDK_DIR="$(pwd)"
REE_DIR_ARRAY=("$SDK_DIR")
function get_version_by_path() {
maxtime=0
verstr=""
COMMIT_CMD_DATA="git log --date=format:'%Y-%m-%d %H:%M:%S' | grep 'Date' | head -n 1"
COMMIT_CMD_CIID="git log --abbrev-commit | grep 'Change-Id:' | head -n 1"
arr=$1
for dir in ${arr[*]}
do
cd $dir
time=$(git log --date=format:'%Y-%m-%d %H:%M:%S' | grep "Date" | head -n 1 | awk '{print $2,$3}')
timenum=$(date -d "$time" +%s)
if [ $timenum -gt $maxtime ]; then
str1=$(eval $COMMIT_CMD_DATA)
str2=$(eval $COMMIT_CMD_CIID)
verstr="${str2#* } ${str1#*:}"
maxtime=$timenum
fi
done
echo $verstr
}
function gen_version() {
VER_FILE=ssm_version.h
# get ree version
REE_VER=$(get_version_by_path "${REE_DIR_ARRAY[*]}")
SSM_REE_VER="static td_uchar g_ssm_ree_version[] ="
echo "/*
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2012-2019. All rights reserved.
* Description: ssm version
* Author: sdk
* Create: 2019-04-13
*/
" > $VER_FILE
echo "#ifndef __SSM_VERSION_H_" >> $VER_FILE
echo "#define __SSM_VERSION_H_" >> $VER_FILE
echo "" >> $VER_FILE
echo $SSM_REE_VER " \"" $REE_VER "\";" >> $VER_FILE
echo "" >> $VER_FILE
echo "#endif" >> $VER_FILE
sed -i 's/\"\ /\"/g' ./ssm_version.h
sed -i 's/\ \"/\"/g' ./ssm_version.h
echo "==============$0 finish=============="
}
gen_version