Skip to content

Conversation

RubMaker
Copy link

  • 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消息,不要用中文,请用英文描述。

Copy link
Contributor

Summary of Changes

Hello @RubMaker, 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 introduces a new utility module to Xmake designed to streamline the process of finding Qt deployment tools across various operating systems. By automatically identifying the correct deployqt executable and including platform-specific search paths, it aims to simplify the integration of Qt application deployment within Xmake-based projects, ensuring a more robust and portable build experience.

Highlights

  • New Module Added: A new Lua module, find_deployqt.lua, has been introduced to the xmake/modules/detect/tools directory.
  • Qt Deployment Tool Detection: This module provides functionality to automatically detect and locate platform-specific Qt deployment tools, such as windeployqt for Windows, macdeployqt for macOS, and linuxdeployqt for Linux.
  • Platform-Specific Search Paths: The detection logic includes predefined, common installation paths for Qt across Windows, macOS, and Linux to enhance the reliability of finding the correct deployment tool.
  • Tool Verification: A check function is implemented to verify the detected tool's functionality by executing it with the --help argument, ensuring it is a valid and working executable.
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 a new detection module for Qt's deployment tools (windeployqt, macdeployqt, linuxdeployqt). The overall approach is good, but there are a few issues to address. There's a logical error in the program check function that causes it to always fail. Also, the handling of the QTDIR environment variable could lead to incorrect behavior when it's not set. I've also pointed out some minor style issues like trailing whitespace and a missing newline at the end of the file to align with the project's conventions. My suggestions aim to improve the robustness and correctness of the new module.

Comment on lines +34 to +46
opt.check = opt.check or function (program)
-- check version to verify the program is working
if is_host("windows") then
-- windeployqt --help should return successfully
os.run("%s --help", program)
elseif is_host("macosx") then
-- macdeployqt --help should return successfully
os.run("%s --help", program)
else
-- assume linux, linuxdeployqt --help should return successfully
os.run("%s --help", program)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The check function doesn't explicitly return a value, so it implicitly returns nil. This will cause the check to fail for any program found. You should return the result of os.run. Additionally, the if/elseif/else block is redundant because the same command is executed for all platforms. The function can be simplified significantly.

    opt.check = opt.check or function (program)
        -- check version to verify the program is working
        -- windeployqt/macdeployqt/linuxdeployqt --help should return successfully
        return os.run("%s --help", program)
    end

-- common Qt installation paths on Windows
table.insert(opt.paths, "C:\\Qt\\*\\bin")
table.insert(opt.paths, "C:\\Qt\\Tools\\*\\bin")
table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin"))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

When the QTDIR environment variable is not set or is empty, path.join(os.getenv("QTDIR") or "", "bin") can resolve to an unintended absolute path (e.g., C:\bin on Windows). This could lead to finding an incorrect tool or unnecessary filesystem searches. It's safer to add this path only when QTDIR is set to a non-empty string.

            local qtdir = os.getenv("QTDIR")
            if qtdir and #qtdir > 0 then
                table.insert(opt.paths, path.join(qtdir, "bin"))
            end

table.insert(opt.paths, "/usr/local/Qt*/*/bin")
table.insert(opt.paths, "~/Qt/*/bin")
table.insert(opt.paths, "/opt/Qt*/*/bin")
table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin"))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Similar to the Windows case, when the QTDIR environment variable is not set or is empty, an unintended path might be searched. It's better to only add the path if QTDIR is defined and not empty.

            local qtdir = os.getenv("QTDIR")
            if qtdir and #qtdir > 0 then
                table.insert(opt.paths, path.join(qtdir, "bin"))
            end

table.insert(opt.paths, "/opt/qt*/bin")
table.insert(opt.paths, "/usr/local/qt*/bin")
table.insert(opt.paths, "~/Qt/*/bin")
table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin"))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Similar to the Windows and macOS cases, when the QTDIR environment variable is not set or is empty, an unintended path might be searched. It's better to only add the path if QTDIR is defined and not empty.

            local qtdir = os.getenv("QTDIR")
            if qtdir and #qtdir > 0 then
                table.insert(opt.paths, path.join(qtdir, "bin"))
            end

if is_host("windows") then
program_name = "windeployqt"
elseif is_host("macosx") then
program_name = "macdeployqt"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is a trailing whitespace character at the end of this line. It should be removed for code cleanliness.

            program_name = "macdeployqt"

elseif is_host("macosx") then
-- common Qt installation paths on macOS
table.insert(opt.paths, "/usr/local/Qt*/*/bin")
table.insert(opt.paths, "~/Qt/*/bin")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is a trailing whitespace character at the end of this line. It should be removed for code cleanliness.

            table.insert(opt.paths, "~/Qt/*/bin")


-- find program
return find_program(program_name, opt)
end No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This file is missing a newline character at the end. Most files in this project end with a newline, so it would be good to add one for consistency.

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.

1 participant