syscon: get the git hash and dirty flag in build time
Signed-off-by: Dan Horák <dan@danny.cz>pull/243/head
parent
538a8629f4
commit
d177ee32f9
@ -1,9 +0,0 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
library work;
|
||||
|
||||
package git is
|
||||
constant GIT_HASH : std_ulogic_vector(27 downto 0) := x"1234567";
|
||||
constant GIT_DIRTY : std_ulogic := '0';
|
||||
end git;
|
@ -0,0 +1,9 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
library work;
|
||||
|
||||
package git is
|
||||
constant GIT_HASH : std_ulogic_vector(27 downto 0) := x"@hash@";
|
||||
constant GIT_DIRTY : std_ulogic := '@dirty@';
|
||||
end git;
|
@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
dirty="0"
|
||||
|
||||
usage() {
|
||||
echo "$0 <file>"
|
||||
echo -e "\tSubstitute @hash@ and @dirty@ in <file> with gathered values."
|
||||
}
|
||||
|
||||
if [ "$1" = "-h" -o "$1" = "--help" ] ;
|
||||
then
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
if [ -z $1 ] ;
|
||||
then
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
src=$1
|
||||
|
||||
if test -e .git || git rev-parse --is-inside-work-tree > /dev/null 2>&1;
|
||||
then
|
||||
version=$(git describe --exact-match 2>/dev/null)
|
||||
if [ -z "$version" ];
|
||||
then
|
||||
version=$(git describe 2>/dev/null)
|
||||
fi
|
||||
if [ -z "$version" ];
|
||||
then
|
||||
version=$(git rev-parse --verify --short HEAD 2>/dev/null)
|
||||
fi
|
||||
if git diff-index --name-only HEAD |grep -qv '.git';
|
||||
then
|
||||
dirty="1"
|
||||
fi
|
||||
echo "hash=$version dirty=$dirty"
|
||||
sed -e "s/@hash@/$version/" -e "s/@dirty@/$dirty/" ${src}.in > ${src}
|
||||
fi
|
Loading…
Reference in New Issue