build: add migen and litex git revision to generated file
This commit is contained in:
parent
8b5cf29542
commit
475deb51ac
|
@ -111,7 +111,7 @@ def _build_files(device, sources, vincpaths, named_sc, named_pc, build_name):
|
||||||
|
|
||||||
|
|
||||||
def _run_quartus(build_name, quartus_path):
|
def _run_quartus(build_name, quartus_path):
|
||||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n"
|
||||||
build_script_contents += """
|
build_script_contents += """
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
|
@ -72,12 +72,12 @@ def _build_files(device, sources, vincpaths, build_name):
|
||||||
def _build_script(build_name, device, toolchain_path, ver=None):
|
def _build_script(build_name, device, toolchain_path, ver=None):
|
||||||
if sys.platform in ("win32", "cygwin"):
|
if sys.platform in ("win32", "cygwin"):
|
||||||
script_ext = ".bat"
|
script_ext = ".bat"
|
||||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
|
||||||
copy_stmt = "copy"
|
copy_stmt = "copy"
|
||||||
fail_stmt = " || exit /b"
|
fail_stmt = " || exit /b"
|
||||||
else:
|
else:
|
||||||
script_ext = ".sh"
|
script_ext = ".sh"
|
||||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\nset -e\n"
|
||||||
copy_stmt = "cp"
|
copy_stmt = "cp"
|
||||||
fail_stmt = ""
|
fail_stmt = ""
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,11 @@ def _build_pre_pack(vns, freq_cstrs):
|
||||||
def _build_script(source, build_template, build_name, **kwargs):
|
def _build_script(source, build_template, build_name, **kwargs):
|
||||||
if sys.platform in ("win32", "cygwin"):
|
if sys.platform in ("win32", "cygwin"):
|
||||||
script_ext = ".bat"
|
script_ext = ".bat"
|
||||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
|
||||||
fail_stmt = " || exit /b"
|
fail_stmt = " || exit /b"
|
||||||
else:
|
else:
|
||||||
script_ext = ".sh"
|
script_ext = ".sh"
|
||||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\nset -e\n"
|
||||||
fail_stmt = ""
|
fail_stmt = ""
|
||||||
|
|
||||||
for s in build_template:
|
for s in build_template:
|
||||||
|
|
|
@ -75,11 +75,11 @@ def _build_script(source, build_template, build_name, architecture,
|
||||||
package, freq_constraint):
|
package, freq_constraint):
|
||||||
if sys.platform in ("win32", "cygwin"):
|
if sys.platform in ("win32", "cygwin"):
|
||||||
script_ext = ".bat"
|
script_ext = ".bat"
|
||||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
|
||||||
fail_stmt = " || exit /b"
|
fail_stmt = " || exit /b"
|
||||||
else:
|
else:
|
||||||
script_ext = ".sh"
|
script_ext = ".sh"
|
||||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\nset -e\n"
|
||||||
fail_stmt = ""
|
fail_stmt = ""
|
||||||
|
|
||||||
for s in build_template:
|
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):
|
def _build_script(build_name, device, toolchain_path, ver=None):
|
||||||
if sys.platform in ("win32", "cygwin"):
|
if sys.platform in ("win32", "cygwin"):
|
||||||
script_ext = ".bat"
|
script_ext = ".bat"
|
||||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n\n"
|
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
|
||||||
copy_stmt = "copy"
|
copy_stmt = "copy"
|
||||||
fail_stmt = " || exit /b"
|
fail_stmt = " || exit /b"
|
||||||
else:
|
else:
|
||||||
script_ext = ".sh"
|
script_ext = ".sh"
|
||||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n"
|
||||||
copy_stmt = "cp"
|
copy_stmt = "cp"
|
||||||
fail_stmt = " || exit 1"
|
fail_stmt = " || exit 1"
|
||||||
|
|
||||||
|
|
|
@ -91,13 +91,27 @@ else:
|
||||||
def cygpath(p):
|
def cygpath(p):
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def git_revision():
|
def get_migen_get_revision():
|
||||||
return "--------"
|
import migen
|
||||||
|
d = os.getcwd()
|
||||||
|
os.chdir(os.path.dirname(migen.__file__))
|
||||||
|
r = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])[:-1].decode("utf-8")
|
||||||
|
os.chdir(d)
|
||||||
|
return r
|
||||||
|
|
||||||
|
def get_litex_get_revision():
|
||||||
|
import litex
|
||||||
|
d = os.getcwd()
|
||||||
|
os.chdir(os.path.dirname(litex.__file__))
|
||||||
|
r = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])[:-1].decode("utf-8")
|
||||||
|
os.chdir(d)
|
||||||
|
return r
|
||||||
|
|
||||||
def generated_banner(line_comment="//"):
|
def generated_banner(line_comment="//"):
|
||||||
r = line_comment + "-"*60 + "\n"
|
r = line_comment + "-"*80 + "\n"
|
||||||
r += line_comment + " Generated by Migen & LiteX / "
|
r += line_comment + " Auto-generated by Migen ({}) & LiteX ({}) on ".format(
|
||||||
r += git_revision() + " / "
|
get_migen_get_revision(),
|
||||||
|
get_litex_get_revision())
|
||||||
r += "{}\n".format(datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S"))
|
r += "{}\n".format(datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
r += line_comment + "-"*60 + "\n"
|
r += line_comment + "-"*80 + "\n"
|
||||||
return r
|
return r
|
|
@ -91,13 +91,13 @@ def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
|
||||||
source_cmd = "call "
|
source_cmd = "call "
|
||||||
script_ext = ".bat"
|
script_ext = ".bat"
|
||||||
shell = ["cmd", "/c"]
|
shell = ["cmd", "/c"]
|
||||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n"
|
||||||
fail_stmt = " || exit /b"
|
fail_stmt = " || exit /b"
|
||||||
else:
|
else:
|
||||||
source_cmd = "source "
|
source_cmd = "source "
|
||||||
script_ext = ".sh"
|
script_ext = ".sh"
|
||||||
shell = ["bash"]
|
shell = ["bash"]
|
||||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\nset -e\n"
|
||||||
fail_stmt = ""
|
fail_stmt = ""
|
||||||
if source:
|
if source:
|
||||||
settings = common.settings(ise_path, ver, "ISE_DS")
|
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):
|
def _run_vivado(build_name, vivado_path, source, ver=None):
|
||||||
if sys.platform == "win32" or sys.platform == "cygwin":
|
if sys.platform == "win32" or sys.platform == "cygwin":
|
||||||
build_script_contents = "REM Autogenerated by LiteX / git: " + tools.git_revision() + "\n"
|
build_script_contents = "REM Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n"
|
||||||
build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
|
build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
|
||||||
build_script_file = "build_" + build_name + ".bat"
|
build_script_file = "build_" + build_name + ".bat"
|
||||||
tools.write_to_file(build_script_file, build_script_contents)
|
tools.write_to_file(build_script_file, build_script_contents)
|
||||||
command = build_script_file
|
command = build_script_file
|
||||||
else:
|
else:
|
||||||
build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_revision() + "\nset -e\n"
|
build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\nset -e\n"
|
||||||
# Only source Vivado settings if not already in our $PATH
|
# Only source Vivado settings if not already in our $PATH
|
||||||
if not find_executable("vivado"):
|
if not find_executable("vivado"):
|
||||||
# For backwards compatibility with ISE paths, also
|
# For backwards compatibility with ISE paths, also
|
||||||
|
|
Loading…
Reference in New Issue