premake / premake-core

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

Build commands in makefile utilities do not seem to run #2134

Open tommitytom opened 1 year ago

tommitytom commented 1 year ago

What seems to be the problem?

workspace "Foo"
    configurations { "Debug" }
    project "Bar"
        kind "Utility"
        postbuildcommands { "echo Hello" }
$ premake5 gmake2
Building configurations...
Running action 'gmake2'...
Done (35ms).

$ make
==== Building Bar (debug) ====

What did you expect to happen? I expected "Hello" to be printed to the console

What have you tried so far?

$ make
$ make Bar
$ make Bar.make
$ make Bar.make all

Seems to also be an issue with prebuildcommands too. Works as expected with vs2022.

How can we reproduce this? See above.

What version of Premake are you using? Note that although this says I am using a -dev version, I grabbed it directly from premake-5.0.0-beta2-linux.tar.gz

$ ./premake5 --version
premake5 (Premake Build Script Generator) 5.0.0-dev

Anything else we should know?

$ make -v
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
nickclark2016 commented 1 year ago

Could you also upload the makefile that was generated?

tommitytom commented 1 year ago

Sure!

Makefile

# Alternative GNU Make workspace makefile autogenerated by Premake

ifndef config
  config=debug
endif

ifndef verbose
  SILENT = @
endif

ifeq ($(config),debug)
  Bar_config = debug

else
  $(error "invalid configuration $(config)")
endif

PROJECTS := Bar

.PHONY: all clean help $(PROJECTS) 

all: $(PROJECTS)

Bar:
ifneq (,$(Bar_config))
    @echo "==== Building Bar ($(Bar_config)) ===="
    @${MAKE} --no-print-directory -C . -f Bar.make config=$(Bar_config)
endif

clean:
    @${MAKE} --no-print-directory -C . -f Bar.make clean

help:
    @echo "Usage: make [config=name] [target]"
    @echo ""
    @echo "CONFIGURATIONS:"
    @echo "  debug"
    @echo ""
    @echo "TARGETS:"
    @echo "   all (default)"
    @echo "   clean"
    @echo "   Bar"
    @echo ""
    @echo "For more information, see https://github.com/premake/premake-core/wiki"

Bar.make

# Alternative GNU Make project makefile autogenerated by Premake

ifndef config
  config=debug
endif

ifndef verbose
  SILENT = @
endif

.PHONY: clean prebuild

SHELLTYPE := posix
ifeq (.exe,$(findstring .exe,$(ComSpec)))
    SHELLTYPE := msdos
endif

# Configurations
# #############################################

define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
    @echo Running postbuild commands
    echo Hello
endef

# File sets
# #############################################

# Rules
# #############################################

all: $(TARGETDIR) $(TARGET)
    @:

$(TARGET): 
    $(PREBUILDCMDS)
    $(PRELINKCMDS)
    $(POSTBUILDCMDS)

$(TARGETDIR):
    @echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
    $(SILENT) mkdir -p $(TARGETDIR)
else
    $(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif

clean:
    @echo Cleaning Bar

# File Rules
# #############################################
EnzoCrisostomo commented 1 year ago

I was having the same issue on windows. Running mingw32-make clean then mingw32-make again solved the issue.

Before:

PS E:\Dev\IDJ\pinguim> mingw32-make
"==== Building engine (debug) ===="
"==== Building penguim (debug) ===="

Clean projects:

PS E:\Dev\IDJ\pinguim> mingw32-make clean
Cleaning engine
Cleaning penguim

After:

PS E:\Dev\IDJ\pinguim> mingw32-make      
"==== Building engine (debug) ===="
Creating ../obj/debug-windows-x86/engine
"main.cpp"
"myclass.cpp"
Linking engine
"==== Building penguim (debug) ===="
Creating ../obj/debug-windows-x86/penguim
"main.cpp"
"myclass.cpp"
Linking penguim
Running postbuild commands
copy /B /Y C:\SDL32\bin\*.dll ..\build\debug-windows-x86\penguim
C:\SDL32\bin\SDL2.dll
C:\SDL32\bin\SDL2_image.dll
C:\SDL32\bin\SDL2_mixer.dll
C:\SDL32\bin\SDL2_ttf.dll
        4 arquivo(s) copiado(s).
copy /B /Y ..\build\debug-windows-x86\engine\*.dll ..\build\debug-windows-x86\penguim
..\build\debug-windows-x86\engine\engine_debug.dll
        1 arquivo(s) copiado(s).
nickclark2016 commented 1 year ago

Makes me curious if this is a problem with make caching the "build" and thinking that it's already been executed.