Skip to content

fix: bazel manpage compilation#10729

Open
luarss wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
luarss:fix-bazel-manpage
Open

fix: bazel manpage compilation#10729
luarss wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
luarss:fix-bazel-manpage

Conversation

@luarss

@luarss luarss commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • src/OpenRoad.cc: Check BUILD_WORKSPACE_DIRECTORY in getDocsPath() for bazel run case
    (ifdef BAZEL_BUILD).
  • packaging/BUILD.bazel: Add //docs:man_pages to install data deps.
  • bazel/install.sh: Copy cat/ and html/ to $DEST_DIR/share/openroad/man/.

Type of Change

  • Bug fix

Impact

[How does this change the tool's behavior?]

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have included tests to prevent regressions.
  • I have signed my commits (DCO).

Related Issues

fixes #10640

Signed-off-by: Jack Luar <39641663+luarss@users.noreply.github.com>
@luarss luarss requested a review from a team as a code owner June 21, 2026 12:15
@luarss luarss requested a review from eder-matheus June 21, 2026 12:15

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

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.

Code Review

This pull request adds support for installing and locating generated man pages in Bazel builds. Specifically, it updates bazel/install.sh and packaging/BUILD.bazel to copy man pages to the installation directory, and modifies src/OpenRoad.cc to look for them in bazel-bin/docs when running via Bazel. The review feedback suggests dereferencing symlinks using cp -rfL and cleaning up stale directories during installation, as well as using the non-throwing overload of std::filesystem::is_directory to prevent potential exceptions.

Comment thread bazel/install.sh
Comment on lines +66 to +75
if [ -n "$MAN_CAT_SRC" ] && [ -d "$MAN_CAT_SRC" ]; then
MAN_DIR="$ABS_DEST/share/openroad/man"
mkdir -p "$MAN_DIR"
cp -rf "$MAN_CAT_SRC" "$MAN_DIR/"
MAN_HTML_SRC="$(rlocation openroad/docs/html 2>/dev/null || true)"
if [ -n "$MAN_HTML_SRC" ] && [ -d "$MAN_HTML_SRC" ]; then
cp -rf "$MAN_HTML_SRC" "$MAN_DIR/"
fi
echo "OpenROAD man pages installed to $MAN_DIR"
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.

high

When copying directories from Bazel's runfiles, the source files are typically symlinks. Using cp -rf without dereferencing (-L) will copy these symlinks as-is, resulting in broken symlinks in the final installation directory. Additionally, if a previous installation exists, stale man pages are not cleaned up.

To resolve these issues, clean up the target directories before copying and use cp -rfL to dereference the symlinks.

Suggested change
if [ -n "$MAN_CAT_SRC" ] && [ -d "$MAN_CAT_SRC" ]; then
MAN_DIR="$ABS_DEST/share/openroad/man"
mkdir -p "$MAN_DIR"
cp -rf "$MAN_CAT_SRC" "$MAN_DIR/"
MAN_HTML_SRC="$(rlocation openroad/docs/html 2>/dev/null || true)"
if [ -n "$MAN_HTML_SRC" ] && [ -d "$MAN_HTML_SRC" ]; then
cp -rf "$MAN_HTML_SRC" "$MAN_DIR/"
fi
echo "OpenROAD man pages installed to $MAN_DIR"
fi
if [ -n "$MAN_CAT_SRC" ] && [ -d "$MAN_CAT_SRC" ]; then
MAN_DIR="$ABS_DEST/share/openroad/man"
mkdir -p "$MAN_DIR"
rm -rf "$MAN_DIR/cat"
cp -rfL "$MAN_CAT_SRC" "$MAN_DIR/"
MAN_HTML_SRC="$(rlocation openroad/docs/html 2>/dev/null || true)"
if [ -n "$MAN_HTML_SRC" ] && [ -d "$MAN_HTML_SRC" ]; then
rm -rf "$MAN_DIR/html"
cp -rfL "$MAN_HTML_SRC" "$MAN_DIR/"
fi
echo "OpenROAD man pages installed to $MAN_DIR"
fi

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@luarss Is this a real concern from gemini?

Comment thread src/OpenRoad.cc
Comment on lines +739 to +741
if (std::filesystem::is_directory(docs_path)) {
return docs_path;
}

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

std::filesystem::is_directory can throw a std::filesystem::filesystem_error exception if the path is inaccessible, contains a loop of symlinks, or encounters other OS-level errors. To ensure robust error handling and prevent potential crashes, use the non-throwing overload that accepts an std::error_code parameter.

    std::error_code ec;
    if (std::filesystem::is_directory(docs_path, ec)) {
      return docs_path;
    }

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.

man: bazel build not working

2 participants