Skip to content

Conversation

@hillwoodroc
Copy link

@hillwoodroc hillwoodroc commented Dec 12, 2025

fix:(cmake) Improve Qt lrelease detection for translation generation

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hillwoodroc

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot
Copy link

Hi @hillwoodroc. Thanks for your PR. 😃

@deepin-ci-robot
Copy link

Hi @hillwoodroc. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts file permission logging for Qt 6.10+ compatibility and improves detection of the Qt lrelease tool in the translation generation CMake script.

Flow diagram for QFileInfo permission logging with Qt version check

flowchart TD
  Start[Start main logging block] --> CreateFileInfo[Create QFileInfo from path]
  CreateFileInfo --> CheckQtVersion{QT_VERSION >= 6.10.0?}
  CheckQtVersion -- Yes --> LogUintPerm[Log file info with permissions cast to uint]
  CheckQtVersion -- No --> LogPerm[Log file info with raw permissions]
  LogUintPerm --> End[Continue program]
  LogPerm --> End
Loading

Flow diagram for improved Qt lrelease detection in translation generation

flowchart TD
  Start[Start TRANSLATION_GENERATE function] --> FindLinguistTools[find_package QtLinguistTools]
  FindLinguistTools --> FindLrelease[find_program Qt_LRELEASE_EXECUTABLE in standard Qt bin paths]
  FindLrelease --> CheckFound{Qt_LRELEASE_EXECUTABLE found?}
  CheckFound -- Yes --> UseFound[Use found Qt_LRELEASE_EXECUTABLE]
  CheckFound -- No --> SetFallback[Set QT_LRELEASE to /lib/qt$QT_VERSION_MAJOR/bin/lrelease]
  SetFallback --> LogMessage[message STATUS about fallback QT_LRELEASE]
  UseFound --> End[End TRANSLATION_GENERATE]
  LogMessage --> End
Loading

File-Level Changes

Change Details Files
Make QFileInfo::permissions() logging compatible with Qt 6.10+ while keeping behavior for older Qt versions.
  • Wrap the qInfo logging statement with a QT_VERSION check for 6.10.0 and above
  • Cast QFile::permissions() result to unsigned int for Qt 6.10+ to ensure it logs correctly
  • Fix the log message typo from 'permssion' to 'permission'
src/main.cpp
Improve CMake detection of the Qt lrelease executable for translation generation.
  • Introduce find_program call to locate lrelease in common Qt binary directories for the current major version
  • Retain fallback QT_LRELEASE path and status message when lrelease is not found
cmake/translation-generate.cmake

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • For the QFileInfo::permissions logging, consider using the same representation across all Qt versions (e.g., always static_cast<uint>(fileInfo.permissions())) so log format stays consistent regardless of the Qt version compiled against.
  • In translation-generate.cmake, find_program(Qt${QT_VERSION_MAJOR}_LRELEASE_EXECUTABLE ...) never populates QT_LRELEASE when it succeeds, so you may want to assign QT_LRELEASE from Qt${QT_VERSION_MAJOR}_LRELEASE_EXECUTABLE to ensure the found binary is actually used.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- For the QFileInfo::permissions logging, consider using the same representation across all Qt versions (e.g., always `static_cast<uint>(fileInfo.permissions())`) so log format stays consistent regardless of the Qt version compiled against.
- In `translation-generate.cmake`, `find_program(Qt${QT_VERSION_MAJOR}_LRELEASE_EXECUTABLE ...)` never populates `QT_LRELEASE` when it succeeds, so you may want to assign `QT_LRELEASE` from `Qt${QT_VERSION_MAJOR}_LRELEASE_EXECUTABLE` to ensure the found binary is actually used.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@hillwoodroc hillwoodroc force-pushed the master branch 3 times, most recently from d1ef13b to faf93f7 Compare January 7, 2026 15:54
@lzwind
Copy link
Contributor

lzwind commented Jan 14, 2026

We need to resolve the conflicts, and also note that our system supports Qt5 compilation, which requires dual authentication.

@github-actions
Copy link

github-actions bot commented Jan 15, 2026

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve Qt lrelease detection for translation generation in CMake. However, the changes introduce critical bugs that break the translation generation functionality.

Changes:

  • Modified find_package to use REQUIRED and COMPONENTS syntax for Qt LinguistTools
  • Replaced fallback logic with version-specific lrelease detection for Qt6 vs Qt5
  • Removed input validation for the translation directory parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return()
set(QT_LRELEASE "lupdate")
endif()

Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The validation check that ensures ARGN (the translation directory path) is provided has been removed. Without this check, if the function is called without a directory path, it will silently fail or produce unexpected behavior when trying to find .ts files on line 13. The original error message provided clear feedback about incorrect usage.

Suggested change
# Ensure a translation directory path is provided
if (NOT ARGN)
message(FATAL_ERROR "TRANSLATION_GENERATE requires a translation directory path argument (e.g. translations).")
endif()

Copilot uses AI. Check for mistakes.
if(NOT ARGN)
message(SEND_ERROR "Error: TRANSLATION_GENERATE() called without any .ts path")
return()
set(QT_LRELEASE "lupdate")
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

For Qt5, the code should retrieve the lrelease executable path similar to Qt6. The current hardcoded string "lrelease" may not work if the lrelease binary is not in the system PATH. Consider using get_target_property with Qt5::lrelease or the Qt5_LRELEASE_EXECUTABLE variable that was available from find_package.

Suggested change
set(QT_LRELEASE "lupdate")
if (TARGET Qt5::lrelease)
get_target_property(QT_LRELEASE Qt5::lrelease LOCATION)
elseif(DEFINED Qt5_LRELEASE_EXECUTABLE)
set(QT_LRELEASE "${Qt5_LRELEASE_EXECUTABLE}")
else()
# Fallback: rely on lrelease being in PATH
set(QT_LRELEASE "lrelease")
endif()

Copilot uses AI. Check for mistakes.
@hillwoodroc hillwoodroc force-pushed the master branch 2 times, most recently from 4df096c to d726f70 Compare January 19, 2026 13:02
@hillwoodroc hillwoodroc changed the title Multiple fix fix:(cmake) Improve Qt lrelease detection for translation generation Jan 19, 2026
Use Qt6::lrelease imported target from Qt6 LinguistTools instead of
manually guessing the lrelease path, fixing build failures when the
command cannot be found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants