Skip to content

Add -bazel and -bazel-dev options to DependencyInstaller and Build scripts#9762

Merged
maliberty merged 4 commits into
The-OpenROAD-Project:masterfrom
alokkumardalei-wq:feature/bazel-options-dependency-installer
May 1, 2026
Merged

Add -bazel and -bazel-dev options to DependencyInstaller and Build scripts#9762
maliberty merged 4 commits into
The-OpenROAD-Project:masterfrom
alokkumardalei-wq:feature/bazel-options-dependency-installer

Conversation

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor

@alokkumardalei-wq alokkumardalei-wq commented Mar 14, 2026

What does this PR solves?

Fixes #9594

Adds Bazel setup options to DependencyInstaller.sh and Build.sh to make it easier for developers to get started with the Bazel build.

Changes
DependencyInstaller.sh:

  • bazel — installs bazelisk (so the correct Bazel version is picked up from .bazelversion automatically) + xcb libs needed for GUI support
  • bazel-dev — installs buildifier for formatting BUILD/.bzl files
    Both flags work standalone or combined with -all/-base/-common
    Build.sh:
  • bazel — use Bazel instead of CMake to build; prefers bazelisk if available

Testing/Verification:

etc/DependencyInstaller.sh -bazel

Expected output:

[INFO] Checking Bazel (via bazelisk)
[INFO] Downloading bazelisk...... ✔
[INFO] Installing bazelisk...... ✔
[INFO] Installing xcb libraries for GUI support...... ✔

[INFO] Installation Summary
====================================================================================
Package              | System Version       | Required Version     | Status
-------------------- | -------------------- | -------------------- | ----------
Bazel                | none                 | latest               | installed
==================================================================================
etc/DependencyInstaller.sh -bazel-dev

Expected output:

[INFO] Checking Bazel dev tools (buildifier)
[INFO] Downloading buildifier...... ✔
[INFO] Installing buildifier...... ✔

[INFO] Installation Summary
====================================================================================
Package              | System Version       | Required Version     | Status
-------------------- | -------------------- | -------------------- | ----------
buildifier           | none                 | latest               | installed
====================================================================================

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Bazel support for building and dependency installation. The changes to Build.sh and DependencyInstaller.sh add new flags (-bazel, -bazel-dev) to use Bazel. My review focuses on improving the portability and robustness of these new scripts. I've suggested adding support for macOS in the dependency installer and improving shell script practices by removing an unnecessary eval. I also noted a point for future improvement regarding package manager support for GUI dependencies.

Comment on lines +769 to +799
_install_bazel() {
local bazel_prefix=${PREFIX:-"/usr/local"}
log "Checking Bazel (via bazelisk)"
if _command_exists "bazelisk"; then
log "bazelisk already installed, skipping."
INSTALL_SUMMARY+=("Bazel: system=found, required=any, status=skipped")
return
fi
local arch
arch=$(uname -m)
local bazelisk_arch="amd64"
if [[ "${arch}" == "aarch64" ]]; then
bazelisk_arch="arm64"
fi
(
cd "${BASE_DIR}"
_execute "Downloading bazelisk..." curl -Lo bazelisk \
"https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-${bazelisk_arch}"
chmod +x bazelisk
_execute "Installing bazelisk..." mv bazelisk "${bazel_prefix}/bin/bazelisk"
)
# Install xcb libraries needed for GUI support with Bazel builds
if _command_exists "apt-get"; then
_execute "Installing xcb libraries for GUI support..." \
apt-get -y install --no-install-recommends \
libxcb1-dev libxcb-util-dev libxcb-icccm4-dev libxcb-image0-dev \
libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev \
libxcb-xinerama0-dev libxcb-xkb-dev
fi
INSTALL_SUMMARY+=("Bazel: system=none, required=latest, status=installed")
}
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.

high

This function currently only supports installing bazelisk on Linux. On macOS, it will fail because it tries to download a Linux binary. Please add support for macOS, for example by using Homebrew (brew install bazelisk).

