Skip to content

bazel: build and package man pages as runfiles#9766

Open
alokkumardalei-wq wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
alokkumardalei-wq:feature/bazel-manpage
Open

bazel: build and package man pages as runfiles#9766
alokkumardalei-wq wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
alokkumardalei-wq:feature/bazel-manpage

Conversation

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor

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

What does this PR do?

Fixes #7117 — Bazel build now generates and packages man pages

The Bazel build was missing man pages for both the man command and the GUI help browser.

Added a man_pages Bazel rule (
man_pages.bzl
) that runs the existing docs Makefile to generate cat/ and html/ pages from the module READMEs. The output is packaged as runfiles alongside the openroad binary.

Updated getDocsPath() to check for the Bazel runfiles layout (.runfiles/openroad/docs/) before falling back to the installed path.

Verification/Testing

bazel build //docs:man_pages

Expected output:

INFO: Invocation ID: e5407d31-853c-4d14-ba5d-f6352d3f1eb0
INFO: Analyzed target //docs:man_pages (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //docs:man_pages up-to-date:
  bazel-bin/docs/cat
  bazel-bin/docs/html
INFO: Elapsed time: 147.810s, Critical Path: 0.24s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

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 a new Bazel rule to build and package man pages, making them available to the openroad binary as runfiles. This is a valuable addition that improves the build process. My review focuses on enhancing the robustness and maintainability of the new Bazel rule and improving the portability of the C++ code that locates the generated documentation at runtime.

Comment thread bazel/man_pages.bzl Outdated
Comment thread bazel/man_pages.bzl Outdated
Comment thread bazel/man_pages.bzl Outdated
Comment thread src/OpenRoad.cc Outdated
@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-manpage branch 2 times, most recently from abb37f2 to 4f974a0 Compare March 14, 2026 20:41
@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! 👍"

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@gadfort
Copy link
Copy Markdown
Collaborator

gadfort commented Mar 15, 2026

When I try this I get:

make: mkdir: No such file or directory
make: *** [Makefile:76: man/man1] Error 127
make: mkdir: No such file or directory
make: *** [Makefile:78: man/man2] Error 127
make: mkdir: No such file or directory
make: *** [Makefile:82: html/html1] Error 127
make: mkdir: No such file or directory
make: *** [Makefile:84: html/html2] Error 127
make: mkdir: No such file or directory
make: *** [Makefile:88: cat/cat1] Error 127
make: mkdir: No such file or directory
make: *** [Makefile:90: cat/cat2] Error 127
make: Target 'all' not remade because of errors.

and no files are created in the runfiles.

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Hello @gadfort I think this is due to PATH environment problem in Bazel's sandboxed execution on macOS. I have fixed that I want you to have look into this when you have time and happy to address further feedback.

Thank you!

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Hello @gadfort all checks are passing now ,please have a look onto this when you have time .
Thank you!

@gadfort
Copy link
Copy Markdown
Collaborator

gadfort commented Mar 17, 2026

It builds, but ord::get_docs_path is pointing to a directory that doesn't exist.

@github-actions
Copy link
Copy Markdown
Contributor

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

@alokkumardalei-wq alokkumardalei-wq force-pushed the feature/bazel-manpage branch 2 times, most recently from 0070f75 to 693980d Compare March 17, 2026 18:32
@github-actions
Copy link
Copy Markdown
Contributor

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

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Hello @gadfort,
You're absolutely right - I had the wrong repository name in the runfiles path. Fixed in commit d00e7866aa.
The code was looking for runfiles->Rlocation("openroad/docs") but the actual path is _main/docs because that's the Bazel repository name.

Please have a look onto this and happy to address any further feedback.

Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

Hello @maliberty and @gadfort thanks for your feedback and time, all checks are passing and I have addressed all your
feedback , please have a look when you have time . I would be happy to address any feedback further .

Thank you !

@maliberty
Copy link
Copy Markdown
Member

% bazel build //docs:man_pages
INFO: Invocation ID: aab259c6-219e-4d34-9239-d4c74732a020
WARNING: Target pattern parsing failed.
ERROR: Skipping '//docs:man_pages': no such package 'docs': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - docs
ERROR: no such package 'docs': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - docs
INFO: Elapsed time: 0.196s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

% bazel build //docs:man_pages
INFO: Invocation ID: aab259c6-219e-4d34-9239-d4c74732a020
WARNING: Target pattern parsing failed.
ERROR: Skipping '//docs:man_pages': no such package 'docs': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - docs
ERROR: no such package 'docs': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - docs
INFO: Elapsed time: 0.196s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

