@@ -10,19 +10,36 @@ EXCLUDED_VARS+="|LSORACLE_CMD|YOSYS_CMD|TIME_CMD|STDBUF_CMD"
1010EXCLUDED_VARS+=" |SHELL|OPENROAD_EXE|YOSYS_EXE"
1111EXCLUDED_VARS+=" |UNSET_VARIABLES_NAMES|do-step|get_variables|do-copy"
1212
13+ # get the root directory of the Git repository
14+ GIT_ROOT=$( git rev-parse --show-toplevel)
15+ FLOW_ROOT=${GIT_ROOT} /flow
1316printf ' %s\n' " $ISSUE_VARIABLES " | while read -r V;
1417do
15- if [[ ! ${V% =* } =~ ^[[:digit:]] && ${V} == * " =" * && ! -z ${V#* =} && ${V% =* } != * " MAKEFILE" * && ! ${V% =* } =~ ^(${EXCLUDED_VARS} )$ ]] ; then
16- rhs=` sed -e ' s/^"//' -e ' s/"$//' <<< " ${V#*=}" `
17- # handle special case where the variable needs to be splitted in Tcl code
18- if [[ " ${V% =* } " == " GND_NETS_VOLTAGES" || " ${V% =* } " == " PWR_NETS_VOLTAGES" ]]; then
19- echo " export " ${V% =* } " ='" \" ${rhs} " \" '" >> $1 .sh;
20- else
21- echo " export " ${V% =* } " ='" ${rhs} " '" >> $1 .sh;
18+ if [[ ${V% =* } =~ ^[[:digit:]] || ${V} != * " =" * || -z ${V#* =} || ${V% =* } == * " MAKEFILE" * || ${V% =* } =~ ^(${EXCLUDED_VARS} )$ ]] ; then
19+ continue
20+ fi
21+ rhs=` sed -e ' s/^"//' -e ' s/"$//' <<< " ${V#*=}" `
22+ # handle absolute paths
23+ if [[ " ${rhs} " == /* ]]; then
24+ if [[ ! -e " ${rhs} " ]]; then
25+ echo " Skiping path not found ${V} "
26+ continue
27+ fi
28+ if [[ " ${rhs} " != " ${GIT_ROOT} " * ]]; then
29+ echo " Skiping file outside git ${V} "
30+ continue
2231 fi
23- echo " set env(" ${V% =* } " ) \" " ${rhs} \" " " >> $1 .tcl;
24- echo " set env " ${V% =* } " " ${rhs} " " >> $1 .gdb;
32+ # convert the absolute path to a path relative to the flow dir
33+ rhs=$( realpath --relative-to=" $FLOW_ROOT " " $rhs " )
34+ fi
35+ # handle special case where the variable needs to be splitted in Tcl code
36+ if [[ " ${V% =* } " == " GND_NETS_VOLTAGES" || " ${V% =* } " == " PWR_NETS_VOLTAGES" ]]; then
37+ echo " export " ${V% =* } " ='" \" ${rhs} " \" '" >> $1 .sh;
38+ else
39+ echo " export " ${V% =* } " ='" ${rhs} " '" >> $1 .sh;
2540 fi
41+ echo " set env(" ${V% =* } " ) \" " ${rhs} \" " " >> $1 .tcl;
42+ echo " set env " ${V% =* } " " ${rhs} " " >> $1 .gdb;
2643done
2744
2845# remove variables starting with a dot
0 commit comments