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

build: cmake build optimize,avoid repeated compilation of dependent libraries #229

Closed
wants to merge 1 commit into from

Conversation

lqxhub
Copy link
Collaborator

@lqxhub lqxhub commented Mar 29, 2025

尝试优化cmake编译, 避免在编译时重复编译依赖的第三方库

fix:#228

Summary by CodeRabbit

  • Chores
    • Improved external dependency management by disabling automatic update operations during builds.
    • This change ensures that stable, fixed versions of third-party components are used, enhancing build consistency and overall reliability.

Copy link

coderabbitai bot commented Mar 29, 2025

Walkthrough

This pull request updates several CMake configuration files by adding an UPDATE_COMMAND "" parameter to the ExternalProject_Add function for multiple external projects. The modification explicitly disables any update commands during the build or update process for each project. While most files only receive this additional line, a subset also documents the change in their public interface declarations.

Changes

Files Change Summary
cmake/braft.cmake, cmake/brpc.cmake, cmake/gtest.cmake, cmake/openssl.cmake, cmake/snappy.cmake Added UPDATE_COMMAND "" parameter to disable update commands, with explicit mention in public entity declarations.
cmake/fmt.cmake, cmake/gflags.cmake, cmake/leveldb.cmake, cmake/lz4.cmake, cmake/protobuf.cmake, cmake/rocksdb.cmake, cmake/zlib.cmake, cmake/zstd.cmake Inserted a new line with UPDATE_COMMAND "" in the ExternalProject_Add function to explicitly disable any update command, maintaining existing configuration flow.

Sequence Diagram(s)

sequenceDiagram
    participant CMake
    participant ExternalProject_Add
    participant BuildProcess

    CMake->>ExternalProject_Add: Invoke with parameters (including UPDATE_COMMAND = "")
    ExternalProject_Add->>BuildProcess: Check update command configuration
    alt UPDATE_COMMAND is non-empty
        BuildProcess->>ExternalProject_Add: Execute update steps
    else UPDATE_COMMAND is empty
        BuildProcess->>ExternalProject_Add: Skip update step, proceed to build/install
    end
Loading

Suggested labels

✏️ Feature, 🧹 Updates

Suggested reviewers

  • AlexStocks
  • marsevilspirit

Poem

I'm a rabbit with hops so light,
Celebrating changes deep into the night,
UPDATE_COMMAND now sits empty with glee,
No more updates in our CMake spree!
CodeRhythm beats, as smooth builds delight 🐇
Hooray for changes in our build flight!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (6)
cmake/leveldb.cmake (1)

19-19: Duplicate UPDATE_COMMAND "" parameter

There's already an identical UPDATE_COMMAND "" parameter on line 37 of this file. While this duplication won't cause functional issues (the last occurrence takes precedence), it's unnecessary and may cause confusion for future maintenance.

Consider removing one of the duplicate parameters:

-        UPDATE_COMMAND ""
cmake/fmt.cmake (1)

25-25: Duplicate UPDATE_COMMAND "" parameter

There's already an identical UPDATE_COMMAND "" parameter on line 40 of this file. While this duplication won't cause functional issues (the last occurrence takes precedence), it's unnecessary and may cause confusion for future maintenance.

Consider removing one of the duplicate parameters:

-        UPDATE_COMMAND ""
cmake/rocksdb.cmake (1)

17-17: Duplicate UPDATE_COMMAND "" parameter

There's already an identical UPDATE_COMMAND "" parameter on line 47 of this file. While this duplication won't cause functional issues (the last occurrence takes precedence), it's unnecessary and may cause confusion for future maintenance.

Consider removing one of the duplicate parameters:

-        UPDATE_COMMAND ""
cmake/lz4.cmake (1)

20-20: Redundant UPDATE_COMMAND parameter detected

The UPDATE_COMMAND "" is already specified on line 34. Having it defined twice (at line 20 and line 34) is redundant as only the last occurrence would take effect. While this doesn't cause functional issues (both commands achieve the same goal of preventing source updates), it's cleaner to specify it only once.

- UPDATE_COMMAND ""

Keep only the UPDATE_COMMAND "" on line 34 to avoid redundancy and maintain clean code.

cmake/gflags.cmake (1)

25-25: Redundant UPDATE_COMMAND parameter detected

The UPDATE_COMMAND "" is already specified on line 43. Having the same parameter defined twice (at line 25 and line 43) is redundant since only the last instance would take effect in CMake's ExternalProject_Add function. While this doesn't cause functional issues, it's cleaner to have it specified only once.

- UPDATE_COMMAND ""

Keep only the UPDATE_COMMAND "" on line 43 to maintain a cleaner configuration file.

cmake/protobuf.cmake (1)

36-36: Redundant UPDATE_COMMAND parameter detected

The UPDATE_COMMAND "" is already specified on line 24. Having it defined twice (at line 24 and line 36) is redundant as only the last occurrence would be effective in CMake's ExternalProject_Add function. While functionally this doesn't cause issues, it's more maintainable to have it specified only once.

- UPDATE_COMMAND ""

Keep only the UPDATE_COMMAND "" on line 24 to avoid redundancy and maintain cleaner code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04b5c06 and 199ed2e.

