Skip to content

Convenience function for interacting with compile_commands_impl#145

Draft
nettle wants to merge 1 commit intoEricsson:mainfrom
nettle:get-compile-commands
Draft

Convenience function for interacting with compile_commands_impl#145
nettle wants to merge 1 commit intoEricsson:mainfrom
nettle:get-compile-commands

Conversation

@nettle
Copy link
Collaborator

@nettle nettle commented Jan 16, 2026

Why:
Simplify integration src/compile_commands.bzl into src/per_file.bzl

What:

  • Introduce get_compile_commands() function which returns only compile_commands.json File object and performs optional checks

Addresses:
Optional accessory to #98

Why:
Simplify integration src/compile_commands.bzl into src/per_file.bzl

What:
- Introduce get_compile_commands() function
  which returns only compile_commands.json File object
  and performs optional checks
@nettle nettle requested review from Szelethus and furtib January 16, 2026 20:24
@nettle nettle added the non-functional change ☮️ The patch doesn't change any functionality, e.g. refactoring, documentation, test-only. label Jan 16, 2026
),
]

def get_compile_commands(ctx, check=True):
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can see, the only meaningful difference here and #141 is the check parameter. Why would ever want to skip these checks though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Getting files from DefaultInfo provider is a kind of common operation. Theoretically we can also get empty list or no list, and none of these is necessary a fail. That actually may apply to compile_commands.json file as well. We add checks only to handle our specific scenario. To be honest , generalizing this as a function does not look much useful to me.

Copy link
Contributor

@Szelethus Szelethus left a comment

Choose a reason for hiding this comment

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

Besides the check parameter, this was copy-pasted from codechecker.bzl. Please help me understand what specific concerns you have about not reusing this code?

Again, this is not a hill I intend to die on, and I'm fine to support a solution I understand, even if I disagree with it.

@nettle
Copy link
Collaborator Author

nettle commented Jan 22, 2026

Besides the check parameter, this was copy-pasted from codechecker.bzl. Please help me understand what specific concerns you have about not reusing this code?

Again, this is not a hill I intend to die on, and I'm fine to support a solution I understand, even if I disagree with it.

I actually do not see much use of this #145 as well as #141 :)
I implemented this convenience function in a form that might be used in per_file.bzl
But, as to me, it is not needed

@Szelethus
Copy link
Contributor

It is still not clear to me why we can't modify codechecker.bzl to use this new function. For BUILD files, I understand that writing easily readable code is preferred over code reuse, but this principle is not applicable to Starlark (.bzl) code.

I'm sure there is something I don't see that you do, and I'm eager to learn. Why can't the same logic from codechecker.bzl and, after #98 lands, per_file.bzl, be reused from a common function?

@Szelethus
Copy link
Contributor

I'll put the PR in draft; we have more important issues to attend to now that #98 is unblocked.

@Szelethus Szelethus marked this pull request as draft January 27, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

non-functional change ☮️ The patch doesn't change any functionality, e.g. refactoring, documentation, test-only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants