Skip to content

Update Public API - #281

Open
nettle wants to merge 1 commit into
Ericsson:mainfrom
nettle:defs-more
Open

Update Public API#281
nettle wants to merge 1 commit into
Ericsson:mainfrom
nettle:defs-more

Conversation

@nettle

@nettle nettle commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Why:
Still we have to reach into the implementation (//src:) for the toolchain:
@rules_codechecker//src:toolchain_type when declaring own toolchain,
and //src:codechecker_local_toolchain when registering ours.
get_platform_alias() was not reachable from defs.bzl either,
so the public API was incomplete.

What:

  • Define toolchain_type and the default toolchain in the root package
  • Rename codechecker_local to default_tools and
    codechecker_local_toolchain to default_toolchain
  • Refer to //:toolchain_type in the rules that resolve the toolchain
  • Register //:default_toolchain in MODULE.bazel
  • Export get_platform_alias() from defs.bzl
  • Move buildifier to test/buildifier

@Szelethus
Szelethus requested review from Szelethus and furtib August 13, 2026 11:36
@Szelethus Szelethus added the enhancement New feature or request label Aug 13, 2026

@Szelethus Szelethus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we create an issue first as per the PR requirements? It would help us get a clearer picture for the motivation.

  • Export get_platform_alias() from defs.bzl

That, alongside codechecker_suite is poorly documented (related: #44). Also, is this something that should be a public feature of this specific ruleset? Can you expand on the motivation?

  • Move buildifier to test/buildifier

Does this change have to land within this PR? Sounds like a separate addition worhty of a separate discussion.

Comment thread src/per_file.bzl
@@ -192,7 +192,7 @@ def _per_file_impl(ctx):
_create_wrapper_script(ctx, options, compile_commands, config_file)

# TODO: Consider using aliases so we don't have to type //src: everywhere.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is no need to preserve this comment if this PR lands.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point!

@furtib furtib left a comment

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.

The toolchain name should reflect the fact that it is a local-only toolchain.

I don't have strong opinions on the placement of the toolchain_type, but we should move it as little as possible. Looking at similar rules, their toolchains are usually like:

It is my understanding that these rules use the rulename directory as src, so we do not have to follow their pattern.

Remember that this is an API breaking change.

Comment thread test/buildifier/BUILD
@@ -0,0 +1,39 @@
# Copyright 2026 Ericsson AB

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.

Moving Buildifier into testing is outside the scope of a Public API patch.

@nettle nettle Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agree, I've created a separate PR: #289

Comment thread BUILD

# Tools found on PATH, provisioned by the default_codechecker_tools extension
codechecker_toolchain(
name = "default_tools",

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.

This name does not communicate that this toolchain cannot be used with remote executors!

This toolchain is specific to a user's local environment.

We could rename it to something like this.

Suggested change
name = "default_tools",
name = "default_local_tools",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Well... "local" is actually kinda misleading and wrong here.
Local to what? Besides, should this be default forever?
Default tools are being taken from the environment currently, which is totally wrong!
Later default_tools should became real default, not local.

@Szelethus Szelethus added the API change ⚠️ Breaks existing API label Aug 13, 2026
@nettle

nettle commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Can we create an issue first as per the PR requirements? It would help us get a clearer picture for the motivation.

Sure, it is a bit late because #269 is already merged,
but I agree we better have a ticket first: #288

  • Export get_platform_alias() from defs.bzl

That, alongside codechecker_suite is poorly documented (related: #44). Also, is this something that should be a public feature of this specific ruleset? Can you expand on the motivation?

Very simple - it is being used in real project.

  • Move buildifier to test/buildifier

Does this change have to land within this PR? Sounds like a separate addition worhty of a separate discussion.

Yes, agree, this might be better separate.
I have discovered that we should not (and cannot) use buildifier when it is exposed as Public API.
Created a separate PR: #289

@nettle

nettle commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

The toolchain name should reflect the fact that it is a local-only toolchain.

Disagree. I have explained that - the fact that our current implementation is "local" should not be reflected in the interface.
Dependency on local environment is completely wrong from Bazel perspective and must be fixed.

I don't have strong opinions on the placement of the toolchain_type, but we should move it as little as possible. Looking at similar rules, their toolchains are usually like:

It is my understanding that these rules use the rulename directory as src, so we do not have to follow their pattern.

That was exactly what I checked and exactly my thinking! So, here is the suggestion:

  • rules_codechecker: @rules_codechecker//:toolchain_type

Remember that this is an API breaking change.

That's why we need to do that as early as possible!

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

Labels

API change ⚠️ Breaks existing API enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants