Skip to content

Commit 7b6f366

Browse files
committed
fix: make issue tarballs self-contained when WORK_HOME differs
CI runs ORFS from a docker image (/OpenROAD-flow-scripts) with WORK_HOME set to the Jenkins workspace (/tmp/workspace/...). The issue tarballs then recreated the absolute workspace path (tmp/ folder) and run-me sourced the vars file via a hardcoded CI path, so extracted reproducibles failed out of the box: run-me-*.sh: line 2: /tmp/workspace/.../vars-*.sh: No such file [ERROR STA-0340] cannot open '/final_report.tcl'. - makeIssue.sh: source vars relative to run-me location; strip WORK_HOME prefix (literal and symlink-resolved) from tar members - generate-vars.sh: relativize paths under WORK_HOME instead of only the hardcoded /workspace prefix - test_make_issue.sh: run the extracted run-me script instead of the WORK_HOME copy via absolute path Signed-off-by: Vitor Bandeira <vvbandeira@precisioninno.com>
1 parent d90873f commit 7b6f366

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

flow/test/test_make_issue.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ make ISSUE_TAG=tag DESIGN_CONFIG=designs/asap7/gcd/config.mk ${ISSUE_TARGET}_iss
1515
test_archive=${ISSUE_TARGET}_tag.tar.gz
1616
ls -l $test_archive
1717
echo "Testing $test_archive"
18-
runme=$(realpath run-me-gcd-asap7-base.sh)
1918
. ../env.sh
2019
rm -rf results/make-issue/
2120
mkdir -p results/make-issue/
2221
cd results/make-issue/
2322
tar --strip-components=1 -xzf ../../$test_archive
24-
sed -i 's/openroad -no_init/openroad -exit -no_init/g' $runme
25-
$runme
23+
sed -i 's/openroad -no_init/openroad -exit -no_init/g' run-me-gcd-asap7-base.sh
24+
./run-me-gcd-asap7-base.sh
2625
# check for basic syntax errors
2726
openroad -exit -no_init vars-gcd-asap7-base.tcl

flow/util/generate-vars.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -euo pipefail
33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44
FLOW_ROOT=$(realpath "${FLOW_HOME}")
55
ORFS_ROOT=$(realpath "${FLOW_HOME}/../")
6+
WORK_ROOT=$(realpath "${WORK_HOME:-.}")
67

78
# exclude system and CI variables
89
EXCLUDED_VARS='MAKE|MAKEFLAGS|PERL5LIB|QT_QPA_PLATFORM'
@@ -54,6 +55,15 @@ while read -r VAR; do
5455

5556
# PII members use PRESERVE_PATHS=1 make issue ...
5657
if [[ ! -v PRESERVE_PATHS ]]; then
58+
# Relativize paths under WORK_HOME (e.g. a CI workspace); makeIssue.sh
59+
# stores those files at the tarball root. Both the literal and the
60+
# symlink-resolved form may appear in values. Skip when WORK_HOME is
61+
# FLOW_HOME, which is handled via ${FLOW_HOME} below.
62+
for work_path in "${WORK_HOME:-.}" "${WORK_ROOT}"; do
63+
if [[ "${work_path}" == /* && "${work_path}" != "${FLOW_ROOT}" ]]; then
64+
value=$(sed -e "s,\(^\|[: \"']\)${work_path},\1.,g" <<< "${value}")
65+
fi
66+
done
5767
for path in workspace platforms; do
5868
value=$(sed -e "s,\(^\|[: \"']\)/${path},\1./${path},g" <<< "${value}")
5969
done

flow/util/makeIssue.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,22 @@ else
8080
IS_YOSYS=0
8181
fi
8282

83+
# Source the vars file relative to the run-me script itself, so the
84+
# reproducible works out of the box wherever the tarball is extracted
85+
# (WORK_HOME is an absolute CI path that does not exist elsewhere).
8386
if [ "$IS_YOSYS" -eq 1 ]; then
8487
cat > ${RUN_ME_SCRIPT} <<EOF
8588
#!/usr/bin/env bash
86-
source ${VARS_BASENAME}.sh
89+
cd "\$(dirname "\$0")"
90+
source ./$(basename ${VARS_BASENAME}).sh
8791
export PYTHON_EXE=\${PYTHON_EXE:-\$(command -v python3)}
8892
yosys ${YOSYS_FLAGS:-} -c \${SCRIPTS_DIR}/${ISSUE_TARGET}.tcl
8993
EOF
9094
else
9195
cat > ${RUN_ME_SCRIPT} <<EOF
9296
#!/usr/bin/env bash
93-
source ${VARS_BASENAME}.sh
97+
cd "\$(dirname "\$0")"
98+
source ./$(basename ${VARS_BASENAME}).sh
9499
if [[ ! -z \${GDB+x} ]]; then
95100
gdb --args openroad -no_init -threads ${NUM_CORES:-1} \${SCRIPTS_DIR}/${ISSUE_TARGET}.tcl
96101
else
@@ -122,10 +127,20 @@ else
122127
DESIGN_PLATFORM_FILES="$DESIGN_CONFIG $PLATFORM_DIR/config*.mk"
123128
fi
124129

130+
# Strip the WORK_HOME prefix as well, so files generated outside FLOW_HOME
131+
# (vars, run-me, logs, ... when WORK_HOME points at a CI workspace) land at
132+
# the tarball root instead of recreating the absolute path (e.g. tmp/...).
133+
# Both the literal and the symlink-resolved form may appear in member names.
134+
WORK_ROOT=$(realpath "${WORK_HOME:-.}")
135+
WORK_HOME_TRANSFORMS=(--transform="s|^${ISSUE_TARGET}_${ISSUE_TAG}${WORK_ROOT}/|${ISSUE_TARGET}_${ISSUE_TAG}/|S")
136+
if [[ "${WORK_HOME:-.}" == /* && "${WORK_HOME:-.}" != "${WORK_ROOT}" ]]; then
137+
WORK_HOME_TRANSFORMS+=(--transform="s|^${ISSUE_TARGET}_${ISSUE_TAG}${WORK_HOME}/|${ISSUE_TARGET}_${ISSUE_TAG}/|S")
138+
fi
125139
tar --use-compress-program=${COMPRESS} \
126140
--ignore-failed-read -chf ${TAR_NAME} \
127141
--transform="s|^|${ISSUE_TARGET}_${ISSUE_TAG}/|S" \
128142
--transform="s|^${ISSUE_TARGET}_${ISSUE_TAG}${FLOW_HOME}/|${ISSUE_TARGET}_${ISSUE_TAG}/|S" \
143+
"${WORK_HOME_TRANSFORMS[@]}" \
129144
$DESIGN_PLATFORM_FILES \
130145
$LOG_DIR \
131146
$OBJECTS_DIR \

0 commit comments

Comments
 (0)