xmake icon indicating copy to clipboard operation
xmake copied to clipboard

改进Qt程序编写时运行uic,moc时附带编译的性能问题

Open MMitsuha opened this issue 2 years ago • 3 comments

你在什么场景下需要该功能?

编写Qt程序时,会用到.ui等需要qt的uic之类进行预处理的文件,但是修改xxx.ui文件后要在ui_xxx.h中体现出来只能通过运行xmake build,让xmake运行uic,但是此时我正在编写中,xmake build很快运行完uic后开始尝试编译,此时编译必然失败(因为还没写完,我只是想让修改在文件中,在智能补全中体现),导致不必要的等待

描述可能的解决方案

.ui文件放入单独的target

描述你认为的候选方案

No response

其他信息

我尝试了可能的解决方法,但是无奈uic编译出的文件并没有public,所以所以用add deps没获取到,希望能有更好的解决方法 失败的方法

MMitsuha avatar Dec 15 '23 05:12 MMitsuha

Bot detected the issue body's language is not English, translate it automatically.


Title: Improve the performance issues of running uic and moc when writing Qt programs and compiling them

In what scenario do you need this feature?

When writing Qt programs, files such as .ui that require qt's uic for preprocessing will be used. However, after modifying the xxx.ui file, it will be reflected in ui_xxx.h and can only be run xmake build, let xmake run uic, but I am writing at this time. xmake build will soon finish running uic and then start trying to compile. At this time, the compilation must fail (because it has not been finished yet, I just want the changes to be reflected in the file and reflected in smart completion), resulting in unnecessary waiting

Describe possible solutions

Put the .ui file into a separate target

Describe your alternatives

No response

other information

I tried possible solutions, but unfortunately the files compiled by uic were not public, so I couldn’t get them using add deps. I hope there is a better solution. Failed method

Issues-translate-bot avatar Dec 15 '23 05:12 Issues-translate-bot

qt.widgetapp rule 生成的 binary, 你走 add_deps ,等于是生成两个 app

另外,纯 .ui 没 cpp 文件,就没法识别成 cpp 程序

target("xxx")
    add_rules("qt.static", "c++")
    add_files("*.ui")

可以尝试走 static ,并显式设置 c++ rule,不过我也不保证可以,我也没试过。

waruqi avatar Dec 23 '23 15:12 waruqi

Bot detected the issue body's language is not English, translate it automatically.


For the binary generated by qt.widgetapp rule, if you use add_deps, it will generate two apps.

In addition, pure .ui without a cpp file cannot be recognized as a cpp program.

target("xxx")
    add_rules("qt.static", "c++")
    add_files("*.ui")

You can try to use static and explicitly set the c++ rule, but I don't guarantee that it will work, and I haven't tried it either.

Issues-translate-bot avatar Dec 23 '23 15:12 Issues-translate-bot