bazel
bazel copied to clipboard
refactor createSourceAction
This patch refactors the C++ compilation actions in CcCompilationHelper. It introduces a helper method createSourceActionHelper to streamline the creation of source actions and reduces duplicated code related to PIC and non-PIC compilation.
Changes
-
Refactored Source Action Creation:
- Introduced
createSourceActionHelperto handle the common logic for creating compile actions. - This method consolidates the setup and finalization of compile actions for both PIC and non-PIC variants.
- The helper method now handles setting up variables, creating temp actions, and registering the compile actions.
- Introduced
-
Updated
createSourceActionMethod:- The
createSourceActionmethod now callscreateSourceActionHelperfor both PIC and non-PIC compile actions. - This change simplifies the
createSourceActionmethod and removes redundancy.
- The
Background
I'm working on support C++20 Modules in Bazel, see https://github.com/bazelbuild/bazel/pull/19940
While constructing the action graph for compiling C++20 Modules, I noticed that the createSourceAction code could be reused. Therefore, I refactored createSourceAction. One potentially unusual aspect is the handling of ArtifactCategory.CPP_MODULE at the end. Since the logic for handling C++20 Modules differs from that of Clang Modules, this part of the logic was placed outside of createSourceActionHelper.
the code of constructing the action graph for compiling C++20 Modules is https://github.com/bazelbuild/bazel/pull/22553
cc @comius
@comius @trybka Could you please review this patch? It was split out from https://github.com/bazelbuild/bazel/pull/22553 , which is still quite large.
@comius @trybka ping
hi @lberki,
could you please assign this PR to @comius and @trybka? It would be great to have this patch reviewed and merged before we tackle https://github.com/bazelbuild/bazel/pull/22553.
thank you
cc @katre