Problems with SHELL=cmd and mingw32-make
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))
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.
TestApp.make:
. . .
clean:@echo Cleaning TestAppifeq (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.oResult: file1.o is deleted (OK) -
Two files generated
if exist obj\\file1.o obj\\file2.o del /s /q obj\\file1.o obj\\file2.oResult: 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.oResult: 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