diff --git a/tools/sdb_desc_gen.tcl b/tools/sdb_desc_gen.tcl index cc48278e542ea9ba5c7f4625287bb5307fbb76ea..4b9a5cfceb555db23123f3e889012fe39f8363c9 100644 --- a/tools/sdb_desc_gen.tcl +++ b/tools/sdb_desc_gen.tcl @@ -1,20 +1,34 @@ -# Tcl script to automatically generate the SDB synthesis descriptor. -# -# Must be added to your top-level Manifest.py like this: -# -# syn_post_project_cmd = "$(TCL_INTERPRETER) [this_tcl_script] " + -# syn_tool + " $(PROJECT_FILE)" -# -# Notes: -# -# 1. $(TCL_INTERPRETER) and $(PROJECT_FILE) will be automatically -# resolved inside the Makefile generated by hdlmake. -# 2. syn_tool is a Manifest.py variable, it should already be in your -# tol-level Manifest.py. -# 3. [this_tcl_script] should be replaced by the full path to -# this Tcl script. Relative paths should be with respect to -# the location of the top-level Manifest.py. -# 4. Mind the spaces inside the quotes, before and after syn_tool. +##------------------------------------------------------------------------------- +## CERN BE-CO-HT +## General Cores +## https://www.ohwr.org/projects/general-cores +##------------------------------------------------------------------------------- +## +## Tcl script to automatically generate the SDB synthesis descriptor. +## +## Must be added to your top-level Manifest.py like this: +## +## syn_post_project_cmd = "$(TCL_INTERPRETER) [this_tcl_script] " + +## syn_tool + " $(PROJECT_FILE)" +## +## notes: +## +## 1. $(TCL_INTERPRETER) and $(PROJECT_FILE) will be automatically +## resolved inside the Makefile generated by hdlmake. +## 2. syn_tool is a Manifest.py variable, it should already be in your +## tol-level Manifest.py. +## 3. [this_tcl_script] should be replaced by the full path to +## this Tcl script. Relative paths should be with respect to +## the location of the top-level Manifest.py. +## 4. Mind the spaces inside the quotes, before and after syn_tool. +## +##------------------------------------------------------------------------------- +## Copyright CERN 2018 +##------------------------------------------------------------------------------- +## This Source Code Form is subject to the terms of the Mozilla Public License, +## version 2.0. If a copy of the MPL was not distributed with this file, You can +## obtain one at https://mozilla.org/MPL/2.0/. +##------------------------------------------------------------------------------- # get current time set time_now [clock seconds] @@ -92,13 +106,21 @@ if {$syn_tool == "ise"} { # For now we hard-code, since anyway ISE is end-of-life at version 14.7. set inf_tool_version [format "%08d" "147"] } + set inf_tool_name [string toupper $syn_tool] -set inf_commit_id [exec git log -1 --format=%H] set inf_date [clock format $time_now -format "%A, %B %d %Y"] set inf_date_ymd [clock format $time_now -format "%Y%m%d"] -set inf_user [exec git config user.name] -# next line could break if git remote is not called "origin" -set inf_repo_url [exec git remote get-url origin] + +# Git commands below have fallbacks in case something goes wrong. +if { [catch { set inf_user [exec git config --get user.name] }] } { + set inf_user "unknown user" +} +if { [catch { set inf_commit_id [exec git log -1 --format=%H] }] } { + set inf_commit_id "unknown commit" +} +if { [catch { set inf_repo_url [exec git config --get remote.origin.url] }] } { + set inf_repo_url "unknown url" +} #------------------------------------------------------------------------------- # STEP 5/7: Generate the output file