_install_bazel() {
    local bazel_prefix=${PREFIX:-/usr/local}
    log "Checking Bazel (via bazelisk)"
    if _command_exists "bazelisk"; then
        log "bazelisk already installed, skipping."
        INSTALL_SUMMARY+=("Bazel: system=found, required=any, status=skipped")
        return
    fi

    if [[ "$(uname -s)" == "Darwin" ]]; then
        if ! _command_exists "brew"; then
            error "Homebrew not found, which is required to install bazelisk on macOS."
        fi
        _execute "Installing bazelisk..." brew install bazelisk
    else
        local arch
        arch=$(uname -m)
        local bazelisk_arch="amd64"
        if [[ "${arch}" == "aarch64" ]]; then
            bazelisk_arch="arm64"
        fi
        (
            cd "${BASE_DIR}"
            _execute "Downloading bazelisk..." curl -Lo bazelisk \
                "https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-${bazelisk_arch}"
            chmod +x bazelisk
            _execute "Installing bazelisk..." mv bazelisk "${bazel_prefix}/bin/bazelisk"
        )
        # Install xcb libraries needed for GUI support with Bazel builds
        if _command_exists "apt-get"; then
            _execute "Installing xcb libraries for GUI support..." \
                apt-get -y install --no-install-recommends \
                libxcb1-dev libxcb-util-dev libxcb-icccm4-dev libxcb-image0-dev \
                libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev \
                libxcb-xinerama0-dev libxcb-xkb-dev
        fi
    fi
    INSTALL_SUMMARY+=("Bazel: system=none, required=latest, status=installed")
}

Comment on lines +804 to +826
_install_bazel_dev() {
local bazel_prefix=${PREFIX:-"/usr/local"}
log "Checking Bazel dev tools (buildifier)"
if _command_exists "buildifier"; then
log "buildifier already installed, skipping."
INSTALL_SUMMARY+=("buildifier: system=found, required=any, status=skipped")
return
fi
local arch
arch=$(uname -m)
local buildifier_arch="amd64"
if [[ "${arch}" == "aarch64" ]]; then
buildifier_arch="arm64"
fi
(
cd "${BASE_DIR}"
_execute "Downloading buildifier..." curl -Lo buildifier \
"https://github.com/bazelbuild/buildtools/releases/latest/download/buildifier-linux-${buildifier_arch}"
chmod +x buildifier
_execute "Installing buildifier..." mv buildifier "${bazel_prefix}/bin/buildifier"
)
INSTALL_SUMMARY+=("buildifier: system=none, required=latest, status=installed")
}
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.

high

Similar to _install_bazel, this function only supports Linux. Please add support for macOS. buildifier can be installed with Homebrew (brew install buildifier).

_install_bazel_dev() {
    local bazel_prefix=${PREFIX:-/usr/local}
    log "Checking Bazel dev tools (buildifier)"
    if _command_exists "buildifier"; then
        log "buildifier already installed, skipping."
        INSTALL_SUMMARY+=("buildifier: system=found, required=any, status=skipped")
        return
    fi

    if [[ "$(uname -s)" == "Darwin" ]]; then
        if ! _command_exists "brew"; then
            error "Homebrew not found, which is required to install buildifier on macOS."
        fi
        _execute "Installing buildifier..." brew install buildifier
    else
        local arch
        arch=$(uname -m)
        local buildifier_arch="amd64"
        if [[ "${arch}" == "aarch64" ]]; then
            buildifier_arch="arm64"
        fi
        (
            cd "${BASE_DIR}"
            _execute "Downloading buildifier..." curl -Lo buildifier \
                "https://github.com/bazelbuild/buildtools/releases/latest/download/buildifier-linux-${buildifier_arch}"
            chmod +x buildifier
            _execute "Installing buildifier..." mv buildifier "${bazel_prefix}/bin/buildifier"
        )
    fi
    INSTALL_SUMMARY+=("buildifier: system=none, required=latest, status=installed")
}

Comment thread etc/Build.sh Outdated
if command -v bazelisk &> /dev/null; then
bazel_cmd="bazelisk"
fi
eval "${bazel_cmd}" build //:openroad
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

Using eval is unnecessary here and can be a security risk if the variable was not tightly controlled. You can directly execute the command stored in bazel_cmd.

Suggested change
eval "${bazel_cmd}" build //:openroad
"${bazel_cmd}" build //:openroad

Comment thread etc/DependencyInstaller.sh Outdated
Comment on lines +791 to +797
if _command_exists "apt-get"; then
_execute "Installing xcb libraries for GUI support..." \
apt-get -y install --no-install-recommends \
libxcb1-dev libxcb-util-dev libxcb-icccm4-dev libxcb-image0-dev \
libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev \
libxcb-xinerama0-dev libxcb-xkb-dev
fi
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 installation of xcb libraries for GUI support is only implemented for apt-based systems. To improve portability, consider adding support for other package managers like yum for RHEL-based systems.

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-options-dependency-installer branch from 7739166 to c2d59d2 Compare March 14, 2026 12:04
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

