Skip to content

Use the compile_commands implementation from the monolithic rule in the per_file rule#98

Merged
furtib merged 13 commits intoEricsson:mainfrom
furtib:unify-compile_commands
Jan 28, 2026
Merged

Use the compile_commands implementation from the monolithic rule in the per_file rule#98
furtib merged 13 commits intoEricsson:mainfrom
furtib:unify-compile_commands

Conversation

@furtib
Copy link
Contributor

@furtib furtib commented Oct 21, 2025

Why:
Currently, we use a different, inferior implementation for generating compile_commands.json in the pre_file rule.
We should use the same as in the monolithic rule. This would prevent us from having to maintain both rules simultaneously.

What:
Replaces the compile_commands.json generating implementation in the pre_file rule.
Fixes the unittest for compile_commands, the per_file compile_commands.json location changed

Addresses:
Fixes: #120
Fixes: #128

@furtib furtib requested review from Szelethus and nettle October 21, 2025 11:41
@furtib furtib self-assigned this Oct 21, 2025
@furtib furtib added enhancement New feature or request non-functional change ☮️ The patch doesn't change any functionality, e.g. refactoring, documentation, test-only. labels Oct 21, 2025
@furtib furtib force-pushed the unify-compile_commands branch from ff788bf to c1b559c Compare November 24, 2025 12:34
@furtib
Copy link
Contributor Author

furtib commented Nov 24, 2025

Fails because #99 does not affect the "monolithic" compile command generator implementation. should rebase after merging #100

@furtib furtib force-pushed the unify-compile_commands branch from c1b559c to fea15a0 Compare November 24, 2025 13:56
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.

Can you delete all unnecessary functions, just to see how much simpler this solution would be?

@furtib furtib force-pushed the unify-compile_commands branch from fea15a0 to 65034d3 Compare January 10, 2026 22:12
@furtib
Copy link
Contributor Author

furtib commented Jan 10, 2026

This patch might deserve a bit more love.
The file collection still happens through the aspect written inside the per file rule.
We might want to use the solution from compile_commands.bzl there too, the fix I have implemented this has been removed (we concentrated on the monolithic rule for the time being, the patch was: #127), but I think that could have placed here.

@furtib
Copy link
Contributor Author

furtib commented Jan 12, 2026

Using the compile_commands.bzl aspect for file collection, there are some things to keep in mind. Mainly, despite the name transitive_source_files suggests only having source files, it actually can contain header files (this might be because it collects the files under the srcs=[] part of the cc_lib/bin rules)

@furtib furtib force-pushed the unify-compile_commands branch from 7827b46 to cba2a86 Compare January 12, 2026 07:32
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.

Just like that, and everything runs? Damn.

@furtib furtib force-pushed the unify-compile_commands branch 3 times, most recently from 4ce7518 to e4b2503 Compare January 12, 2026 12:09
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.

We need to understand this a bit better before merging...

Copy link
Collaborator

@nettle nettle left a comment

Choose a reason for hiding this comment

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

May I suggest changing only src/per_file.bzl implementation first, which seems reasonable to me and not touching src/codechecker.bzl and src/compile_commands.bzl at least yet.

@Szelethus
Copy link
Contributor

May I suggest changing only src/per_file.bzl implementation first, which seems reasonable to me and not touching src/codechecker.bzl and src/compile_commands.bzl at least yet.

It is a more than reasonable ask to land parts of this patch independently, but I'm strongly against not touching those two files to keep them stable, especially with NFC patches.

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.

Meant to send this inline comment yesterday.

@furtib furtib closed this Jan 21, 2026
@furtib furtib reopened this Jan 21, 2026
Copy link
Collaborator

@nettle nettle left a comment

Choose a reason for hiding this comment

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

Looks generally good to me, with a couple of comments:

  1. To be honest I dont understand the hustle with headers, but I guess you have your reasons, maybe just need to explain, maybe try to implement as a separate function for clarity
  2. Nitpick: the coding style is quite questionable :) but we do not run buildifier yet.
    I would probably suggest to start it running to fix ONLY changed parts :)

@furtib furtib force-pushed the unify-compile_commands branch from e9bf840 to dff2e7b Compare January 22, 2026 15:36
Copy link
Collaborator

@nettle nettle left a comment

Choose a reason for hiding this comment

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

We can make it much simpler

@furtib furtib requested review from Szelethus and nettle January 26, 2026 14:41
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.

LGTM, I think we should merge this and move on.

I'd be happier if I got a response explaining why #141 or #145 couldn't land as a precursor. Writing DRY code is a basic software engineering practice, so explicitly deciding against it requires some justification. I was (and am) willing to let the issue slide, but I want to encourage constructive, technical discussion on such topics in the future; what are the technical reasons behind the obstruction?

I am happy to approve something I disagree with, but not something that I don't even understand.

Copy link
Collaborator

@nettle nettle left a comment

Choose a reason for hiding this comment

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

LGTM

@furtib furtib merged commit 05670a6 into Ericsson:main Jan 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 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.

Missing header files from external repositories during analysis Missing header files during analysis

3 participants