Closed q4a closed 1 year ago
Hi,
From the links you sent me, the problem seems to come from the uic
tool. The second link you provided has the calls to /usr/bin/moc
, and has the command lines to generate the moc files. But the error (at the end of the log) is:
../code/delta_qt/ui/mainwindow.cpp:26:10: fatal error: 'qtgen/ui_mainwindow.h' file not found
#include "qtgen/ui_mainwindow.h"
^~~~~~~~~~~~~~~~~~~~~~~
And indeed, it seems like the addon failed to generate the custom command to process mainwindow.ui
... I will need to investigate. It's been a while since I didn't use this addon, but from what I remember and from a quick look at qt.lua
, if moc
works, uic
should also work (it's based on the .ui
extension, so if the mainwindow.ui
file is correctly added to the project, I don't understand why it doesn't generate the uic
command line...)
I checked a bit, and it seems there's a problem in premake-core: in module/gmake2/gmake2_cpp.lua
, line 178 and line 181.
On line 181, it seems the buildoutputs
for the current file are tested, and if the current file has some, then it's added as a generated file.
But with the .ui
file, line 178 creates a copy of the file configuration context with 0 build outputs ... and this is why line 181 skips adding the command.
(if you add a print(#filecfg.buildoutputs .. " -> " .. #shadowContext.buildoutputs)
on line 180, you'll see that it prints 1 -> 0
)
I don't know why it does this, but maybe you should raise an issue on the premake-core repository, and mention this one here. I'm not sure if this is a bug on premake-core or on Qt addon...
The only difference between the custom commands using moc
and the ones using uic
is that moc
generates a .cpp
file (which is a compilable file for which gmake2 generates a compilation rule) and uic
generates a header file, which gmake2 seems to ignore...
Hi again,
I did a quick test to see if the problem is indeed coming from the Qt addon or the gmake2 action, and it seems that it is indeed something I do in the addon that is causing the bug (I'll post a comment on the issue you opened on the premake-core repo to let them know)
I'll have to figure out what's wrong though and it might take a bit of time, apologies in advance, but anyway, just wanted to let you know that I didn't forget this issue :p
hi! I'm having similar troubles generating Makefile using gmake2. I don't use UI tools from Qt, but use moc application, I have latest premake5 build for today - alpha15, and head revision of your repo. When I insert logs into premake.extensions.qt.addMOCCustomBuildRule - I am able to see correctly produced moc'ing commands, but they don't appear in project Makefile, they are added to GENERATED and OBJECTS lists, but they never created by moc app using custom build steps, because no custom build steps are produced. I have been able to use vs2017 config on Windows all the time, and this is first time I'm compiling on Ubuntu. I have tried switching to gmake instead of gmake2, and it's producing custom build steps as required, but also fails to create output cpp files, as it seems to be treating relative paths wrong, I have changed to abspath in your script, and then moc is creating them in right place, and everything goes ok. That may be a problem of gmake (I'm about relative paths), because it's deprecated as it's noted in the docs, but currently I'm stick to that hack as it works in my environment. I'm willing to help investigating that bug, can give repro steps, because I really want to use up-to-date and stable gmake2 option here. Thanks!
Hi,
Sorry I don't have much time to work on this. The problem seems to be quite tricky: as you noticed, the addon's functions that generate the custom commands for the moc files are correctly called, but gmake2 doesn't seem to care, while gmake works fine. At first I thought that it was gmake2 that wasn't able to handle custom build commands, but I checked, and it does support them... So basically the problem seems to be some sort of combination of how I generate custom commands + how gmake2 handles them. Unfortunately I couldn't find what exactly.
I'll try to get back to this issue if I can find some spare time, but in the meantime if you find the bug, do not hesitate to comment here.
Regards
In the PR https://github.com/dcourtois/premake-qt/pull/21
I add 2 scripts one with that premake module, and one without.
For uic
, the alternative is fine: you can use premake rule
Something like
rule "uic"
display "uic"
fileextension ".ui"
buildmessage 'uic -o ../../obj/%{file.basename} %{file.relpath}'
--buildinputs { "%{file.relpath}" }
buildoutputs { path.join("obj", "ui_%{file.basename}.h") }
buildcommands { path.join(QtRoot, "bin", "uic") .. " -o " .. path.join("../../obj", "ui_%{file.basename}.h") .. " %{file.relpath}" }
and then, in the project:
rules { "uic" }
I will try to fix other generators.
Created https://github.com/premake/premake-core/pull/2047 which fixes gmake2
Fixed by 16b7041ce2efd1f7ca36e334a0a3af187ade7c8f
Hi. I have some wiered behavior when using premake-qt with premake v5.0.0-alpha14 when I'm trying to add custom command, created with addMOCCustomBuildRule. This is open source project, so I'll point to it's code. Main problem is that addMOCCustomBuildRule working on Windows and I can see lines like:
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"C:\Qt\5.14.0\msvc2017_64/bin/moc" "../code/delta_qt/ui/logframe.h" -o "../code/delta_qt/qtgen/moc_logframe.cpp" -DFXNAME="PS4Delta" -DFXNAME_WIDE=L"PS4Delta" -DDELTA_DBG -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -Drsc_company="Dev-Force/Alpin-Dev" -Drsc_copyright="(C) Force67 2019-2020. All rights reserved" -Drsc_fileversion="1.0.0.0" -Drsc_productversion="1.0.0.0" -Drsc_internalname="delta-qt" -Drsc_productname="PS4Delta" -Drsc_originalname="delta-qt.dll" -Drsc_description="PS4Delta core - with qt" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_OPENGL_LIB -DQT_QML_LIB -I"../code/delta_qt" -I"../code/common" -I"../code/common/utl" -I"../code/core" -I"../code/core/orbis" -I"../code/video_core" -I"../code/vendor/fmtlib/include" -I"../code/vendor/capstone/include" -I"../code/vendor/zlib" -I"../code/vendor/xbyak/xbyak" -I"C:/Qt/5.14.0/msvc2017_64/include" -I"C:/Qt/5.14.0/msvc2017_64/include/QtCore" -I"C:/Qt/5.14.0/msvc2017_64/include/QtGui" -I"C:/Qt/5.14.0/msvc2017_64/include/QtWidgets" -I"C:/Qt/5.14.0/msvc2017_64/include/QtOpenGL" -I"C:/Qt/5.14.0/msvc2017_64/include/QtQml" -I"../code/delta_qt/qtgen"</Command>
indelta-qt.vcxproj
file: https://ci.appveyor.com/project/q4a/ps4delta/builds/30674575/job/bowaalmkws2eg4gj#L58But not working on Linux. There is no using
/usr/bin/moc
indelta-qt.make
file: https://ci.appveyor.com/project/q4a/ps4delta/builds/30674575/job/o75820tvxxki5h64#L453Is this bug of premake, premake-qt or mine? Can you help me to fix it?
I already build lastest premake from source but error still here. Also I added 2 prints to
addMOCCustomBuildRule
in premake-qt: https://github.com/q4a/ps4delta/blob/f9c30bce929c767ffebc3d00246177f75bca099e/tools/premake/premake-qt/qt.lua#L621And got good custom commands on Windows: https://ci.appveyor.com/project/q4a/ps4delta/builds/30674575/job/bowaalmkws2eg4gj#L24 And Linux: https://ci.appveyor.com/project/q4a/ps4delta/builds/30674575/job/o75820tvxxki5h64#L413