Skip to content

Showcase new method for compile commands generation#172

Draft
furtib wants to merge 1 commit intoEricsson:mainfrom
furtib:compile_commands_rework
Draft

Showcase new method for compile commands generation#172
furtib wants to merge 1 commit intoEricsson:mainfrom
furtib:compile_commands_rework

Conversation

@furtib
Copy link
Contributor

@furtib furtib commented Jan 29, 2026

Why:
I have come across this seemingly superior method for generating compile_commands.json

What:

  • Print the compile command straight from Bazel

Note:

Addresses:
none

@furtib furtib self-assigned this Jan 29, 2026
@furtib furtib force-pushed the compile_commands_rework branch from ecaf3bc to 9460544 Compare January 29, 2026 07:00
Comment on lines +302 to +308
# from: https://github.com/thekyz/snippets/tree/master/compilation_command_aspects
for action in target.actions:
if action.mnemonic == 'CppCompile':
for input in action.inputs.to_list():
if input.extension == 'c' or input.extension == 'cpp':
break
print(target, action.argv)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not quite sure I understand the purpose of this so far...
Do you mean that there is simpler way of collecting source:arguments?
If so we should consider it and compare with existing one.
That might be interesting!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is exactly it! I think we should see how this compares to our solution.

I'm not 100% sure this method is better, but this example, if run, prints out all build commands, even those hidden under implementation_deps, without looping over attributes. It seems very promising.

I just wanted to bring this to our attention and have it documented so we can reference it in the future.

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.

2 participants