premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.18k stars 617 forks source link

gmake2 action looses custom build rules added programmatically. #1916

Open dcourtois opened 2 years ago

dcourtois commented 2 years ago

I'm "maintaining" a small addon used to add support for Qt (https://github.com/dcourtois/premake-qt/) In this addon, I'm overriding a few Premake functions to scan project files, add generated ones, and setup their build commands. It works fine for most actions, but the custom build commands are completely ignored by the gmake2 one.

I've narrowed down the problem to this line: https://github.com/premake/premake-core/blob/ea2971dd50d048582d646d12d9e50253f6f6731c/modules/gmake2/gmake2_cpp.lua#L178

This line "loses" the buildOutputs in the case of build commands added by my addon: if I print the number of buildOutputs of filecfg, it shows 1, but on shadowContext, it's 0. Thing is if I add a custom rule in my project (using the usual filter and buildcommands, etc.) then shadowContext still retain the buildOutputs.

I'm rusty in Lua and Premake and my Decoda stopped working for some reason, so I'm having a bit of trouble to understand if the issue is a bug in gmake2 or in my addon, and I'm not sure how to fix this.

For reference, here is how my addon adds custom build rules: https://github.com/dcourtois/premake-qt/blob/a79003c5ae2589a1d6ea84838d92ca30116ad4b2/qt.lua#L470 And the generated files are added directly to the list of files in my override of premake.oven.bakeFiles: https://github.com/dcourtois/premake-qt/blob/a79003c5ae2589a1d6ea84838d92ca30116ad4b2/qt.lua#L337

Any help, pointer, etc. appreciated!

Jarod42 commented 2 years ago

In addition, https://github.com/Jarod42/premake-sample-projects now provides also sample projects for premake-qt for testing. (Fixed Ninja, looking at Codelite/Codeblocks issues currently).