Conversation
waruqi
commented
Dec 2, 2025
- Before adding new features and new modules, please go to issues to submit the relevant feature description first.
- Write good commit messages and use the same coding conventions as the rest of the project.
- Please commit code to dev branch and we will merge into master branch in feature
- Ensure your edited codes with four spaces instead of TAB.
- 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
- 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
- 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
- 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。
Summary of ChangesHello @waruqi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the C++ and Objective-C build rules within Xmake to improve modularity and maintainability. By centralizing configuration logic into dedicated Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
366f442 to
597839a
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors the C++ and Objective-C++ rules to centralize configuration logic, which is a great improvement for modularity and code reuse. I've found a couple of areas where the new code can be made more maintainable. Specifically, I've suggested refactoring some duplicated logic in the new Objective-C++ basic configuration and improving the readability of flag selection in the optimization configuration.
| local flagnames = { | ||
| cc = "cflags", | ||
| cxx = "cxxflags", | ||
| mm = "mflags", | ||
| mxx = "mxxflags" | ||
| } | ||
| local cflag = flagnames[sourcekind] or (sourcekind == "cxx" and "cxxflags" or "cflags") |
There was a problem hiding this comment.
This block can be made more readable. While the or chain works, separating the lookup from the fallback logic improves clarity and maintainability, especially for developers who may not be deeply familiar with this part of the codebase.
local flagnames = {
cc = "cflags",
cxx = "cxxflags",
mm = "mflags",
mxx = "mxxflags"
}
local cflag = flagnames[sourcekind]
if not cflag then
-- Fallback for other source kinds to maintain previous behavior.
cflag = sourcekind == "cxx" and "cxxflags" or "cflags"
end
xmake/rules/objc++/config/basic.lua
Outdated
| if sourcekind == "mm" then | ||
| -- deprecated, we only need to use `add_mflags("-fno-objc-arc")` to override it | ||
| if target:values("objc.build.arc") == false then | ||
| target:add("mflags", "-fno-objc-arc") | ||
| end | ||
| if target:is_plat("macosx", "iphoneos", "watchos") then | ||
| target:add("frameworks", "Foundation", "CoreFoundation") | ||
| end | ||
| elseif sourcekind == "mxx" then | ||
| -- deprecated, we only need to use `add_mxxflags("-fno-objc-arc")` to override it | ||
| if target:values("objc++.build.arc") == false then | ||
| target:add("mxxflags", "-fno-objc-arc") | ||
| end | ||
| if target:is_plat("macosx", "iphoneos", "watchos") then | ||
| target:add("frameworks", "Foundation", "CoreFoundation") | ||
| end | ||
| end |
There was a problem hiding this comment.
The logic for mm and mxx source kinds is very similar, leading to code duplication. You can refactor this to be more concise and maintainable by using a configuration table. This also makes it easier to add support for other similar source kinds in the future.
local configs = {
mm = {arc_value = "objc.build.arc", flags = "mflags"},
mxx = {arc_value = "objc++.build.arc", flags = "mxxflags"}
}
local config = configs[sourcekind]
if config then
-- deprecated, we only need to use `add_mflags("-fno-objc-arc")` to override it
if target:values(config.arc_value) == false then
target:add(config.flags, "-fno-objc-arc")
end
if target:is_plat("macosx", "iphoneos", "watchos") then
target:add("frameworks", "Foundation", "CoreFoundation")
end
end
2eb8228 to
a3f3678
Compare