-
Notifications
You must be signed in to change notification settings - Fork 19
fix: optimize lrelease command with additional flags #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The lrelease command in the CMake build process has been enhanced with additional flags for better performance and output quality. The changes include adding -compress flag to reduce the size of generated .qm files, -nounfinished to exclude unfinished translations, and -removeidentical to remove identical translations. Additionally, a new custom target 'generate_qm' has been added to ensure all .qm files are generated as part of the build process. Influence: 1. Verify that .qm files are correctly generated during build 2. Check that translation files are smaller in size due to compression 3. Ensure unfinished translations are properly excluded from final output 4. Test that identical translations are removed to avoid redundancy 5. Confirm the generate_qm target builds all translation files as expected fix: 优化 lrelease 命令并添加额外标志 CMake 构建过程中的 lrelease 命令已通过附加标志进行增强,以提高性 能和输出质量。更改包括添加 -compress 标志以减少生成的 .qm 文件大 小,-nounfinished 以排除未完成的翻译,以及 -removeidentical 以移除相同的 翻译。此外,新增了一个自定义目标 'generate_qm',以确保所有 .qm 文件作为 构建过程的一部分被生成。 Influence: 1. 验证构建过程中 .qm 文件是否正确生成 2. 检查翻译文件是否因压缩而体积变小 3. 确保未完成的翻译被正确排除在最终输出之外 4. 测试相同的翻译是否被移除以避免冗余 5. 确认 generate_qm 目标按预期构建所有翻译文件
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnhances the CMake lrelease-based translation build pipeline by adding optimization flags to the lrelease command and introducing a dedicated generate_qm target that ensures all .qm files are generated as part of the standard build. Sequence diagram for build invoking generate_qm and lrelease with new flagssequenceDiagram
actor Dev
participant BuildSystem as Build_system
participant CMake as CMake_generator
participant TargetGenerateQM as Target_generate_qm
participant Lrelease as lrelease
participant FileSystem as File_system
Dev->>BuildSystem: Invoke build (e.g. make, ninja)
BuildSystem->>CMake: Configure project
CMake-->>BuildSystem: Generated build files with target generate_qm ALL
Dev->>BuildSystem: Build ALL
BuildSystem->>TargetGenerateQM: Execute custom target generate_qm
loop For each .ts file
TargetGenerateQM->>Lrelease: lrelease -compress -nounfinished -removeidentical TS_FILE -qm QM_FILE
Lrelease->>FileSystem: Read TS_FILE
Lrelease->>FileSystem: Write compressed QM_FILE without unfinished or identical translations
end
TargetGenerateQM-->>BuildSystem: All .qm files generated
BuildSystem-->>Dev: Build finished including translation artifacts
Flow diagram for updated lrelease translation generation in CMakeflowchart TD
subgraph Inputs
TS1[".ts translation file 1"]
TS2[".ts translation file 2"]
TSn[".ts translation file N"]
end
subgraph CMake_Config["CMake configuration phase"]
CFG_GEN_QM["Define custom commands to generate .qm from each .ts"]
CFG_TARGET["Define custom target generate_qm with ALL and DEPENDS on all .qm files"]
end
subgraph Build_Phase["Build phase"]
TARGET_GENERATE_QM["Custom target generate_qm"]
LRELEASE_CMD["Run lrelease with flags -compress -nounfinished -removeidentical"]
end
TS1 --> CFG_GEN_QM
TS2 --> CFG_GEN_QM
TSn --> CFG_GEN_QM
CFG_GEN_QM --> CFG_TARGET
CFG_TARGET --> TARGET_GENERATE_QM
TARGET_GENERATE_QM --> LRELEASE_CMD
LRELEASE_CMD --> QM1["Compressed .qm file 1 (no unfinished, identical removed)"]
LRELEASE_CMD --> QM2["Compressed .qm file 2 (no unfinished, identical removed)"]
LRELEASE_CMD --> QMn["Compressed .qm file N (no unfinished, identical removed)"]
subgraph Outputs
QM1
QM2
QMn
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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:
- Consider using the Qt-provided lrelease executable (e.g., via Qt6::lrelease/Qt5::lrelease or a CMake variable) instead of a bare
lreleasecommand to avoid path/portability issues across environments. - The
-compress,-nounfinished, and-removeidenticalflags may not be supported uniformly across all Qt versions; you may want to guard their usage with a version check or make them configurable so older toolchains don’t break. - Attaching
generate_qmtoALLmeans.qmfiles will be regenerated on every normal build; if this is expensive, consider making it an opt-in target or tightening the dependencies to avoid unnecessary rebuilds.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using the Qt-provided lrelease executable (e.g., via Qt6::lrelease/Qt5::lrelease or a CMake variable) instead of a bare `lrelease` command to avoid path/portability issues across environments.
- The `-compress`, `-nounfinished`, and `-removeidentical` flags may not be supported uniformly across all Qt versions; you may want to guard their usage with a version check or make them configurable so older toolchains don’t break.
- Attaching `generate_qm` to `ALL` means `.qm` files will be regenerated on every normal build; if this is expensive, consider making it an opt-in target or tightening the dependencies to avoid unnecessary rebuilds.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Kakueeen, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
The lrelease command in the CMake build process has been enhanced with
additional flags for better performance and output quality. The changes
include adding -compress flag to reduce the size of generated .qm files,
-nounfinished to exclude unfinished translations, and -removeidentical
to remove identical translations. Additionally, a new custom target
'generate_qm' has been added to ensure all .qm files are generated as
part of the build process.
Influence:
output
expected
fix: 优化 lrelease 命令并添加额外标志
CMake 构建过程中的 lrelease 命令已通过附加标志进行增强,以提高性
能和输出质量。更改包括添加 -compress 标志以减少生成的 .qm 文件大
小,-nounfinished 以排除未完成的翻译,以及 -removeidentical 以移除相同的
翻译。此外,新增了一个自定义目标 'generate_qm',以确保所有 .qm 文件作为
构建过程的一部分被生成。
Influence:
Summary by Sourcery
Optimize Qt translation generation in the CMake build by enhancing the lrelease invocation and ensuring all .qm files are built as part of the standard build process.
Build: