build: add git version (sha-1) used to create the scripts
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 23 Apr 2019 04:03:12 +0000 (06:03 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 23 Apr 2019 04:03:12 +0000 (06:03 +0200)
litex/build/altera/quartus.py
litex/build/lattice/diamond.py
litex/build/lattice/icestorm.py
litex/build/lattice/trellis.py
litex/build/microsemi/libero_soc.py
litex/build/tools.py
litex/build/xilinx/ise.py
litex/build/xilinx/vivado.py

index b26f7596848e999384ae0c8a8e0a02b28538afdb..e296fc4b6476e08ab9b2f191060c5503e6e2d4cf 100644 (file)
@@ -111,7 +111,8 @@ 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
+    build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\n"
+    build_script_contents += """
 
 set -e
 
index 9160f8f00565ec8909bfa171d5c48e84a4fb1f44..34ed7b4d4391e900da8b54744e9e291057767df9 100644 (file)
@@ -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\n\n"
+        build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
         copy_stmt = "copy"
         fail_stmt = " || exit /b"
     else:
         script_ext = ".sh"
-        build_script_contents = "# Autogenerated by LiteX\nset -e\n\n"
+        build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
         copy_stmt = "cp"
         fail_stmt = ""
 
index 3f4ccc9736e9452b9c53714a373b93addfb22aa6..3983c7cafc7ebe7aaf265f2fbe475bda12790be5 100644 (file)
@@ -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\n\n"
+        build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
         fail_stmt = " || exit /b"
     else:
         script_ext = ".sh"
-        build_script_contents = "# Autogenerated by LiteX\nset -e\n\n"
+        build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
         fail_stmt = ""
 
     for s in build_template:
index d1ad5b7839ce65812576e853a6c57eb18f31bd8e..570f9c88e52e783464b4218baed4fe844b45ca8a 100644 (file)
@@ -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\n\n"
+        build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
         fail_stmt = " || exit /b"
     else:
         script_ext = ".sh"
-        build_script_contents = "# Autogenerated by LiteX\nset -e\n\n"
+        build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
         fail_stmt = ""
 
     for s in build_template:
index c3e42f449f38b89d7ff6c1eae8e7578cd6624748..0dbf2e9465f57a9f327d19a3ce086cc26d4bf009 100644 (file)
@@ -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\n\n"
+        build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n\n"
         copy_stmt = "copy"
         fail_stmt = " || exit /b"
     else:
         script_ext = ".sh"
-        build_script_contents = "# Autogenerated by LiteX\n\n"
+        build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\n"
         copy_stmt = "cp"
         fail_stmt = " || exit 1"
 
index 313abaea4c409ead2e9cd1ecfacfeff75e7d9c63..bfa8108b0706a585f0c330e9d3c08acf12c313aa 100644 (file)
@@ -88,3 +88,6 @@ if sys.platform == "cygwin":
 else:
     def cygpath(p):
         return p
+
+def git_version():
+    return subprocess.check_output(["git", "describe", "--always"]).strip().decode("utf-8")
index 0242279d49c1869e380e589b17fb66c2dd0cda38..cd3e2d183a4e666a209fd4a7bec497384f7f7a59 100644 (file)
@@ -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\n"
+        build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.git_version() + "\n"
         fail_stmt = " || exit /b"
     else:
         source_cmd = "source "
         script_ext = ".sh"
         shell = ["bash"]
-        build_script_contents = "# Autogenerated by LiteX\nset -e\n"
+        build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\nset -e\n"
         fail_stmt = ""
     if source:
         settings = common.settings(ise_path, ver, "ISE_DS")
index d04ff2d451fa3126b4ea65a21036ff0e15448a4f..93e6fe22eb6b3bab59cb74d192982b1e6fa6361c 100644 (file)
@@ -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\n"
+        build_script_contents = "REM Autogenerated by LiteX / git: " + tools.git_version() + "\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\nset -e\n"
+        build_script_contents = "# Autogenerated by LiteX / git: " + tools.git_version() + "\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