Merge pull request #400 from mikey/githash
syscon: Implement a register for storing git hash infopull/402/head
commit
26095986f3
@ -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;
|
Binary file not shown.
Binary file not shown.
@ -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