Commit Graph

125 Commits

Author SHA1 Message Date
Øyvind Harboe
85e0e57d85 Merge remote-tracking branch 'origin/master' into HEAD 2026-04-15 18:35:45 +02:00
Matt Liberty
d43d716d9b Merge pull request #9811 from alokkumardalei-wq/feature/bazelisk-run-tidy
Bazel: Add unified hermetic:tidy target for workspace formatting
2026-04-15 15:23:46 +00:00
alokkumardalei-wq
8d652ae302 bazel: add buildifier lint/fmt/tidy targets for .bazel files
Implements #9858 (#8495). Adds three new targets mirroring the TCL
lint pattern:

  //:lint_bzl_test  - buildifier -mode=check -lint=warn  (lint check)
  //:fmt_bzl_test   - buildifier -mode=check -lint=off   (format check)
  //:tidy_bzl       - buildifier -mode=fix -lint=fix     (auto-fix)

Wires lint_bzl_test and fmt_bzl_test into //:lint_test, and
bzl_tidy.sh + bzl_lint_test.sh into //:fix_lint. Adds
buildifier_prebuilt 6.4.0 as a dev_dependency in MODULE.bazel.

Uses git ls-files for file discovery, which automatically skips
submodule paths (src/sta, third-party/abc). Explicit -mode=check
flags override the repo-root .buildifier.json default (mode: fix),
ensuring test targets remain read-only.

Updates docs/contrib/LintTargets.md: moves buildifier from "Planned
additions" to "Available targets".

Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
2026-04-14 11:30:47 +05:30
Matt Liberty
d0ceda2e1e Merge pull request #10125 from hzeller/feature-20260413-zipfs-init
Don't use the same macro expression multiple times.
2026-04-13 16:59:39 +00:00
Henner Zeller
7ea9f117db Don't use the same macro expression multiple times.
Put the logic to when to use zipfs in one place,
set `USE_ZIPFS_INIT` define with that value and
use it for `#ifdef` ranges.

With that, also `#ifdef`-out the `GetProgramLocation()`, which is not
needed in the zipfs case.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-04-13 08:53:11 +02:00
Matt Liberty
f382eecd90 bazel: dedup SWIG helpers and clean up build files
- Extract shared transitive-depset helpers into bazel/swig_common.bzl;
  tcl_wrap_cc and python_wrap_cc had identical copy-pasted helpers.
  Providers stay distinct so deps type safety is preserved.
- Delete empty bazel/build_helper.bzl (never loaded anywhere).
- Remove dead .tcl/.py endswith filter in tcl_encode_or.bzl; the
  attr.label_list(allow_files=[".tcl", ".py"]) already enforces it.
- Deduplicate -Wall/-Wextra/-Wno-sign-compare/-Wno-unused-parameter
  in OPENROAD_COPTS; these are already set globally via .bazelrc.
- Add missing doc= for runtime_header attr; drop stale "for google3"
  docstring and obsolete/incorrect narration comments.

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
2026-04-13 05:50:18 +00:00
Øyvind Harboe
dc04ecd404 bazel: fix installed binary Tcl init failure
install.sh deleted openroad.runfiles/_main which contains the Tcl
resource files (init.tcl, tclreadline, etc.) needed by the Bazel-built
binary.  Remove that rm so the runfiles tree stays intact after install.

Add an install smoke test that extracts the packaging tarball and
verifies the binary can evaluate a Tcl expression — catches regressions
like this automatically.

Validate: bazelisk test //test/install/...

Fixes #10115

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-04-12 13:39:48 +02:00
Henner Zeller
46344b5b09 Use program name logic from former InitRunFiles
Also, remove now the old, not used anymore InitRunFiles and
library.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-04-09 20:27:09 +02:00
dsengupta0628
1f60b6dd75 update post cmts
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
2026-04-09 14:28:36 +00:00
dsengupta0628
5827c616f3 address gemini bot comment
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
2026-04-09 13:51:49 +00:00
dsengupta0628
ffd41b1b8a linux condition
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
2026-04-08 20:23:11 +00:00
dsengupta0628
4e1614c8da update tcl_lib_init for Bazel build issue to WA commit OpenSTA@385f4fd
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
2026-04-08 19:54:16 +00:00
Henner Zeller
5af56087d8 Bazel tcl initialization: use zipfs on Tcl9 and runfiles on Tcl8
* For Tcl9, all relevant system tcl files, the tcl library and
   readline library, are packed in a zip file, compiled into the
   binary mounted on the virtual filesystem //zipfs:/
 * On Tcl 8, which does not allow to do that quite yet, we
   take the same directory structure (unpacked), and use them
   via runfiles as before; however, since this is now a single
   directory the runfile symbolic links are reduced to one.

Default for now is to use the runfile method, as we're still on
Tcl8; The code is prepared for Tcl9, awaiting some changes in
STA to be merged, then we can change the default.

Fixes: #9962 #9980

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-04-03 14:07:48 +02:00
Vitor Bandeira
2464c8cb54 bazel: fix Bazel target paths in install script and docs
Signed-off-by: Vitor Bandeira <vvbandeira@precisioninno.com>
2026-03-31 18:06:38 +00:00
Matt Liberty
1e10509b13 Merge pull request #9931 from oharboe/fix-fix-lint
[bazel] Fix tclint/tclfmt runfiles lookup in lint scripts
2026-03-28 06:44:29 +00:00
Henner Zeller
c711c030f0 Use openmp from BCR
It has been added in
https://github.com/bazelbuild/bazel-central-registry/pull/8152

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-03-27 11:38:29 -07:00
Øyvind Harboe
ff0e283c74 Update bazel/tcl_lint_test.sh
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-26 22:41:07 +01:00
Øyvind Harboe
793509bbd4 Update bazel/tcl_fmt_test.sh
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-26 22:40:59 +01:00
Henner Zeller
fee884118b Make tcl wrap working properly if used via downstream project.
Issues #9937

Co-authored-by: Paul Rigge <rigge@google.com>
Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-03-25 22:41:00 +01:00
Øyvind Harboe
06c09ccaf4 [bazel] Fix tclint/tclfmt runfiles lookup in lint scripts
readlink -f resolves through symlinks, losing the .runfiles sibling
directory that py_console_script_binary needs. Use the same cd/pwd
pattern as tcl_tidy.sh which resolves the directory without following
the symlink.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-25 09:11:19 +01:00
Henner Zeller
c10380196d Fix uses of /bin/bash to use /usr/bin/env bash instead.
The only Posix compatible way to call bash is via `/usr/bin/env`
as bash might be installed in different locations on the system.
`/bin/bash` is not a Posix-required location for that binary
(only `/bin/sh` is).

Use `set -o noglob` instead of `bash -f` for improved readability.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-03-23 02:57:02 -07:00
Øyvind Harboe
183689f85d fix: make fix_lint run tclint after tclfmt (POLA)
fix_lint was an alias for tidy_tcl (tclfmt only), so developers
who ran it before pushing were still surprised by tclint CI
failures like line-length.

Replace the alias with a script that delegates to tcl_tidy.sh
and tcl_lint_test.sh (DRY), shows git status, and exits with
a clear error if lint violations remain unfixed.

Update docs with POLA rationale and naming convention for
umbrella and per-language targets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-20 16:59:23 +01:00
Matt Liberty
2da3e5bf39 Merge pull request #9734 from Pinata-Consulting/linting
Some checks failed
Automatically sync branch from upstream. / Automatic sync 'master' from The-OpenROAD-Project/OpenROAD (push) Has been cancelled
Lint Python / Black (push) Has been cancelled
Lint Bazel / Buildifier format (push) Has been cancelled
Lint Bazel / Buildifier lint (push) Has been cancelled
Check That ODB Files Are Generated / Are-Odb-Files-Generated (push) Has been cancelled
Format Code with pre commit trigger / Clang-Format (push) Has been cancelled
Lint Tcl code / Tclint (push) Has been cancelled
Build on macOS / Mac-Build (push) Has been cancelled
Scan Code with pre commit trigger / Security-Scan (push) Has been cancelled
Linting
2026-03-20 00:34:33 +00:00
Øyvind Harboe
5eb007b7bd bazel: fix lint scripts to use git ls-files and find workspace
- Tests were scanning 0 files because BUILD_WORKSPACE_DIRECTORY is
  unset in test context. Resolve workspace from tclint.toml symlink.
- fix_lint failed because readlink -f resolved through runfiles
  symlinks. Use directory-based path resolution instead.
- All three scripts now use git ls-files to avoid broken symlinks
  in gitignored directories like tmp/.
- Add tmp/ to tclint.toml excludes, fix leading whitespace.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-17 20:12:47 +01:00
Henner Zeller
66ebecfa1c Add the import of cc_library() in openmp build rule.
This was implicit in the olden days, but these days we should
be explicit to be compatible with future bazel versions.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-03-16 08:32:53 -07:00
Øyvind Harboe
ba764a22fc Merge remote-tracking branch 'origin/master' into HEAD 2026-03-13 15:33:25 +01:00
Øyvind Harboe
f5d566698e bazel: address PR #9734 review comments
- Rename //:lint to //:fix_lint to clarify it modifies files (gadfort)
- Replace duplicated sh_binary with alias(actual = ":tcl_tidy") (gemini)
- Add BUILD_WORKSPACE_DIRECTORY fallback in tcl_tidy.sh (gemini)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-13 15:32:58 +01:00
Øyvind Harboe
eb1613d9ff bazel: add tclint/tclfmt console script binaries
Expose tclint and tclfmt as py_console_script_binary targets from the
pip-managed tclint package. Add wrapper shell scripts that invoke these
tools against the workspace root.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-13 15:32:58 +01:00
Øyvind Harboe
8a41365de9 pip: add tclint dependency
Add tclint==0.7.0 to pip requirements for Bazel-managed TCL linting
and formatting. This is the same version used by the GitHub Actions
workflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-13 15:32:58 +01:00
Matt Liberty
50656bf4f3 Merge pull request #9737 from Pinata-Consulting/bazel-hermeticity-nits
Some checks failed
Lint Python / Black (push) Has been cancelled
Lint Bazel / Buildifier format (push) Has been cancelled
Lint Bazel / Buildifier lint (push) Has been cancelled
Check That ODB Files Are Generated / Are-Odb-Files-Generated (push) Has been cancelled
Format Code with pre commit trigger / Clang-Format (push) Has been cancelled
Lint Tcl code / Tclint (push) Has been cancelled
Build on macOS / Mac-Build (push) Has been cancelled
Scan Code with pre commit trigger / Security-Scan (push) Has been cancelled
Run Repo stats / repostats-for-nice-project (push) Has been cancelled
Automatically sync branch from upstream. / Automatic sync 'master' from The-OpenROAD-Project/OpenROAD (push) Has been cancelled
bazel: replace genrule sed/cat with skylib rules for hermeticity
2026-03-12 19:29:26 +00:00
Matt Liberty
e61a2c531c Merge pull request #9700 from alokkumardalei-wq/fix-bazel-tclreadline
bazel: enable tclreadline in Bazel
2026-03-12 14:29:08 +00:00
Øyvind Harboe
52664be5c8 bazel: replace genrule sed/cat with skylib rules for hermeticity
Use expand_template and copy_file from bazel_skylib instead of
genrule with sed/cat in the OpenMP overlay BUILD file. This avoids
depending on host shell tools and sets a better example for
contributors who copy existing patterns.

Remaining hermeticity nits for later:
- BUILD.bazel OpenRoadVersion genrule uses grep/cut/printf
- src/sta StaConfig genrule uses echo -e (fix pending in sta repo)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2026-03-12 07:39:45 +01:00
alokkumardalei-wq
4ec0e179c7 chore: make tclreadline bazel build fully hermetic
Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
2026-03-12 09:44:46 +05:30
alokkumardalei-wq
00c7610706 bazel: enable tclreadline for interactive openroad> prompt
Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
2026-03-10 05:20:00 +05:30
Friedrich Beckmann
54a0fe8e24 bazel: use pkg_tar for the install procedure
I updated the install procedure to use the pkg_tar
module. The install works as before, but now you
can also install optionally to another location.

