Skip to content

refactor: extract constants and helpers for better maintainability#70

Open
nradakovic wants to merge 1 commit into
mainfrom
nira_refactor_code
Open

refactor: extract constants and helpers for better maintainability#70
nradakovic wants to merge 1 commit into
mainfrom
nira_refactor_code

Conversation

@nradakovic

@nradakovic nradakovic commented Jun 26, 2026

Copy link
Copy Markdown
Member
  • 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

@nradakovic nradakovic requested a review from Copilot June 26, 2026 17:53
@nradakovic nradakovic self-assigned this Jun 26, 2026
@nradakovic nradakovic added p4 Negligible impact - improvements and/or cosmetic features. improvements Code or documentation improvements labels Jun 26, 2026
@nradakovic nradakovic added documentation Improvements or additions to documentation wip Work in progress labels Jun 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.bzl to remove duplication.
  • Added helper(s) in extensions/gcc.bzl to 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.

Comment thread extensions/gcc.bzl
Comment thread docs/generation_flow.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

Comment thread rules/gcc.bzl Outdated
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 thread docs/generation_flow.md Outdated
Comment thread extensions/gcc.bzl Outdated
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 thread rules/gcc.bzl
Comment on lines 299 to 301
rctx.template(
"gcov_wrapper",
rctx.attr._cc_gcov_wrapper_script,
@nradakovic nradakovic force-pushed the nira_refactor_code branch 2 times, most recently from 720a488 to 9360f30 Compare June 26, 2026 18:15
@nradakovic nradakovic requested a review from Copilot June 26, 2026 18:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Comment thread rules/gcc.bzl
Comment thread rules/gcc.bzl
Comment thread rules/gcc.bzl
@nradakovic nradakovic force-pushed the nira_refactor_code branch from 9360f30 to f8fd376 Compare June 26, 2026 18:51
- 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>
@nradakovic nradakovic force-pushed the nira_refactor_code branch from f8fd376 to e385c6e Compare June 26, 2026 18:52
@nradakovic nradakovic requested a review from Copilot June 26, 2026 18:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

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

Labels

documentation Improvements or additions to documentation improvements Code or documentation improvements p4 Negligible impact - improvements and/or cosmetic features. wip Work in progress

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants