Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor createSourceAction #22744

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PikachuHyA
Copy link
Contributor

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.

Benefits

  • Code Simplification: By consolidating common logic into a helper method, the codebase becomes easier to understand and maintain.
  • Reduced Redundancy: The refactoring eliminates the duplicated code for setting up and finalizing compile actions for PIC and non-PIC scenarios.
  • Improved Readability: The separation of concerns into distinct methods enhances the readability and traceability of the compilation process.

Background

I'm working on support C++20 Modules in Bazel, see #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 #22553

@PikachuHyA PikachuHyA requested a review from lberki as a code owner June 14, 2024 07:53
@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Jun 14, 2024
@PikachuHyA
Copy link
Contributor Author

cc @comius

@sgowroji sgowroji added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants