support dynamic mkspec selection for Qt SDK#7208
Conversation
Fix the qt mkspecsdir path
- Add mkspec variable to store QMAKE_XSPEC or QMAKE_SPEC from Qt environment - Include mkspec in the returned Qt SDK information table - Use dynamic mkspec path instead of hardcoded platform-specific paths - Remove hardcoded mkspec directory paths for macosx, linux, windows, android and wasm platforms - Add include directories using the dynamic mkspec path for proper Qt compilation
Summary of ChangesHello @RC1844, 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 improves the detection and usage of Qt SDK mkspecs directories. It addresses an issue where the mkspecs directory path was incorrectly identified and eliminates the reliance on hardcoded platform-specific paths. By dynamically determining the mkspecs directory using Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic mkspec selection for the Qt SDK, which is a valuable improvement for build flexibility. The logic for identifying the mkspec from the Qt environment appears correct. However, I've found a critical issue in the implementation that will cause a crash and prevent the new feature from working correctly. My review includes a specific comment with a suggested fix to address this. I also noted that the underlying issue might be present in other parts of the file, which would be beneficial to fix for overall stability.
| local includedir = qtenvs.QT_INSTALL_HEADERS | ||
| local mkspecsdir = qtenvs.QMAKE_MKSPECS or path.join(qtenvs.QT_INSTALL_ARCHDATA, "mkspecs") | ||
| local mkspecsdir = qtenvs.QMAKE_MKSPECS or path.join(qtenvs.QT_HOST_DATA, "mkspecs") | ||
| local mkspec = qtenvs.QMAKE_XSPEC or qtenvs.QMAKE_SPEC |
There was a problem hiding this comment.
最好再做下 fallback 的适配,如果 QMAKE_XSPEC 这两都没从 qmake 中取到,继续按现有 plat 判断,给个默认值。
There was a problem hiding this comment.
加在load.lua了,那里加比较方便
- Introduce fallbackmkspec variable to handle mkspec selection - Set platform-specific fallback mkspec values: - macosx: macx-clang - linux: linux-g++ - windows: win32-msvc - mingw: win32-g++ - android: android-clang - wasm: wasm-emscripten - Implement conditional logic to use qt.mkspec when available, otherwise fall back to platform-specific mkspec - Maintain backward compatibility with existing mkspec usage
xmake/rules/qt/load.lua
Outdated
| _add_includedirs(target, path.join(qt.mkspecsdir, qt.mkspec)) | ||
| else | ||
| _add_includedirs(target, path.join(qt.mkspecsdir, fallbackmkspec)) | ||
| end |
There was a problem hiding this comment.
_add_includedirs(target, path.join(qt.mkspecsdir, qt.mkspec or fallbackmkspec))
Replace conditional statement with ternary operator for adding includedirs from qt.mkspecsdir. The logic remains the same but the code is more concise using 'qt.mkspec or fallbackmkspec' instead of explicit if-else condition.
use QT_HOST_DATA instead of QT_INSTALL_ARCHDATA for mkspecs directory
The mkspecs directory path was incorrectly using qtenvs.QT_INSTALL_ARCHDATA,
which has been changed to qtenvs.QT_HOST_DATA to properly locate the mkspecs
directory in Qt installations.
support dynamic mkspec selection for Qt SDK