premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

gmake2: Groups create circular dependencies

Open crazydef opened this issue 1 year ago • 8 comments

What seems to be the problem? When groups are added to a workspace and they contain projects with the same name, the resulting makefile has circular dependencies.

workspace "App"
  group "Core"
    project "Core"
  group ""

The above snippet will generate this line in the makefile:

Core: Core

And make will output the following message:

make: Circular Core <- Core dependency dropped.

This isn't a huge deal (I can just rename the group), but it took me ages to figure this out. So it might be nice to have a warning in Premake about such things, or even just dropping groups from gmake2. (They're an IDE construct after all. I don't know if they bring any value to makefiles.)

What did you expect to happen? I never know what to expect. :)

What have you tried so far? I renamed the group. It's no biggie, but maybe the UX could be improved.

How can we reproduce this? See the above snippet.

  • [ ] Visual Studio 2022 (vs2022)
  • [ ] Visual Studio 2019 (vs2019)
  • [ ] Visual Studio 2017 (vs2017)
  • [ ] Visual Studio 2015 (vs2015)
  • [ ] Visual Studio 2012 (vs2012)
  • [ ] Visual Studio 2010 (vs2010)
  • [ ] Visual Studio 2008 (vs2008)
  • [ ] Visual Studio 2005 (vs2005)
  • [x] GNU Makefile (gmake)
  • [x] GNU Makefile 2 (gmake2)
  • [ ] XCode (xcode)
  • [ ] Codelite
  • [ ] Other (Please list below)

What version of Premake are you using? 5.0.0-dev

crazydef avatar Jul 12 '23 18:07 crazydef

Also apply to gmake.

As I see, group adds rules in makefile to build all projects of the group. I haven't expected group to appear in Makefile, but ok...

Jarod42 avatar Jul 13 '23 08:07 Jarod42

Also apply to gmake.

This will be a non-fix unless the gmake and gmake2 group creation logic is shared.

As I see, group adds rules in makefile to build all projects of the group. I didn't expect group to appear in Makefile...

I fully expect compilation groups to be in makefile, as I can do things like optional projects and such with them (i.e. unit tests).

nickclark2016 avatar Jul 13 '23 09:07 nickclark2016

Just some further review on this. I don't think renaming the group in Premake is a valid option. Personally, I'm a fan of either a "wont fix" or a warning for when there are multiple nodes with the same name in the structure.

nickclark2016 avatar Aug 10 '23 17:08 nickclark2016

For me renaming the group in the my lua file is the easiest option. And it's what I did. For me, it's no biggie. (It's just a folder name in VS.)

But having some warning or error when running Premake would improve the UX and make it easier to debug things like this in the future. As I said, it took me ages to figure out what the actual problem was. (Which wasn't really a problem per se - just an annoying warning from make when building.)

crazydef avatar Aug 10 '23 21:08 crazydef

Actions to Take:

  • Check for multiple elements with the same name
  • If multiple have the same name, emit a warning

This could be done in either the core library or the gmake2 module. Correct location TBD.

nickclark2016 avatar Aug 14 '23 12:08 nickclark2016

As it is an issue only with gmake/gmake2, so check should be done in gmake/gmake2, IMO.

Jarod42 avatar Aug 14 '23 16:08 Jarod42

I guess the question is: Do we want this behavior to be consistent across all of premake, or do we want exporter-specific behavior?

nickclark2016 avatar Aug 14 '23 16:08 nickclark2016

The whole reason for Premake existing is to support multiple toolchains across different OSes/devices. It might seem a bit inconsistent if one reported this and the others didn't. (E.g., everything works on your initial platform and then you suddenly start getting warnings when you move to a second.)

crazydef avatar Aug 14 '23 16:08 crazydef