Skip to content

Commit f40d2f3

Browse files
authored
Merge pull request #4088 from The-OpenROAD-Project-staging/docker-verific
docker: add optioin for verific
2 parents 738bc90 + 71f4f53 commit f40d2f3

3 files changed

Lines changed: 79 additions & 54 deletions

File tree

‎build_openroad.sh‎

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ OPENROAD_APP_ARGS=""
2929
DOCKER_OS_NAME="ubuntu22.04"
3030
PROC=-1
3131

32-
VERIFIC_COMPONENTS='database util containers pct hier_tree verilog'
3332
WITH_VERIFIC=0
34-
VERIFIC_DIR=""
33+
VERIFIC_SRC=""
34+
VERIFIC_COMPONENTS='database util containers pct hier_tree verilog'
35+
VERIFIC_ARGS=" VERIFIC_COMPONENTS='${VERIFIC_COMPONENTS}'"
36+
VERIFIC_ARGS+=" ENABLE_VERIFIC=1 ENABLE_VERIFIC_VHDL=0 VERIFIC_DIR=verific"
3537

3638
function usage() {
3739
cat << EOF
@@ -145,20 +147,17 @@ while (( "$#" )); do
145147
YOSYS_OVERWRITE_ARGS=1
146148
;;
147149
--yosys-args)
148-
YOSYS_USER_ARGS="$2"
150+
YOSYS_USER_ARGS+="$2"
149151
shift
150152
;;
151153
--with-verific)
152-
YOSYS_USER_ARGS+=" ENABLE_VERIFIC=1"
153-
YOSYS_USER_ARGS+=" ENABLE_VERIFIC_VHDL=0"
154-
YOSYS_USER_ARGS+=" VERIFIC_COMPONENTS='${VERIFIC_COMPONENTS}'"
155-
VERIFIC_DIR=${2}
156-
if [ ! -d "${VERIFIC_DIR}" ]; then
157-
echo "[ERROR] Verific path '${VERIFIC_DIR}' does not exist." >&2
154+
WITH_VERIFIC=1
155+
VERIFIC_SRC=${2}
156+
if [ ! -d "${VERIFIC_SRC}" ]; then
157+
echo "[ERROR] Verific path '${VERIFIC_SRC}' does not exist." >&2
158158
exit 1
159159
fi
160-
YOSYS_USER_ARGS+=" VERIFIC_DIR=${VERIFIC_DIR}"
161-
WITH_VERIFIC=1
160+
YOSYS_USER_ARGS+="${VERIFIC_ARGS}"
162161
shift
163162
;;
164163
--openroad-args-overwrite)
@@ -238,8 +237,14 @@ __docker_build()
238237
cp .dockerignore{,.bak}
239238
sed -i '/flow\/platforms/d' .dockerignore
240239
fi
240+
options=""
241+
if [ -n "${WITH_VERIFIC}" ]; then
242+
cp -r "${VERIFIC_SRC}" tools/verific
243+
options="-buildArgs=--build-arg verificPath=tools/verific"
244+
fi
241245
./etc/DockerHelper.sh create -target=dev -os="${DOCKER_OS_NAME}" -threads="${PROC}"
242-
./etc/DockerHelper.sh create -target=builder -os="${DOCKER_OS_NAME}" -threads="${PROC}"
246+
./etc/DockerHelper.sh create -target=builder -os="${DOCKER_OS_NAME}" -threads="${PROC}" "${options}"
247+
rm -rf tools/verific
243248
if [ ! -z "${DOCKER_COPY_PLATFORMS+x}" ]; then
244249
mv .dockerignore{.bak,}
245250
fi
@@ -248,56 +253,56 @@ __docker_build()
248253
__local_build()
249254
{
250255
if [[ "$OSTYPE" == "darwin"* ]]; then
251-
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$(brew --prefix tcl-tk)/bin:$PATH"
252-
export CMAKE_PREFIX_PATH=$(brew --prefix or-tools)
256+
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$(brew --prefix tcl-tk)/bin:$PATH"
257+
export CMAKE_PREFIX_PATH=$(brew --prefix or-tools)
253258
fi
254259
if [[ -f "/opt/rh/rh-python38/enable" ]]; then
255-
set +u
256-
source /opt/rh/rh-python38/enable
257-
set -u
260+
set +u
261+
source /opt/rh/rh-python38/enable
262+
set -u
258263
fi
259264
if [[ -f "/opt/rh/devtoolset-8/enable" ]]; then
260-
# the scl script has unbound variables
261-
set +u
262-
source /opt/rh/devtoolset-8/enable
263-
set -u
265+
# the scl script has unbound variables
266+
set +u
267+
source /opt/rh/devtoolset-8/enable
268+
set -u
264269
fi
265270

266271
if [ -z "${SKIP_OPENROAD+x}" ]; then
267-
echo "[INFO FLW-0018] Compiling OpenROAD."
268-
if [ -f "${DIR}/openroad_deps_prefixes.txt" ]; then
269-
DEPS_PREFIX_ARG="${DIR}/openroad_deps_prefixes.txt"
270-
elif [ -f "${DIR}/tools/OpenROAD/etc/openroad_deps_prefixes.txt" ]; then
271-
DEPS_PREFIX_ARG="${DIR}/tools/OpenROAD/etc/openroad_deps_prefixes.txt"
272-
elif [ -f /etc/openroad_deps_prefixes.txt ]; then
273-
DEPS_PREFIX_ARG="/etc/openroad_deps_prefixes.txt"
274-
else
275-
DEPS_PREFIX_ARG=""
276-
fi
277-
if [[ -n "${DEPS_PREFIX_ARG}" ]]; then
278-
echo "[INFO FLW-0029] Found OpenROAD dependencies prefixes file: '${DEPS_PREFIX_ARG}'."
279-
DEPS_PREFIX_ARG="-deps-prefixes-file=${DEPS_PREFIX_ARG}"
280-
fi
281-
eval ${NICE} ./tools/OpenROAD/etc/Build.sh \
282-
-dir="$DIR/tools/OpenROAD/build" \
283-
-threads=${PROC} \
284-
-cmake=\'${OPENROAD_APP_ARGS}\' \
285-
${DEPS_PREFIX_ARG}
286-
${NICE} cmake --build tools/OpenROAD/build --target install -j "${PROC}"
272+
echo "[INFO FLW-0018] Compiling OpenROAD."
273+
if [ -f "${DIR}/openroad_deps_prefixes.txt" ]; then
274+
DEPS_PREFIX_ARG="${DIR}/openroad_deps_prefixes.txt"
275+
elif [ -f "${DIR}/tools/OpenROAD/etc/openroad_deps_prefixes.txt" ]; then
276+
DEPS_PREFIX_ARG="${DIR}/tools/OpenROAD/etc/openroad_deps_prefixes.txt"
277+
elif [ -f /etc/openroad_deps_prefixes.txt ]; then
278+
DEPS_PREFIX_ARG="/etc/openroad_deps_prefixes.txt"
279+
else
280+
DEPS_PREFIX_ARG=""
281+
fi
282+
if [[ -n "${DEPS_PREFIX_ARG}" ]]; then
283+
echo "[INFO FLW-0029] Found OpenROAD dependencies prefixes file: '${DEPS_PREFIX_ARG}'."
284+
DEPS_PREFIX_ARG="-deps-prefixes-file=${DEPS_PREFIX_ARG}"
285+
fi
286+
eval ${NICE} ./tools/OpenROAD/etc/Build.sh \
287+
-dir="$DIR/tools/OpenROAD/build" \
288+
-threads=${PROC} \
289+
-cmake=\'${OPENROAD_APP_ARGS}\' \
290+
${DEPS_PREFIX_ARG}
291+
${NICE} cmake --build tools/OpenROAD/build --target install -j "${PROC}"
287292
fi
288293

289294
YOSYS_ABC_PATH=tools/yosys/abc
290295
if [[ -d "${YOSYS_ABC_PATH}/.git" ]]; then
291-
# update indexes to make sure git diff-index uses correct data
292-
git --work-tree=${YOSYS_ABC_PATH} --git-dir=${YOSYS_ABC_PATH}/.git update-index --refresh
296+
# update indexes to make sure git diff-index uses correct data
297+
git --work-tree=${YOSYS_ABC_PATH} --git-dir=${YOSYS_ABC_PATH}/.git update-index --refresh
293298
fi
294299

295300
if [ ${WITH_VERIFIC} -eq 1 ]; then
296301
echo "[INFO FLW-0031] Compiling Verific components."
297-
cp -r "${VERIFIC_DIR}" verific
302+
cp -r "${VERIFIC_SRC}" tools/yosys/verific
298303
for c in ${VERIFIC_COMPONENTS}; do
299-
make -j -C "verific/${c}" clean
300-
make -j -C "verific/${c}"
304+
make -j -C "tools/yosys/verific/${c}" clean
305+
make -j -C "tools/yosys/verific/${c}"
301306
done
302307
fi
303308

@@ -322,7 +327,7 @@ __local_build()
322327

323328
if [ ${WITH_VERIFIC} -eq 1 ]; then
324329
echo "[INFO FLW-0032] Cleaning up Verific components."
325-
rm -rf verific
330+
rm -rf tools/yosys/verific
326331
fi
327332
}
328333

