Skip to content

Commit 4f70508

Browse files
committed
util: fix path in variables
Signed-off-by: Vitor Bandeira <[email protected]>
1 parent ed48b6e commit 4f70508

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

flow/util/generate-vars.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/bin/bash
22
set -euo pipefail
33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
FLOW_ROOT=$(realpath "${FLOW_HOME}")
5+
ORFS_ROOT=$(realpath "${FLOW_HOME}/../")
46

57
# exclude system and CI variables
6-
EXCLUDED_VARS="MAKE|PERL5LIB"
7-
EXCLUDED_VARS+="|HOME|PWD|MAIL|QT_QPA_PLATFORM"
8-
EXCLUDED_VARS+="|SHELL|OPENROAD_EXE|YOSYS_EXE|RESULTS_ODB"
9-
EXCLUDED_VARS+="|NPROC|NUM_CORES|PUBLIC|ISSUE_SCRIPTS|MAKEFLAGS"
8+
EXCLUDED_VARS="MAKE|MAKEFLAGS|PERL5LIB|QT_QPA_PLATFORM"
9+
EXCLUDED_VARS+="|RESULTS_ODB|PUBLIC|ISSUE_SCRIPTS"
10+
EXCLUDED_VARS+="|HOME|PWD|MAIL|SHELL|NPROC|NUM_CORES"
1011
EXCLUDED_VARS+="|UNSET_VARIABLES_NAMES|do-step|get_variables|do-copy"
1112

12-
EXCLUDED_PATTERNS="_EXE$|PATH$|_DIR$|_CMD$|^\."
13+
EXCLUDED_PATTERNS="_EXE$|PATH$|_CMD$|\."
1314

1415
while read -r VAR; do
1516
if [[ ${VAR} != *"="* ]] ; then
@@ -41,14 +42,14 @@ while read -r VAR; do
4142
# skip variables that match the exclude patterns
4243
continue
4344
fi
44-
if [[ ${value} == *"\""* ]]; then
45-
# remove double quotes from value to avoid syntax issues on final
46-
# generated script
47-
value=$(sed -e 's/^"//' -e 's/"$//' <<< "${value}")
45+
if [[ ${value} == /* ]]; then
46+
# convert absolute paths if possible to use FLOW_HOME variable
47+
value=$(sed -e "s,${FLOW_ROOT},\${FLOW_HOME},g" <<< "${value}")
48+
value=$(sed -e "s,${ORFS_ROOT},\${FLOW_HOME}/\.\.,g" <<< "${value}")
4849
fi
4950
# handle special case where the variable needs to be splitted in Tcl code
5051
if [[ "${name}" == "GND_NETS_VOLTAGES" || "${name}" == "PWR_NETS_VOLTAGES" ]]; then
51-
echo "export ${name}='\"${value}\"'" >> $1.sh;
52+
echo "export ${name}='${value}'" >> $1.sh;
5253
else
5354
echo "export ${name}=\"${value}\"" >> $1.sh;
5455
fi

0 commit comments

Comments
 (0)