-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion.sh
executable file
·69 lines (53 loc) · 1.61 KB
/
version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# ###############################
# get branch name
#
branch=`git rev-parse --abbrev-ref HEAD`
#echo ${branch}
#
# if branchname is long, just use the first X-chars and last X-chars, ie "abcde...vwxyz"
branchlen=$(( ${#branch} ))
#echo ${branchlen}
#
if [ ${branchlen} -gt 13 ] ; then
branch_abcde=${branch:0:5}
branch_v_pos=$(( ${branchlen}-5 ))
branch_vwxyz=${branch:${branch_v_pos}:5}
echo "${branch_abcde} ${branch_v_pos} ${branch_vwxyz}"
branch="${branch_abcde}...${branch_vwxyz}"
fi
echo ${branch}
# ###############################
# get git-commit and the dirty-flag
#
commit_id=`git describe --always --abbrev=7 --dirty=~`
version32=`git describe --always --abbrev=8`
datestamp=$(expr $(expr $(date +%Y) - 2020) \* 366 + `date +%j`)
# ###############################
# get timestamp
#
datetime=`date +%Y%m%d.%H`
# ###############################
# get incrememting number (number of commits since branching from branch "ghdl-crash-20200604")
num_commits="$(git log --oneline | wc -l)"
#echo ${num_commits}
# ###############################
# and put it all together
#
stringout="${branch},${num_commits},${datetime},${commit_id}"
echo $stringout
# ###############################
# generate the source file(s)
#
cat > version.vhdl <<ENDTEMPLATE
library ieee;
use Std.TextIO.all;
use ieee.STD_LOGIC_1164.all;
use ieee.numeric_std.all;
package version is
constant gitcommit : string := "${stringout}";
constant fpga_commit : unsigned(31 downto 0) := x"${version32}";
constant fpga_datestamp : unsigned(15 downto 0) := to_unsigned(${datestamp},16);
end version;
ENDTEMPLATE
echo "wrote: version.vhdl"