‎docker/Dockerfile.builder‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,25 @@ ENV PATH="/usr/local/bin/wrapped-cc:$PATH"
3131
COPY --link tools tools
3232
ARG numThreads=$(nproc)
3333
ARG openroadVersion=NotSet
34+
ARG verificPath=""
3435

35-
RUN echo "" > tools/yosys/abc/.gitcommit && \
36-
./build_openroad.sh --no_init --local --threads ${numThreads} --openroad-args -DOPENROAD_VERSION=${openroadVersion}
36+
RUN <<EOF
37+
set -e
38+
echo "" > tools/yosys/abc/.gitcommit
39+
if [ -n "${verificPath}" ]; then
40+
verificArgs="--with-verific ${verificPath}"
41+
else
42+
verificArgs=""
43+
fi
44+
./build_openroad.sh --no_init \
45+
--local \
46+
--threads ${numThreads} \
47+
--openroad-args -DOPENROAD_VERSION=${openroadVersion} \
48+
${verificArgs}
49+
if [ -n "${verificPath}" ]; then
50+
rm -rf "${verificPath}"
51+
fi
52+
EOF
3753

3854
FROM orfs-base
3955

‎etc/DockerHelper.sh‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ usage: $0 [CMD] [OPTIONS]
3535
-dry-run Do not push images to the repository
3636
-push-latest Push the latest image to the repository
3737
-no-constant-build-dir Do not use constant build directory
38+
-buildArgs=<ARGS> Additional build arguments to pass to docker buildx
3839
-h -help Show this message and exits
3940
4041
EOF
@@ -64,7 +65,7 @@ _setup() {
6465
"builder" | "master")
6566
fromImage="${FROM_IMAGE_OVERRIDE:-"${org}/flow-${os}-dev"}:${imageTag}"
6667
context="."
67-
buildArgs="--build-arg numThreads=${numThreads}"
68+
buildArgs+=" --build-arg numThreads=${numThreads}"
6869
orVersion=$(git -C tools/OpenROAD describe --tags)
6970
echo "OpenROAD version: ${orVersion}"
7071
buildArgs+=" --build-arg openroadVersion=${orVersion}"
@@ -76,15 +77,15 @@ _setup() {
7677
local yosys_ver
7778
yosys_ver=v$(grep 'yosys_ver =' tools/yosys/docs/source/conf.py | awk -F'"' '{print $2}')
7879
options+=" -yosys-ver=${yosys_ver}"
79-
buildArgs="--build-arg \"options=${options}\" ${noConstantBuildDir}"
80+
buildArgs+=" --build-arg \"options=${options}\" ${noConstantBuildDir}"
8081
;;
8182
*)
8283
echo "Target ${target} not found" >&2
8384
_help
8485
;;
8586
esac
8687
imagePath="${imageName}:${imageTag}"
87-
buildArgs="--build-arg fromImage=${fromImage} ${buildArgs}"
88+
buildArgs+=" ${buildArgs} --build-arg fromImage=${fromImage}"
8889
file="docker/Dockerfile.${target}"
8990
}
9091

@@ -191,7 +192,7 @@ os="ubuntu22.04"
191192
target="dev"
192193
numThreads="-1"
193194
tag=""
194-
options=""
195+
buildArgs=""
195196
dryRun=0
196197
pushLatest=0
197198

@@ -201,7 +202,7 @@ while [ "$#" -gt 0 ]; do
201202
_help 0
202203
;;
203204
-ci )
204-
options="-ci"
205+
options+=" -ci"
205206
;;
206207
-dry-run )
207208
dryRun=1
@@ -227,6 +228,9 @@ while [ "$#" -gt 0 ]; do
227228
-tag=* )
228229
tag="${1#*=}"
229230
;;
231+
-buildArgs=* )
232+
buildArgs="${1#*=}"
233+
;;
230234
-no-constant-build-dir )
231235
noConstantBuildDir="--build-arg constantBuildDir= "
232236
;;

0 commit comments

Comments
 (0)