Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/compile_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ def _accumulate_compilation_database(accumulated, deps):
return depset(transitive = compilation_db)

def _compile_commands_aspect_impl(target, ctx):
# 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)
Comment on lines +302 to +308
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.


source_files = get_sources(ctx)
source_files = depset(source_files)
compilation_db = get_compilation_database(target, ctx)
Expand Down