Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,8 @@ pkg_tar(
include_runfiles = True,
package_file_name = "openroad.tar",
)

alias(
name = "setup-orfs",
actual = "//etc:setup-orfs",
)
30 changes: 30 additions & 0 deletions docs/user/Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,36 @@ The install process will install the binary "openroad" and the runfile directory

See [Bazel](Bazel.md) for more details on testing, profiling and build configurations.

### Setup ORFS flow dependencies

When using Bazel to build OpenROAD, the remaining ORFS flow dependencies
(Yosys, eqy, sby, KLayout, etc.) can be installed with a single command:

bazelisk run //:setup-orfs

If system packages are missing (compilers, dev libraries), the command
prints the exact `sudo` command to run and exits. This design is
intentional:

- The user sees exactly what will be installed with root privileges
before it happens — no silent modifications to `/usr/local` or system
directories.
- In educational and corporate environments, `sudo` is often controlled
by IT policy. Printing the command lets the user hand it off to an
administrator or request approval.
- Running `sudo` separately benefits from the system's apt cache,
so repeated runs are fast.
- User-level tools (Yosys, eqy, sby) are built and installed into the
project's `dependencies/` directory with user permissions only.
Comment on lines +62 to +63

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The term "project's" could be ambiguous here. Since this documentation is in the OpenROAD repository, a user might think it refers to a dependencies/ directory within the OpenROAD project structure. To improve clarity, I suggest specifying that this directory is at the root of the OpenROAD-flow-scripts repository.

Suggested change
- User-level tools (Yosys, eqy, sby) are built and installed into the
project's `dependencies/` directory with user permissions only.
- User-level tools (Yosys, eqy, sby) are built and installed into the
`dependencies/` directory of the `OpenROAD-flow-scripts` checkout with user permissions only.


After installing system packages, re-run `bazelisk run //:setup-orfs` to
complete the user-level setup.

This sets up the minimum tooling that Bazel does not yet provide. Over
time, more of these tools may be built and managed by Bazel directly,
but that is an implementation detail — `bazelisk run //:setup-orfs` will
remain the single entry point for developers.

## Build with Prebuilt Binaries

Courtesy of [Precision Innovations](https://precisioninno.com/), there are prebuilt binaries
Expand Down
7 changes: 7 additions & 0 deletions etc/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

package(features = ["layering_check"])

Expand All @@ -10,3 +11,9 @@ py_binary(
main = "file_to_string.py",
visibility = ["//visibility:public"],
)

sh_binary(
name = "setup-orfs",
srcs = ["setup_orfs_bazel.sh"],
visibility = ["//:__pkg__"],
)
73 changes: 73 additions & 0 deletions etc/setup_orfs_bazel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
#
# Setup ORFS dependencies for developers using Bazel for OpenROAD.
#
# Invoked via: bazelisk run //:setup-orfs
# (from the tools/OpenROAD directory)
#
# This script:
# 1. Checks if system packages are installed
# 2. If not, prints the sudo command to run and exits
# 3. If yes, builds Yosys/eqy/sby and installs pip packages with
# user permissions into $ORFS_DIR/dependencies
#
# Shares code with ORFS etc/DependencyInstaller.sh via the -bazel flag.

set -euo pipefail

OR_DIR="${BUILD_WORKSPACE_DIRECTORY:?Must be run via bazelisk run}"

# Navigate from tools/OpenROAD to the ORFS root
ORFS_DIR="$(cd "${OR_DIR}/../.." && pwd)"

if [[ ! -f "${ORFS_DIR}/etc/DependencyInstaller.sh" ]]; then
echo "ERROR: Cannot find ORFS root at ${ORFS_DIR}"
echo "This script expects OpenROAD to be at tools/OpenROAD within ORFS."
exit 1
fi

cd "${ORFS_DIR}"

# Check for key system packages needed to build Yosys and run the flow.
# These are installed by: sudo ./etc/DependencyInstaller.sh -base -bazel
missing=()
for cmd in gcc g++ bison flex pkg-config tclsh python3; do
if ! command -v "$cmd" &>/dev/null; then
missing+=("$cmd")
fi
done

# Also check for key dev libraries via pkg-config
for lib in tcl libffi zlib; do
if ! pkg-config --exists "$lib" 2>/dev/null; then
missing+=("$lib (dev)")
fi
done

if [[ ${#missing[@]} -gt 0 ]]; then
echo "Missing system dependencies: ${missing[*]}"
echo ""
echo "Run the following command first to install system packages:"
echo ""
echo " sudo ${ORFS_DIR}/etc/DependencyInstaller.sh -base -bazel"
echo ""
exit 1
fi

PREFIX="${ORFS_DIR}/dependencies"

echo "Installing ORFS flow dependencies into ${PREFIX}"
echo ""

# Build Yosys/eqy/sby using the shared DependencyInstaller.sh with -bazel.
# The -common flag triggers the Yosys/eqy/sby build (not the full OpenROAD
# dependency chain).
"${ORFS_DIR}/etc/DependencyInstaller.sh" -common -bazel "-prefix=${PREFIX}"

echo ""
echo "ORFS flow dependencies installed to ${PREFIX}"
echo ""
echo "To use, source the environment or add to PATH:"
echo ""
echo " export PATH=${PREFIX}/bin:\$PATH"
echo ""
Loading