alokkumardalei-wq commented Mar 14, 2026

Hello @maliberty the https://jenkins.openroad.tools/job/OpenROAD-Public/job/PR-9762-merge/4/display/redirect is failing at build 4 as I checked but has passed in build 1, 2 and 3 . I have no idea why is it so . Could you please look into this when you have time.

Thank you.

Comment thread etc/Build.sh Outdated
if command -v bazelisk &> /dev/null; then
bazel_cmd="bazelisk"
fi
"${bazel_cmd}" build //:openroad
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.

this should honor the GUI flag and numThreads, and should build release or opt

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 15, 2026

I think this is a bad idea. We want to ultimately phase out DependencyInstaller and install only bazel and let it pull in dependencies. DependencyInstaller should be kept as is for the CMake use-case, IMO.

@gadfort
Copy link
Copy Markdown
Contributor

gadfort commented Mar 16, 2026

@oharboe I think this will provide for a smoother transition and if bazel can handle it all then maybe it can be retired in the future. (although we still need to install bazel/bazelisk and buildifier, so something is needed to get folks onboarded quickly and easily).

cd "${BASE_DIR}"
_execute "Downloading bazelisk..." curl -Lo bazelisk \
"https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-${bazelisk_arch}"
chmod +x bazelisk
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.

need to verify the checksum _verify_checksum

cd "${BASE_DIR}"
_execute "Downloading buildifier..." curl -Lo buildifier \
"https://github.com/bazelbuild/buildtools/releases/latest/download/buildifier-linux-${buildifier_arch}"
chmod +x buildifier
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.

need to verify the checksum _verify_checksum

Comment thread etc/DependencyInstaller.sh Outdated
error "You must use one of: -all, -base, -common, -bazel, or -bazel-dev."
fi

if [[ "${INSTALL_BAZEL}" == "yes" ]]; then
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.

probably should include bazel if doing -bazel-dev
"|| ${INSTALL_BAZEL_DEV}" == "yes"

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

Being a user of bazel, what I would be more interested in is:

  1. install bazelisk using non-ORFS bazel idiomatic instrunctions. use the bazel up to date insructions
  2. add a bazelisk run //:build-deps that builds ORFS dependencies to complement //:install

This would probably require framework inverting DependencyInstaller so that it calls one decomposed build per tool.

Claude should do that automatically.

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

as for dev dependencies and linters and such, I think a better path is to add e.g. lint targets and let those lint targets handle dependencies in a bazel idiomatic fashion #9734

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

in that same vein check docs with bazel #9733

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

I think that this PR rightly identifies some real pain-points that I have myself.

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

@alokkumardalei-wq @gadfort Thougths?

The two PRs below build on the findings in this PR and should addresses the concerns:

The-OpenROAD-Project/OpenROAD-flow-scripts#4003

#9772

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

@alokkumardalei-wq Did you see my comments? #9762 (comment)

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-options-dependency-installer branch from 83b0442 to d853468 Compare March 16, 2026 10:25
@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! I have updated the PR to address @gadfort 's review comments: I added checksum verification for the tool downloads, made -bazel-dev automatically include the base -bazel tools, and updated Build.sh to respect the -no-gui and -threads flags while defaulting to -c opt."
If anything else I can improve please let me know.
Thank you.

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

alokkumardalei-wq commented Mar 16, 2026