📒 Files selected for processing (13)
  • cmake/braft.cmake (1 hunks)
  • cmake/brpc.cmake (1 hunks)
  • cmake/fmt.cmake (1 hunks)
  • cmake/gflags.cmake (1 hunks)
  • cmake/gtest.cmake (1 hunks)
  • cmake/leveldb.cmake (1 hunks)
  • cmake/lz4.cmake (1 hunks)
  • cmake/openssl.cmake (1 hunks)
  • cmake/protobuf.cmake (1 hunks)
  • cmake/rocksdb.cmake (1 hunks)
  • cmake/snappy.cmake (1 hunks)
  • cmake/zlib.cmake (1 hunks)
  • cmake/zstd.cmake (1 hunks)
🔇 Additional comments (5)
cmake/brpc.cmake (1)

26-26: LGTM: Appropriate use of UPDATE_COMMAND ""

The addition of UPDATE_COMMAND "" prevents CMake from attempting to update the brpc source code on subsequent builds, which aligns with the PR objective of avoiding repeated compilation of dependent libraries.

cmake/gtest.cmake (1)

18-18: Good addition to prevent unnecessary updates

Adding UPDATE_COMMAND "" prevents CMake from running update commands on the external project's source code during builds. This is a good optimization as it avoids unnecessary recompilation of the Google Test library when the rest of the project is rebuilt.

This change aligns well with the PR objective of optimizing the build process by preventing repeated compilation of dependency libraries.

cmake/braft.cmake (1)

27-27: LGTM: Build optimization through UPDATE_COMMAND

Adding UPDATE_COMMAND "" prevents CMake from running update commands on the braft repository during builds, which aligns with the PR objective to avoid repeated compilation of dependent libraries.

cmake/snappy.cmake (1)

16-16: LGTM: Build optimization through UPDATE_COMMAND

Adding UPDATE_COMMAND "" prevents CMake from running update commands on the snappy repository during builds, which aligns with the PR objective to avoid repeated compilation of dependent libraries.

cmake/zstd.cmake (1)

34-34: Maintain this original UPDATE_COMMAND parameter.

This is the original location of the UPDATE_COMMAND "" parameter. The PR's goal of preventing repeated compilation is already achieved with this line, which explicitly disables update commands during the build process.

@@ -13,6 +13,7 @@ ExternalProject_Add(
GIT_REPOSITORY "https://github.com/madler/zlib.git"
GIT_TAG "v1.2.8"
GIT_SHALLOW true
UPDATE_COMMAND ""
Copy link

@coderabbitai coderabbitai bot Mar 29, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate UPDATE_COMMAND parameter

There's already an identical UPDATE_COMMAND "" parameter at line 29. Having two identical parameters in the same ExternalProject_Add call is redundant and may lead to confusion.

-        UPDATE_COMMAND ""
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
UPDATE_COMMAND ""

Copy link
Collaborator

Choose a reason for hiding this comment

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

看看这个AI的comment,下面的跟这个重复了

Copy link

Choose a reason for hiding this comment

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

@marsevilspirit 是的,您说得对。代码中确实存在重复的 UPDATE_COMMAND "" 参数。一个在第16行(新添加的),另一个在第29行(已经存在的)。在 ExternalProject_Add 函数中只需要一个 UPDATE_COMMAND "" 参数即可达到避免重复编译的目的,保留其中一个就足够了。建议移除其中一处重复的参数。

@@ -30,6 +30,7 @@ ExternalProject_Add(
DOWNLOAD_NAME "openssl-3.2.1.tar.gz"
SOURCE_DIR ${OPENSSL_SOURCE_DIR}
DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND ""
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate UPDATE_COMMAND parameter

There's already an identical UPDATE_COMMAND "" parameter at line 46. Having two identical parameters in the same ExternalProject_Add call is redundant and may lead to confusion.

-        UPDATE_COMMAND ""
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
UPDATE_COMMAND ""

@@ -16,6 +16,7 @@ ExternalProject_Add(
DOWNLOAD_NAME "zstd-1.5.4.tar.gz"
SOURCE_DIR ${zstd_SOURCES_DIR}
DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND ""
Copy link

@coderabbitai coderabbitai bot Mar 29, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Duplicate UPDATE_COMMAND parameter detected.

The UPDATE_COMMAND "" parameter has been added at line 19, but the same parameter already exists at line 34. Having duplicate parameters in the ExternalProject_Add function is redundant and could lead to confusion.

-        UPDATE_COMMAND ""
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
UPDATE_COMMAND ""

Copy link
Collaborator

Choose a reason for hiding this comment

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

看看这个AI的comment,下面的跟这个重复了

Copy link

Choose a reason for hiding this comment

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

@marsevilspirit 您说得对,代码中确实存在重复的 UPDATE_COMMAND "" 参数。在 ExternalProject_Add 函数中,同一个参数出现了两次:

  1. 第19行(本次PR新增的)
  2. 第34行(已经存在的)

建议删除新增的那一行(第19行),保留原来的第34行即可。这样可以避免冗余并保持代码的清晰度,同时仍然能够实现PR目标:通过设置空的更新命令来优化构建过程,避免重复编译依赖库。

Copy link
Collaborator

@marsevilspirit marsevilspirit left a comment

Choose a reason for hiding this comment

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

看一下comment

@@ -13,6 +13,7 @@ ExternalProject_Add(
GIT_REPOSITORY "https://github.com/madler/zlib.git"
GIT_TAG "v1.2.8"
GIT_SHALLOW true
UPDATE_COMMAND ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

看看这个AI的comment,下面的跟这个重复了

@@ -16,6 +16,7 @@ ExternalProject_Add(
DOWNLOAD_NAME "zstd-1.5.4.tar.gz"
SOURCE_DIR ${zstd_SOURCES_DIR}
DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

看看这个AI的comment,下面的跟这个重复了

@lqxhub lqxhub closed this Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants