-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
WalkthroughThis pull request updates several CMake configuration files by adding an Changes
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
Suggested labels
Suggested reviewers
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
: DuplicateUPDATE_COMMAND ""
parameterThere'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
: DuplicateUPDATE_COMMAND ""
parameterThere'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
: DuplicateUPDATE_COMMAND ""
parameterThere'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 detectedThe
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 detectedThe
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 detectedThe
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
📒 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 ofUPDATE_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 updatesAdding
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_COMMANDAdding
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_COMMANDAdding
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 "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
UPDATE_COMMAND "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看看这个AI的comment,下面的跟这个重复了
There was a problem hiding this comment.
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 "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
UPDATE_COMMAND "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看看这个AI的comment,下面的跟这个重复了
There was a problem hiding this comment.
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
函数中,同一个参数出现了两次:
- 第19行(本次PR新增的)
- 第34行(已经存在的)
建议删除新增的那一行(第19行),保留原来的第34行即可。这样可以避免冗余并保持代码的清晰度,同时仍然能够实现PR目标:通过设置空的更新命令来优化构建过程,避免重复编译依赖库。
There was a problem hiding this 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 "" |
There was a problem hiding this comment.
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 "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看看这个AI的comment,下面的跟这个重复了
尝试优化cmake编译, 避免在编译时重复编译依赖的第三方库
fix:#228
Summary by CodeRabbit