bazel icon indicating copy to clipboard operation
bazel copied to clipboard

refactor createSourceAction

Open PikachuHyA opened this issue 1 year ago • 3 comments

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

  1. Refactored Source Action Creation:

    • Introduced createSourceActionHelper to 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.
  2. Updated createSourceAction Method:

    • The createSourceAction method now calls createSourceActionHelper for both PIC and non-PIC compile actions.
    • This change simplifies the createSourceAction method and removes redundancy.

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

PikachuHyA avatar Jun 14 '24 07:06 PikachuHyA

cc @comius

PikachuHyA avatar Jun 14 '24 07:06 PikachuHyA

@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.

PikachuHyA avatar Jul 23 '24 02:07 PikachuHyA

@comius @trybka ping

PikachuHyA avatar Aug 26 '24 03:08 PikachuHyA

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

PikachuHyA avatar Sep 06 '24 02:09 PikachuHyA

cc @katre

PikachuHyA avatar Sep 06 '24 02:09 PikachuHyA