refactor: extract constants and helpers for better maintainability#70
Open
nradakovic wants to merge 1 commit into
Open
refactor: extract constants and helpers for better maintainability#70nradakovic wants to merge 1 commit into
nradakovic wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the GCC toolchain repository rule and module extension to centralize repeated logic (CPU normalization, SDP version mapping, canonical repo name handling) and improve documentation/error messages, aiming to improve maintainability without changing behavior.
Changes:
- Extracted shared constants and helper functions in
rules/gcc.bzlto remove duplication. - Added helper(s) in
extensions/gcc.bzlto apply version-matrix defaults and improved failure diagnostics. - Updated documentation to reference the new helpers/constants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| rules/gcc.bzl | Introduces module-level constants and helper functions to centralize toolchain string/version normalization and canonical repo name resolution. |
| extensions/gcc.bzl | Refactors version-matrix default application and improves validation/error reporting when a matrix entry is missing. |
| docs/generation_flow.md | Updates documentation to describe the new helper functions/constants used during repository-rule generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e2bc1dd to
5776ed3
Compare
a0d2712 to
9eb3c27
Compare
Comment on lines
285
to
288
| "%{tc_gcov_path}": "external/score_bazel_cpp_toolchains++gcc+{repo}/bin/{cpu}-unknown-linux-gnu-gcov".format( | ||
| repo = rctx.attr.tc_pkg_repo, | ||
| cpu = "aarch64le" if rctx.attr.tc_cpu == "aarch64" else rctx.attr.tc_cpu, | ||
| cpu = _normalize_cpu(rctx.attr.tc_cpu), | ||
| ), |
Comment on lines
+21
to
+28
| # Constants | ||
| _PACKAGE_SUFFIX = "_pkg" | ||
| _IDENTIFIER_GCC = "gcc" | ||
| _IDENTIFIER_SDK = "sdk" | ||
| _IDENTIFIER_SDP = "sdp" | ||
| _SUPPORTED_CPUS = ["x86_64", "aarch64"] | ||
| _SUPPORTED_OSS = ["linux", "qnx"] | ||
| _SDP_VERSION_MAPPING = {"8.0.4": "8.0.0"} |
Comment on lines
299
to
301
| rctx.template( | ||
| "gcov_wrapper", | ||
| rctx.attr._cc_gcov_wrapper_script, |
720a488 to
9360f30
Compare
9360f30 to
f8fd376
Compare
- Extract configuration constants (OS, CPU, version mappings) to module level - Create helper functions to eliminate code duplication (_normalize_cpu, _apply_sdp_version_mapping, _get_canonical_pkg_name, _apply_matrix_defaults) - Improve docstrings with complete type annotations and error conditions - Enhance error messages with supported values - Update documentation to reference new refactored helpers - Remove FIXME/TODO comments by implementing systematic solutions Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nikola Radakovic <radaknikolans@gmail.com>
f8fd376 to
e385c6e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.