Closes: #9635

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-03-06 06:54:32 +01:00
Henner Zeller
dde683ab61 Use @rules_python directly, don't rename.
Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-03-03 09:31:26 +01:00
Henner Zeller
b02bdbf6e3 Use swig from BCR, allowing to remove last dep on WORKSPACE
Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-03-02 19:08:42 +01:00
Henner Zeller
cee579b853 Use swig from BCR, allowing to remove last dep on WORKSPACE
Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-03-02 18:38:27 +01:00
Matt Liberty
9b206bb8b7 Merge pull request #9530 from fredowski/tcl_encode_sta
tcl_lang: fix tcl_encode_sta.bzl rule - (#9524)
2026-02-26 15:16:01 +00:00
Friedrich Beckmann
6d77389dba bazel/macos: central setting for linker settings for python extensions
I extended the mechanism that is used to supply the defines for
the python module. Now tha linker options are set in one place.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-02-26 08:16:31 +01:00
Matt Liberty
d6b90eb5a1 Revert "Merge pull request #9537 from The-OpenROAD-Project-staging/9490-revert"
This reverts commit d7b40432ab, reversing
changes made to 186c695e9b.
2026-02-25 21:33:34 +00:00
Henner Zeller
e9afa6264c Copy bison and flex.bzl from bazel_rules_hdl locally.
Step 1 from 2.

That way, we can use it from here and remove the reference
in `WORKSPACE`.

After
https://github.com/The-OpenROAD-Project/OpenSTA/pull/296
is merged, we can (step 2) update that submodule, and
with it remove the WORKSPACE reference.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-02-25 07:04:48 -08:00
Matt Liberty
1a60d75625 Revert "Merge pull request #9490 from fredowski/bazel-tcl"
This reverts commit c0199c49bf, reversing
changes made to f6fd0d645f.
2026-02-24 21:18:10 +00:00
Friedrich Beckmann
d55474ec28 bazel: add build test for tcl_encode_sta.bzl rule
Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-02-24 09:37:06 +01:00
Friedrich Beckmann
823cd13c83 bazel: tcl_encode_sta sort keys lexicographically
buildifier lint suggested this change according to
https://github.com/bazelbuild/buildtools/blob/main/WARNINGS.md#unsorted-dict-items

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-02-24 09:36:45 +01:00
Friedrich Beckmann
aa38a1a682 tcl_lang: fix tcl_encode_sta.bzl rule - (#9524)
The tcl_lang package does not provide the default tcl library
files like init.tcl with the tclsh. That is different compared
to the rules_hdl version. tcl_lang provides the library files
via tcl_core. I derived the path and set TCL_LIBRARY such that
tclsh finds the right init.tcl file.

Closes: #9524

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-02-24 01:05:01 +01:00
Matt Liberty
359e41edaf clang-format bazel/InitRunFiles.cpp
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
2026-02-23 01:45:39 +00:00
Friedrich Beckmann
b3d6b364c5 bazel/tcl: add cstdlib include for setenv in InitRunFiles.cpp
clang/tidy noticed that there is no include for setenv.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-02-22 22:22:00 +01:00
Friedrich Beckmann
676e7e9d43 bazel/tcl: Set and Overwrite the TCL_LIBRARY environment variable
The bazel build comes with tcl files in the runtime environment.
When the binary is called directly with TCL_LIBRARY set
to another tcl version, then that one is used. If the versions
differ like 8.6.12 vs 8.6.16, then the tcl shell does not work.

This patch makes sure that the TCL_LIBRARY variable is
always overwritten to use the bazel runtime environment
with the correct tcl init files.

The original behaviour resulted in regression test
failures because the TCL_LIBRARY variable was
set to the system (ubuntu) version which was 8.6.12 while
openroad uses 8.6.16.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-02-22 22:22:00 +01:00
Friedrich Beckmann
3157515dea bazel/tcl: remove TCL_LIBRARY setting in tcl_encode_sta.bzl
At least after migrating to bcr version of tcl the
regression works without this setting. Also some short
test on the openroad cmdline version works.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
2026-02-22 22:22:00 +01:00