Hello , @maliberty now you can check the same , it is fixed docs/BUILD.bazel and bazel/man_pages.bzl are now included. It should build successfully now .

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

alokkumardalei-wq commented Apr 18, 2026

Hello @maliberty @gadfort , all checks are passing ,please have a look onto this when you get time.

Thank you !

@maliberty
Copy link
Copy Markdown
Member

/gemini review

@maliberty
Copy link
Copy Markdown
Member

@codex review

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 a new Bazel rule, man_pages, to automate the generation of man pages and HTML documentation from module READMEs, integrating with the existing documentation Makefile. It also updates the OpenRoad class to locate these documents within the Bazel runfiles directory and refactors runfiles management in regression tests. Review feedback focuses on improving the robustness of the shell commands within the Bazel rule—specifically by avoiding silent failures and handling empty output directories—and notes the fragility of hardcoding the workspace name in the runfiles path lookup.

Comment thread bazel/man_pages.bzl
cd docs

# Symlink module READMEs into md/man2/
bash src/scripts/link_readmes.sh 2>/dev/null || true
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

Masking errors with || true and redirecting stderr to /dev/null can lead to silent failures during the documentation generation process. If the script fails, the resulting man pages might be incomplete or incorrect. It is better to allow the script to fail the build so that issues can be identified and fixed.

Suggested change
bash src/scripts/link_readmes.sh 2>/dev/null || true
bash src/scripts/link_readmes.sh

Comment thread bazel/man_pages.bzl
Comment on lines +38 to +39
cp -r docs/cat/* {cat_out}/
cp -r docs/html/* {html_out}/
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 the * glob in the cp command will cause the shell to fail if the source directory is empty (which might happen if the make command fails to produce output but doesn't return a non-zero exit code). Using . is a more robust way to copy the contents of the directory.

Suggested change
cp -r docs/cat/* {cat_out}/
cp -r docs/html/* {html_out}/
cp -r docs/cat/. {cat_out}/
cp -r docs/html/. {html_out}/

Comment thread src/OpenRoad.cc

// Check Bazel runfiles layout first
const std::filesystem::path runfiles_docs
= std::filesystem::path(exe + ".runfiles") / "_main" / "docs";
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

Hardcoding _main as the workspace name is fragile. While _main is the default in modern Bazel versions, it can be overridden in the MODULE.bazel or WORKSPACE file. This logic will break if the workspace is renamed.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d073a29ad8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/BUILD.bazel
Comment on lines +6 to +7
man_pages(
name = "man_pages",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add //docs:man_pages to the openroad data deps

This target is defined but never consumed by the //:openroad binary, so the new getDocsPath() probe for <exe>.runfiles/_main/docs will not find generated docs during bazel run //:openroad. I checked for //docs:man_pages references and it only appears in this file, which means the man pages are built in isolation but not packaged with the executable’s runfiles; man/GUI help remains unavailable in Bazel-run binaries.

Useful? React with 👍 / 👎.

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.

This matches my experience, man in the application doesn't find anything

Comment thread bazel/man_pages.bzl Outdated

ctx.actions.run_shell(
outputs = [cat_dir, html_dir],
inputs = ctx.files.docs_srcs + ctx.files.scripts + ctx.files.readmes,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Declare man3 messages files as Bazel action inputs

md_roff_compat.py generates man3 pages from ../src/*/messages.txt and ../messages.txt, but this action only declares docs_srcs, scripts, and readmes as inputs. In Bazel sandboxing those message files are missing, so man3() skips them and cat3/html3 outputs are incomplete, which breaks lookups for message-ID documentation. Add the messages files as explicit attrs and include them in inputs.

Useful? React with 👍 / 👎.

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor Author

alokkumardalei-wq commented Apr 19, 2026

Hello @maliberty , Fixed- the man pages target was being built but never added to the binary's runfiles, so getDocsPath() had nothing to find. Added //docs:man_pages as a data dependency of //:openroad. Also declared messages.txt files as explicit inputs so man3 pages generate correctly in sandboxed builds.

Please have a look onto this when you get time.

Thank you !

@github-actions
Copy link
Copy Markdown
Contributor

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

@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 19, 2026

@maliberty what's the best way to reach you - discord/slack, email, or here on GitHub?

@github-actions
Copy link
Copy Markdown
Contributor

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

Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

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

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.

bazel - manpage missing

3 participants