premake / premake-core

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

gmake and gmake OBJDIR contains '|' char #1572

Closed chowette closed 3 years ago

chowette commented 3 years ago

What seems to be the problem? When using platforms, configurations and %{cfg.longname} in objdir, it get expanded to something containing a '|' char that fail to build.

workspace "test"
  platforms {"x86", "x64"}
  configurations { "Debug", "Release"}
  objdir ("build/obj/%{prj.name}/%{cfg.longname}")

  project "mainApp"
    kind "ConsoleApp"
    files "mainApp.cpp"

premake5 gmake (or gmake2) output this

...
OBJDIR = obj/mainApp/Debug|x64
...

What did you expect to happen? I expect the offending '|' to be substituted to '_'

What have you tried so far? using '%{cfg.sortname}' workaround this problem, but I did loose way too long on this ...

How can we reproduce this? See the previous premake5.lua file

What version of Premake are you using? last version, both official and master show the same behavior.

Anything else we should know? Using %{cfg.longname} works as expected with VS2019

samsinsane commented 3 years ago

This seems to be working as intended? https://github.com/premake/premake-core/blob/0bf4fb6d096318f7774dc9d5e8ec65a47f06cce9/src/base/oven.lua#L779-L781

These have been like this for at least 7 years.

@starkos what's the purpose of longname? I can see the purpose of shortname is that it's compatible in paths, but longname doesn't seem to have any real purpose?

chowette commented 3 years ago

Ok, the longname is working as intended (feature, not a bug) as long as the documentation explain the difference with shortname but maybe gmake and gmake2 should escape special char in makefile to avoid this very strange error message. Somebody else could use other char in the objdir(). I was bitten by developing my premake file on windows with vs2019 and getting greeted by a make error on linux...

I see a function gmake.esc() that could be expanded and used to make this substitution. https://github.com/premake/premake-core/blob/9b8b035a8a3603f9fab0b50694dc81070767b502/modules/gmake2/gmake2.lua#L54-L64

in the gmake2.objdir() https://github.com/premake/premake-core/blob/9b8b035a8a3603f9fab0b50694dc81070767b502/modules/gmake2/gmake2.lua#L355-L357

What do you think?

starkos commented 3 years ago

@starkos what's the purpose of longname?

Oh, hell if I know. From a quick code search for cfg.name it looks like its used to show a human-readable identifier for the build config + platform pair for validation messages mostly.

Going to mark this one as closed, by design. Using cfg.shortname or rolling your own with cfg.buildCfg and cfg.platform seems the correct approach here.