加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
version.sh 2.96 KB
一键复制 编辑 原始数据 按行查看 历史
hanbingjie 提交于 2020-08-21 14:56 . update CMake file
#!/bin/bash
# ============================================================================
# File:
# version.sh
# - get version of repository and generate the file version.h
# ============================================================================
# get version of remote and local repository
shell_dir=""
if [ ! -n "$1" ]; then
shell_dir="."
else
shell_dir=$1
fi
VER_R=`git rev-list origin/master | sort | wc -l | gawk '{print $1}'`
VER_L=`git rev-list HEAD | sort | wc -l | gawk '{print $1}'`
VER_SHA1=`git log -n 1 | head -n 1 | cut -d ' ' -f 2`
major_version="1"
minor_version="2"
type_version="release"
# generate the file version.h
echo "// ===========================================================================" > $shell_dir/version.h
echo "// version.h" >> $shell_dir/version.h
echo "// - collection of version numbers" >> $shell_dir/version.h
echo "// ===========================================================================" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#ifndef __VERSION_H__" >> $shell_dir/version.h
echo "#define __VERSION_H__" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#define VER_MAJOR $major_version // major version number" >> $shell_dir/version.h
echo "#define VER_MINOR $minor_version // minor version number" >> $shell_dir/version.h
echo "#define VER_BUILD $VER_L // build number" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#define VERSION_TYPE \"$type_version\"" >> $shell_dir/version.h
echo "#define VERSION_STR \"$major_version.$minor_version.$VER_L\"" >> $shell_dir/version.h
echo "#define VERSION_SHA1 \"$VER_SHA1\"" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#endif // __VERSION_H__" >> $shell_dir/version.h
# show version informations
echo " "
echo " GIT VERSION TOOLS"
echo " ====================="
echo " "
echo " get the code version number of remote & local repository."
echo " "
echo " remote: $VER_R"
echo " local: $VER_L"
echo " SHA-1: $VER_SHA1"
echo " "
echo " remote version $VER_L is added to file version.h, such as:"
echo " "
echo " #define VER_BUILD $VER_L"
echo " "
echo " #define VERSION_SHA1 $VER_SHA1"
echo " "
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化