Skip to content

Commit bfdd544

Browse files
authored
Merge pull request #1303 from vvbandeira/make-issue
Cleanup make issue generation
2 parents bf9f1e8 + 0a4b13f commit bfdd544

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

flow/util/generate-vars.sh

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,47 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44

55
# exclude system and CI variables
66
EXCLUDED_VARS="MAKE|PYTHONPATH|PKG_CONFIG_PATH|PERL5LIB|PCP_DIR|PATH|MANPATH"
7-
EXCLUDED_VARS+="|LD_LIBRARY_PATH|INFOPATH|HOME|PWD|MAIL|TIME_CMD|QT_QPA_PLATFORM"
8-
EXCLUDED_VARS+="|do-step|get_variables|do-copy"
7+
EXCLUDED_VARS+="|LD_LIBRARY_PATH|INFOPATH|HOME|PWD|MAIL|QT_QPA_PLATFORM"
8+
EXCLUDED_VARS+="|OPENROAD_CMD|OPENROAD_GUI_CMD|OPENROAD_NO_EXIT_CMD"
9+
EXCLUDED_VARS+="|LSORACLE_CMD|YOSYS_CMD|TIME_CMD|STDBUF_CMD"
10+
EXCLUDED_VARS+="|SHELL|OPENROAD_EXE|YOSYS_EXE"
11+
EXCLUDED_VARS+="|NPROC|NUM_CORES|PUBLIC|CURDIR|ISSUE_SCRIPTS|MAKEFLAGS"
12+
EXCLUDED_VARS+="|UNSET_VARIABLES_NAMES|do-step|get_variables|do-copy"
913

14+
# get the root directory of the Git repository
15+
GIT_ROOT=$(git rev-parse --show-toplevel)
16+
FLOW_ROOT=${GIT_ROOT}/flow
1017
printf '%s\n' "$ISSUE_VARIABLES" | while read -r V;
1118
do
12-
if [[ ! ${V%=*} =~ ^[[:digit:]] && ${V} == *"="* && ! -z ${V#*=} && ${V%=*} != *"MAKEFILE"* && ! ${V%=*} =~ ^(${EXCLUDED_VARS})$ ]] ; then
13-
rhs=`sed -e 's/^"//' -e 's/"$//' <<<"${V#*=}"`
14-
# handle special case where the variable needs to be splitted in Tcl code
15-
if [[ "${V%=*}" == "GND_NETS_VOLTAGES" || "${V%=*}" == "PWR_NETS_VOLTAGES" ]]; then
16-
echo "export "${V%=*}"='"\"${rhs}"\"'" >> $1.sh;
17-
else
18-
echo "export "${V%=*}"='"${rhs}"'" >> $1.sh;
19+
if [[ ${V%=*} =~ ^[[:digit:]] || ${V} != *"="* || -z ${V#*=} || ${V%=*} == *"MAKEFILE"* || ${V%=*} =~ ^(${EXCLUDED_VARS})$ ]] ; then
20+
continue
21+
fi
22+
rhs=`sed -e 's/^"//' -e 's/"$//' <<<"${V#*=}"`
23+
if [[ "${rhs}" == "''" ]]; then
24+
echo "Skiping empty variable ${V}"
25+
continue
26+
fi
27+
# handle absolute paths
28+
if [[ "${rhs}" == /* ]]; then
29+
if [[ ! -e "${rhs}" ]]; then
30+
echo "Skiping path not found ${V}"
31+
continue
1932
fi
20-
echo "set env("${V%=*}") \""${rhs}\""" >> $1.tcl;
21-
echo "set env "${V%=*}" "${rhs}"" >> $1.gdb;
33+
if [[ "${rhs}" != "${GIT_ROOT}"* ]]; then
34+
echo "Skiping file outside git ${V}"
35+
continue
36+
fi
37+
# convert the absolute path to a path relative to the flow dir
38+
rhs=$(realpath --relative-to="$FLOW_ROOT" "$rhs")
39+
fi
40+
# handle special case where the variable needs to be splitted in Tcl code
41+
if [[ "${V%=*}" == "GND_NETS_VOLTAGES" || "${V%=*}" == "PWR_NETS_VOLTAGES" ]]; then
42+
echo "export "${V%=*}"='"\"${rhs}"\"'" >> $1.sh;
43+
else
44+
echo "export "${V%=*}"='"${rhs}"'" >> $1.sh;
2245
fi
46+
echo "set env("${V%=*}") \""${rhs}\""" >> $1.tcl;
47+
echo "set env "${V%=*}" "${rhs}"" >> $1.gdb;
2348
done
2449

2550
# remove variables starting with a dot

0 commit comments

Comments
 (0)