syscon: Implement a register for storing git hash info
It also stores the dirty status so that's known. This does some Makefile tricks so that we only rebuild when the git hash changes. This avoids rebuilding the world every time we run make. Also adds fusesoc generator, so that should continue to work as before. Signed-off-by: Dan Horák <dan@danny.cz> Signed-off-by: Michael Neuling <mikey@neuling.org>pull/400/head
parent
050185e2ca
commit
1ddbacb67f
@ -0,0 +1,9 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
library work;
|
||||
|
||||
package git is
|
||||
constant GIT_HASH : std_ulogic_vector(55 downto 0) := x"@hash@";
|
||||
constant GIT_DIRTY : std_ulogic := '@dirty@';
|
||||
end git;
|
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script builds a git.vhdl which contains info on the SHA1 and
|
||||
# dirty status of your git tree. It always builds but only replaces
|
||||
# the file if it's changed. This way we can use Makefile $(shell ..)
|
||||
# to build it which happens before make does it's dependancy checks.
|
||||
#
|
||||
|
||||
dirty="0"
|
||||
version="00000000000000"
|
||||
|
||||
usage() {
|
||||
echo "$0 <file>"
|
||||
echo -e "\tSubstitute @hash@ and @dirty@ in <file> with gathered values."
|
||||
}
|
||||
|
||||
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=14 HEAD 2>/dev/null)
|
||||
fi
|
||||
if git diff-index --name-only HEAD |grep -qv '.git';
|
||||
then
|
||||
dirty="1"
|
||||
fi
|
||||
# echo "hash=$version dirty=$dirty"
|
||||
fi
|
||||
|
||||
# Put it in a temp file and only update if it's change. This helps Make
|
||||
sed -e "s/@hash@/$version/" -e "s/@dirty@/$dirty/" ${src}.in > ${src}.tmp
|
||||
if diff -q ${src}.tmp ${src} >/dev/null 2>&1; then
|
||||
rm ${src}.tmp
|
||||
else
|
||||
mv ${src}.tmp ${src}
|
||||
fi
|
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Simple wrapper around make_version.sh that fusesoc needs
|
||||
# Just pulls out the files_root from yaml so we know where to run.
|
||||
#
|
||||
|
||||
import yaml
|
||||
import sys
|
||||
import os
|
||||
|
||||
with open(sys.argv[1], 'r') as stream:
|
||||
data = yaml.safe_load(stream)
|
||||
|
||||
# Run make version in source dir so we can get the git version
|
||||
os.system("cd %s; scripts/make_version.sh git.vhdl" % data["files_root"])
|
Loading…
Reference in New Issue