Skip to content

Commit 2d97675

Browse files
committed
util: issue do not save missing path/outside git
Signed-off-by: Vitor Bandeira <[email protected]>
1 parent 42fc6bb commit 2d97675

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

flow/util/generate-vars.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,36 @@ EXCLUDED_VARS+="|LSORACLE_CMD|YOSYS_CMD|TIME_CMD|STDBUF_CMD"
1010
EXCLUDED_VARS+="|SHELL|OPENROAD_EXE|YOSYS_EXE"
1111
EXCLUDED_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
1316
printf '%s\n' "$ISSUE_VARIABLES" | while read -r V;
1417
do
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;
2643
done
2744

2845
# remove variables starting with a dot

0 commit comments

Comments
 (0)