Skip to content

Comments

tcl_lang: fix tcl_encode_sta.bzl rule - (#9524)#9530

Open
fredowski wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
fredowski:tcl_encode_sta
Open

tcl_lang: fix tcl_encode_sta.bzl rule - (#9524)#9530
fredowski wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
fredowski:tcl_encode_sta

Conversation

@fredowski
Copy link

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

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: The-OpenROAD-Project#9524

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
Copy link
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

The pull request correctly addresses the issue where tclsh could not find the default Tcl library files by setting the TCL_LIBRARY environment variable and including the necessary files in the action's inputs. The changes also correctly move the encoding script from tools to inputs as it is a data dependency for the Tcl interpreter, which is a more accurate representation of the action's dependencies.


# All tcl_core files live under library/, so split any file's path on
# "/library/" to obtain the library directory for TCL_LIBRARY.
tcl_lib_dir = ctx.files._tcl_library_files[0].path.split("/library/", 1)[0] + "/library"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The calculation of tcl_lib_dir assumes that ctx.files._tcl_library_files is not empty. If the file list is empty, this will cause a list index out of range error during the analysis phase. It is safer to verify that the list contains at least one file before accessing it, even though this is a private attribute with a default value.

    if not ctx.files._tcl_library_files:
        fail("No files found in _tcl_library_files")
    tcl_lib_dir = ctx.files._tcl_library_files[0].path.split("/library/", 1)[0] + "/library"

@github-actions
Copy link
Contributor

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

@maliberty
Copy link
Member

@hzeller review?

Copy link
Collaborator

@hzeller hzeller left a comment

Choose a reason for hiding this comment

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

Looks good.

@hzeller
Copy link
Collaborator

hzeller commented Feb 24, 2026

(might need some buildifier cleanup)

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

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

Friedrich Beckmann added 2 commits February 24, 2026 09:36
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>
Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
@github-actions
Copy link
Contributor

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

@fredowski
Copy link
Author

The linter is happy now. And i added a small build test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tcl_encode_sta complains about not finding init.tcl

3 participants