Thanks @oharboe for your suggestions, I see the architectural point about keeping DependencyInstaller.sh purely for CMake and moving Bazel dependency management entirely into bazel run targets (as proposed in PR #9772). Since @gadfort suggested this PR could serve as a useful transition step, I am open to whatever the core maintainers decide: either treating this as a temporary bridge while the Bazel-native targets mature, or closing this in favor of PR #9772.

Thank you!

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

@alokkumardalei-wq Please also read The-OpenROAD-Project/OpenROAD-flow-scripts#4003 and let me know what your thoughts are this PR in light of that PR getting accepted.

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Thanks @oharboe for linking that! I just reviewed OpenROAD-flow-scripts#4003. Yes, adding bazelisk run //:install to ORFS directly addresses the original paint-point I raised in #9594. It's a much cleaner, Bazel-native approach than trying to overload DependencyInstaller.sh and Build.sh.
Once ORFS#4003 is merged, the onboarding experience for Bazel users will be much smoother. If everyone is in agreement, I am happy to close this PR in favor of your approach in ORFS#4003 and #9772.

Thank you!

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented Mar 16, 2026

@alokkumardalei-wq Is #9772 needed? I thought we were statically linked. Please advice if it should be re-opened with some specific instructions on what exactly it should test for.

@gadfort
Copy link
Copy Markdown
Contributor

gadfort commented Mar 16, 2026

@alokkumardalei-wq @oharboe please keep in mind that not all users are using ORFS and we should not expecting that of users and developers.

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Hello @maliberty Thanks for the feedback. I have resolved that as per suggestion please have a look when you have time and I would be happy to address any further feedback.

You can find this in this commit: 0b2a66e

Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

…ld scripts

Fixes The-OpenROAD-Project#9594. Adds Bazel setup options to make it easier for developers
to get started with the Bazel build.

DependencyInstaller.sh:
  -bazel     — installs bazelisk + xcb libs for GUI support
  -bazel-dev — installs buildifier for formatting BUILD/.bzl files
               (implies -bazel)

Both flags work standalone or combined with -all/-base/-common.
Supports Linux (apt/yum) and macOS (Homebrew). Downloads are
verified with _verify_checksum.

Build.sh:
  -bazel — builds with Bazel instead of CMake, using bazelisk if
           available. Honors -no-gui (--//:platform=cli) and uses
           --config=opt with -j for thread count.

Also refactors cmakeOptions from a string to a Bash array to
safely handle quoted strings without eval, as suggested in review.

Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-options-dependency-installer branch from cc0ab79 to fce2187 Compare April 12, 2026 05:14
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Alok Kumar Dalei <alokkumardalei2@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Copy Markdown
Member

Errors still need fixing, eg

00:37:10  ./etc/Build.sh: line 358: isNinja: unbound variable

@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-options-dependency-installer branch from e8ea5ba to b135cc8 Compare April 27, 2026 03:37
The isNinja branch was never reachable (no code path sets it) and under
'set -euo pipefail' it terminated the script with 'isNinja: unbound
variable' at line 358 once master's removal of the ninja option (commit
4e494df) was merged in. Remove the dead block.

Reported by maliberty in The-OpenROAD-Project#9762.

Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-options-dependency-installer branch from b135cc8 to e89327a Compare April 27, 2026 03:42
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

alokkumardalei-wq commented Apr 27, 2026

Hello @maliberty fixed in e89327a ,dropped the dead isNinja block. It became unreachable when master removed the -ninja option in 4e494df; nothing was setting isNinja, so under set -euo pipefail fired the unbound-variable error. Build.sh now goes straight from the bazel branch to the cmake fallback.

Please have a look when you get time .

Thank you !

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Hello @maliberty ,all checks are passing now ,please have a look when you get time .
Happy to address any further feedback.

Thank you !

Comment thread etc/DependencyInstaller.sh Outdated
chmod +x bazelisk
_execute "Installing bazelisk..." mv bazelisk "${bazel_prefix}/bin/bazelisk"
)
# Install xcb libraries needed for GUI support with Bazel builds
Copy link
Copy Markdown
Member

@maliberty maliberty Apr 27, 2026

Choose a reason for hiding this comment

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

Skip if noGui=1

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

@maliberty done in 6464b7d , added a -no-gui flag to DependencyInstaller.sh that skips the xcb block in _install_bazel. Default behavior is unchanged (xcb still installs unless -no-gui is passed).

if [[ "${NO_GUI}" != "yes" ]]; then
    # Install xcb libraries needed for GUI support with Bazel builds
    if _command_exists "apt-get"; then
        ...
    elif _command_exists "yum"; then
        ...
    fi
fi

Kept the scope narrow to the xcb block per your comment. The Qt5 packages elsewhere in the script (_installCommonDev and per-distro blocks) have the same property but I didn't touch them,happy to extend -no-gui to gate those too if you'd like, in this PR or a follow-up.

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-options-dependency-installer branch from 6464b7d to be6ca9a Compare April 28, 2026 08:52
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

alokkumardalei-wq commented Apr 28, 2026

Hello @maliberty could you please have a look on failing ci https://github.com/The-OpenROAD-Project/OpenROAD/actions/runs/25043425809/job/73352197611?pr=9762 and this https://jenkins.openroad.tools/job/OpenROAD-Public/job/PR-9762-merge/53/display/redirect
These two shoeing the same error which I think unrelated to my code/PR and I think it is some flaky test failure , could you please check when you get time and if possible re-trigger these ci runners once again.

Thank you !

@maliberty
Copy link
Copy Markdown
Member

@gadfort approve or ?

@maliberty maliberty merged commit 533abfc into The-OpenROAD-Project:master May 1, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add bazel options to DependencyInstaller.sh

4 participants