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

Problems with SHELL=cmd and mingw32-make

Open ghost opened this issue 1 year ago • 1 comments

If there are too many objects, the clean command will fail.

Discovered when building this project:

https://github.com/SpartanJ/eepp

This generated code is problematic:

	$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
	$(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))
	$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))

ghost avatar Jul 20 '24 22:07 ghost

To be clear, it's trying to execute the object files (.o extension) instead of deleting them. This is extremely hard to debug since there is no --verbose switch or something like that.

ghost avatar Jul 20 '24 23:07 ghost

TestApp.make:

. . . clean: @echo Cleaning TestApp ifeq (posix,$(SHELLTYPE)) $(SILENT) rm -f $(TARGET) $(SILENT) rm -rf $(GENERATED) $(SILENT) rm -rf $(OBJDIR) else $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) $(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED)) $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) endif . . .

Yeah. $(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED)) [Premake 5.0-beta7] Windows 10 home CMD

Cases:

  • Only one file generated if exist obj\\file1.o del /s /q obj\\file.o Result: file1.o is deleted (OK)

  • Two files generated if exist obj\\file1.o obj\\file2.o del /s /q obj\\file1.o obj\\file2.o Result: tries to open/start the file2.o (Files deleted: none)

  • N files generated if exist obj\\file1.o obj\\file2.o obj\\fileN.o del /s /q obj\\file1.o obj\\file2.o obj\\fileN.o Result: tries to open/start the file2.o (Files deleted: none)

Turns out it was the next line that deletes the "obj" directory together with all the generated files: $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))

Manually replacing: $(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED)) with: $(SILENT) 2>nul del /s /q $(subst /,\\,$(GENERATED)) >nul or with: $(foreach f,$(subst /,\\,$(GENERATED)),$(SILENT) if exist $(f) del /s /q $(f)>nul &) did the job for me

0hip avatar Sep 13 '25 20:09 0hip