Skip to content

support dynamic mkspec selection for Qt SDK#7208

Merged
waruqi merged 4 commits intoxmake-io:devfrom
RC1844:patch-4
Jan 12, 2026
Merged

support dynamic mkspec selection for Qt SDK#7208
waruqi merged 4 commits intoxmake-io:devfrom
RC1844:patch-4

Conversation

@RC1844
Copy link
Contributor

@RC1844 RC1844 commented Jan 10, 2026

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

  • 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

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
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 QT_HOST_DATA and incorporating the specific mkspec from the Qt environment, the changes provide a more robust, flexible, and maintainable configuration for Qt projects across various platforms.

Highlights

  • Mkspecs Directory Path Correction: The calculation for the mkspecsdir path has been corrected to use QT_HOST_DATA instead of the previously incorrect QT_INSTALL_ARCHDATA.
  • Dynamic Mkspec Selection: A new mkspec variable is introduced to dynamically store the specific mkspec (either QMAKE_XSPEC or QMAKE_SPEC) from the Qt environment.
  • Qt SDK Information Table Update: The newly determined mkspec is now included in the returned Qt SDK information table, making it accessible for further configuration.
  • Removal of Hardcoded Mkspec Paths: Platform-specific hardcoded mkspec include paths have been replaced with a single dynamic path derived from the detected mkspecsdir and mkspec.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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
Copy link
Member

Choose a reason for hiding this comment

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

最好再做下 fallback 的适配,如果 QMAKE_XSPEC 这两都没从 qmake 中取到,继续按现有 plat 判断,给个默认值。

Copy link
Contributor Author

@RC1844 RC1844 Jan 11, 2026

Choose a reason for hiding this comment

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

加在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
@RC1844 RC1844 requested a review from waruqi January 11, 2026 05:53
_add_includedirs(target, path.join(qt.mkspecsdir, qt.mkspec))
else
_add_includedirs(target, path.join(qt.mkspecsdir, fallbackmkspec))
end
Copy link
Member

Choose a reason for hiding this comment

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

        _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.
@RC1844 RC1844 requested a review from waruqi January 11, 2026 13:50
@waruqi waruqi closed this Jan 11, 2026
@waruqi waruqi reopened this Jan 11, 2026
@waruqi waruqi added this to the v3.0.7 milestone Jan 11, 2026
@waruqi waruqi merged commit 0bb0eca into xmake-io:dev Jan 12, 2026
55 of 73 checks passed
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