mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
build: add sha-1/date to generated verilog, change git_version to git_revision
This commit is contained in:
parent
f7c0b118ce
commit
425741226c
9 changed files with 25 additions and 16 deletions
|
@ -111,7 +111,7 @@ def _build_files(device, sources, vincpaths, named_sc, named_pc, build_name):
|
|||
|
||||
|
||||
def _run_quartus(build_name, quartus_path):
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\n"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
||||
build_script_contents += """
|
||||
|
||||
set -e
|
||||
|
|
|
@ -72,12 +72,12 @@ def _build_files(device, sources, vincpaths, build_name):
|
|||
def _build_script(build_name, device, toolchain_path, ver=None):
|
||||
if sys.platform in ("win32", "cygwin"):
|
||||
script_ext = ".bat"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
||||
copy_stmt = "copy"
|
||||
fail_stmt = " || exit /b"
|
||||
else:
|
||||
script_ext = ".sh"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
||||
copy_stmt = "cp"
|
||||
fail_stmt = ""
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ def _build_pre_pack(vns, freq_cstrs):
|
|||
def _build_script(source, build_template, build_name, **kwargs):
|
||||
if sys.platform in ("win32", "cygwin"):
|
||||
script_ext = ".bat"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
||||
fail_stmt = " || exit /b"
|
||||
else:
|
||||
script_ext = ".sh"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
||||
fail_stmt = ""
|
||||
|
||||
for s in build_template:
|
||||
|
|
|
@ -75,11 +75,11 @@ def _build_script(source, build_template, build_name, architecture,
|
|||
package, freq_constraint):
|
||||
if sys.platform in ("win32", "cygwin"):
|
||||
script_ext = ".bat"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
||||
fail_stmt = " || exit /b"
|
||||
else:
|
||||
script_ext = ".sh"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
||||
fail_stmt = ""
|
||||
|
||||
for s in build_template:
|
||||
|
|
|
@ -181,12 +181,12 @@ def _build_timing_sdc(vns, clocks, false_paths, build_name, additional_timing_co
|
|||
def _build_script(build_name, device, toolchain_path, ver=None):
|
||||
if sys.platform in ("win32", "cygwin"):
|
||||
script_ext = ".bat"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
||||
copy_stmt = "copy"
|
||||
fail_stmt = " || exit /b"
|
||||
else:
|
||||
script_ext = ".sh"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\n"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
||||
copy_stmt = "cp"
|
||||
fail_stmt = " || exit 1"
|
||||
|
||||
|
|
|
@ -89,5 +89,5 @@ else:
|
|||
def cygpath(p):
|
||||
return p
|
||||
|
||||
def git_version():
|
||||
return subprocess.check_output(["git", "describe", "--always"]).strip().decode("utf-8")
|
||||
def git_revision():
|
||||
return subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).strip().decode("utf-8")
|
||||
|
|
|
@ -91,13 +91,13 @@ def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
|
|||
source_cmd = "call "
|
||||
script_ext = ".bat"
|
||||
shell = ["cmd", "/c"]
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n"
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
||||
fail_stmt = " || exit /b"
|
||||
else:
|
||||
source_cmd = "source "
|
||||
script_ext = ".sh"
|
||||
shell = ["bash"]
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
||||
fail_stmt = ""
|
||||
if source:
|
||||
settings = common.settings(ise_path, ver, "ISE_DS")
|
||||
|
|
|
@ -58,13 +58,13 @@ def _build_xdc(named_sc, named_pc):
|
|||
|
||||
def _run_vivado(build_name, vivado_path, source, ver=None):
|
||||
if sys.platform == "win32" or sys.platform == "cygwin":
|
||||
build_script_contents = "REM Autogenerated by LiteX / git: " + tools.git_version() + "\n"
|
||||
build_script_contents = "REM Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
||||
build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
|
||||
build_script_file = "build_" + build_name + ".bat"
|
||||
tools.write_to_file(build_script_file, build_script_contents)
|
||||
command = build_script_file
|
||||
else:
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
|
||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
||||
# Only source Vivado settings if not already in our $PATH
|
||||
if not find_executable("vivado"):
|
||||
# For backwards compatibility with ISE paths, also
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from functools import partial
|
||||
from operator import itemgetter
|
||||
import collections
|
||||
import time
|
||||
import datetime
|
||||
|
||||
from migen.fhdl.structure import *
|
||||
from migen.fhdl.structure import _Operator, _Slice, _Assign, _Fragment
|
||||
|
@ -8,6 +10,8 @@ from migen.fhdl.tools import *
|
|||
from migen.fhdl.namer import build_namespace
|
||||
from migen.fhdl.conv_output import ConvOutput
|
||||
|
||||
from litex.build.tools import git_revision
|
||||
|
||||
|
||||
_reserved_keywords = {
|
||||
"always", "and", "assign", "automatic", "begin", "buf", "bufif0", "bufif1",
|
||||
|
@ -402,7 +406,12 @@ def convert(f, ios=None, name="top",
|
|||
ns.clock_domains = f.clock_domains
|
||||
r.ns = ns
|
||||
|
||||
src = "/* Machine-generated using LiteX gen */\n"
|
||||
src = "//" + "-"*60 + "\n"
|
||||
src += "// Generated by Migen & LiteX / ".format(git_revision())
|
||||
src += git_revision() + " / "
|
||||
src += "{}\n".format(datetime.datetime.fromtimestamp(
|
||||
time.time()).strftime("%Y-%m-%d %H:%M:%S"))
|
||||
src += "//" + "-"*60 + "\n"
|
||||
src += _printheader(f, ios, name, ns, attr_translate,
|
||||
reg_initialization=reg_initialization)
|
||||
if regular_comb:
|
||||
|
|
Loading…
Reference in a new issue