1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 505882: Generate clean target per subdir.mk

To avoid errors like "Command line too long" when removing build
artifacts, split the clean command on multiple lines. In order to
properly handle whitespace etc, generate a new clean target in each
subdir.mk with the explicit list of files to remove in that directory.
The command should be splited on a sane length, 6000 is used in the
internal builder, so reuse that limit here.

Contributed by STMicroelectronics

Change-Id: I843e1ac896076d279173c421210b72f4a325296f
Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com>
This commit is contained in:
Torbjörn Svensson 2021-08-13 23:14:49 +02:00
parent c831994958
commit 15c29ebf2c
96 changed files with 604 additions and 80 deletions

View file

@ -22,3 +22,10 @@ Sources/sub\ sources/func\ 3.o: ../Sources/sub\ sources/func\ 3.c Sources/sub\ s
@echo ' ' @echo ' '
clean: clean-Sources-2f-sub-20-sources
clean-Sources-2f-sub-20-sources:
-$(RM) ./Sources/sub\ sources/func\ 3.d ./Sources/sub\ sources/func\ 3.o
.PHONY: clean-Sources-2f-sub-20-sources

View file

@ -35,3 +35,10 @@ Sources/func2.o: ../Sources/func2.c Sources/subdir.mk
@echo ' ' @echo ' '
clean: clean-Sources
clean-Sources:
-$(RM) ./Sources/func1.d ./Sources/func1.o ./Sources/func2.d ./Sources/func2.o ./Sources/func4.d ./Sources/func4.o
.PHONY: clean-Sources

View file

@ -50,7 +50,7 @@ test1DepCalc2: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) test1DepCalc2 -$(RM) test1DepCalc2
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -22,3 +22,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -24,3 +24,10 @@ Sources/sub\ sources/func\ 3.o: ../Sources/sub\ sources/func\ 3.c Sources/sub\ s
@echo ' ' @echo ' '
clean: clean-Sources-2f-sub-20-sources
clean-Sources-2f-sub-20-sources:
-$(RM) ./Sources/sub\ sources/func\ 3.d ./Sources/sub\ sources/func\ 3.o
.PHONY: clean-Sources-2f-sub-20-sources

View file

@ -30,3 +30,10 @@ Sources/%.o: ../Sources/%.c Sources/subdir.mk
@echo ' ' @echo ' '
clean: clean-Sources
clean-Sources:
-$(RM) ./Sources/func1.d ./Sources/func1.o ./Sources/func2.d ./Sources/func2.o ./Sources/func4.d ./Sources/func4.o
.PHONY: clean-Sources

View file

@ -50,7 +50,7 @@ test1DepCalc3: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) test1DepCalc3 -$(RM) test1DepCalc3
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -24,3 +24,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -27,3 +27,10 @@ Sources/sub\ sources/func\ 3.d: ../Sources/sub\ sources/func\ 3.c Sources/sub\ s
@echo ' ' @echo ' '
clean: clean-Sources-2f-sub-20-sources
clean-Sources-2f-sub-20-sources:
-$(RM) ./Sources/sub\ sources/func\ 3.d ./Sources/sub\ sources/func\ 3.o
.PHONY: clean-Sources-2f-sub-20-sources

View file

@ -33,3 +33,10 @@ Sources/%.d: ../Sources/%.c Sources/subdir.mk
@echo ' ' @echo ' '
clean: clean-Sources
clean-Sources:
-$(RM) ./Sources/func1.d ./Sources/func1.o ./Sources/func2.d ./Sources/func2.o ./Sources/func4.d ./Sources/func4.o
.PHONY: clean-Sources

View file

@ -50,7 +50,7 @@ test1DepCalcPreBuild: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_D
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) test1DepCalcPreBuild -$(RM) test1DepCalcPreBuild
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -27,3 +27,10 @@ main.d: ../main.c subdir.mk
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -63,7 +63,7 @@ test12.exe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) test12.exe -$(RM) test12.exe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -22,3 +22,10 @@ CPP_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./test.d ./test.o
.PHONY: clean--2e-

View file

@ -63,7 +63,7 @@ test20.exe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C++_DEPS)$(EXECUTABLES)$(CC_DEPS)$(C_DEPS)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) test20.exe -$(RM) test20.exe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -22,3 +22,10 @@ CPP_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./Test1.d ./Test1.o
.PHONY: clean--2e-

View file

@ -22,3 +22,10 @@ Functions/%.o: ../Functions/%.c Functions/subdir.mk
@echo ' ' @echo ' '
clean: clean-Functions
clean-Functions:
-$(RM) ./Functions/Func1.d ./Functions/Func1.o
.PHONY: clean-Functions

View file

@ -49,7 +49,7 @@ MBS2dot1.exe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) MBS2dot1.exe -$(RM) MBS2dot1.exe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -22,3 +22,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -22,3 +22,10 @@ Functions/%.o: ../Functions/%.cpp Functions/subdir.mk
@echo ' ' @echo ' '
clean: clean-Functions
clean-Functions:
-$(RM) ./Functions/Func1.d ./Functions/Func1.o
.PHONY: clean-Functions

View file

@ -64,7 +64,7 @@ Test21CXX: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) Test21CXX -$(RM) Test21CXX
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -22,3 +22,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ liblinkedFolder.a: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS) liblinkedFolder.a -$(RM) liblinkedFolder.a
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -27,3 +27,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./f1.d ./f1.o ./f2.d ./f2.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ liblinkedLib.a: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS) liblinkedLib.a -$(RM) liblinkedLib.a
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -36,3 +36,10 @@ f2.o: C:/Documents\ and\ Settings/agvozdev/CDTMBSTest/f2.c subdir.mk
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./f1.d ./f1.o ./f2.d ./f2.o
.PHONY: clean--2e-

View file

@ -63,7 +63,7 @@ testResCfg: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) testResCfg -$(RM) testResCfg
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -24,3 +24,10 @@ source1/%.o: ../source1/%.cpp source1/subdir.mk
@echo ' ' @echo ' '
clean: clean-source1
clean-source1:
-$(RM) ./source1/Class1.d ./source1/Class1.o
.PHONY: clean-source1

View file

@ -24,3 +24,10 @@ source2/source21/Class21.o: ../source2/source21/Class21.cpp source2/source21/sub
@echo ' ' @echo ' '
clean: clean-source2-2f-source21
clean-source2-2f-source21:
-$(RM) ./source2/source21/Class21.d ./source2/source21/Class21.o
.PHONY: clean-source2-2f-source21

View file

@ -24,3 +24,10 @@ source2/%.o: ../source2/%.cpp source2/subdir.mk
@echo ' ' @echo ' '
clean: clean-source2
clean-source2:
-$(RM) ./source2/Class2.d ./source2/Class2.o
.PHONY: clean-source2

View file

@ -24,3 +24,10 @@ CPP_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ testSingleExe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS) testSingleExe -$(RM) testSingleExe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -24,3 +24,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -60,7 +60,7 @@ libtestDoubleSO.so: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEP
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libtestDoubleSO.so -$(RM) libtestDoubleSO.so
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -27,3 +27,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./so1.d ./so1.o ./so2.d ./so2.o
.PHONY: clean--2e-

View file

@ -42,7 +42,7 @@ CDTFortranTest1.exe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DE
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(MODS)$(EXECUTABLES) CDTFortranTest1.exe -$(RM) CDTFortranTest1.exe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -27,3 +27,10 @@ MAIN.obj: AVE_CALCULATOR.mod ../MODULE.F90
./AVE_CALCULATOR.mod: MODULE.obj ./AVE_CALCULATOR.mod: MODULE.obj
clean: clean--2e-
clean--2e-:
-$(RM) ./AVE_CALCULATOR.mod ./AVERAGE.obj ./MAIN.obj ./MODULE.obj
.PHONY: clean--2e-

View file

@ -173,3 +173,10 @@ Sources/y.obj: D.mod ../module/d.f90 L_MODULE.mod ../module/l_module.f90 M1_MODU
Sources/z.obj: A_MODULE.mod ../module/a_module.f90 CBA_MODULE.mod ../module/cba_module.f90 D.mod ../module/d.f90 JJ_MODULE.mod ../module/jj_module.f90 MF_MODULE.mod ../module/mf_module.f90 XXX_MODULE.mod ../module/xxx_module.f90 Sources/z.obj: A_MODULE.mod ../module/a_module.f90 CBA_MODULE.mod ../module/cba_module.f90 D.mod ../module/d.f90 JJ_MODULE.mod ../module/jj_module.f90 MF_MODULE.mod ../module/mf_module.f90 XXX_MODULE.mod ../module/xxx_module.f90
clean: clean-Sources
clean-Sources:
-$(RM) ./Sources/a.obj ./Sources/ab.obj ./Sources/ac.obj ./Sources/c.obj ./Sources/ca.obj ./Sources/cd.obj ./Sources/ce.obj ./Sources/d1.obj ./Sources/e.obj ./Sources/et.obj ./Sources/f.obj ./Sources/fa.obj ./Sources/fex.obj ./Sources/ff.obj ./Sources/g.obj ./Sources/h.obj ./Sources/ha.obj ./Sources/i.obj ./Sources/ia.obj ./Sources/ii.obj ./Sources/is.obj ./Sources/l.obj ./Sources/m.obj ./Sources/ma.obj ./Sources/main.obj ./Sources/mo.obj ./Sources/o.obj ./Sources/p.obj ./Sources/r.obj ./Sources/rx.obj ./Sources/s.obj ./Sources/t.obj ./Sources/u.obj ./Sources/u1.obj ./Sources/v.obj ./Sources/w.obj ./Sources/x.obj ./Sources/y.obj ./Sources/z.obj
.PHONY: clean-Sources

View file

@ -44,7 +44,7 @@ CDTFortranTest2: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(MODS)$(EXECUTABLES) CDTFortranTest2 -$(RM) CDTFortranTest2
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -164,3 +164,10 @@ module/yyy_module.obj: A2_MODULE.mod ../module/a2_module.f90 A_MODULE.mod ../mod
./YYY_MODULE.mod: module/yyy_module.obj A2_MODULE.mod ../module/a2_module.f90 A_MODULE.mod ../module/a_module.f90 B1_MODULE.mod ../module/b1_module.f90 D.mod ../module/d.f90 L1_MODULE.mod ../module/l1_module.f90 UN_MODULE.mod ../module/un_module.f90 XYZ_MODULE.mod ../module/xyz_module.f90 ./YYY_MODULE.mod: module/yyy_module.obj A2_MODULE.mod ../module/a2_module.f90 A_MODULE.mod ../module/a_module.f90 B1_MODULE.mod ../module/b1_module.f90 D.mod ../module/d.f90 L1_MODULE.mod ../module/l1_module.f90 UN_MODULE.mod ../module/un_module.f90 XYZ_MODULE.mod ../module/xyz_module.f90
clean: clean-module
clean-module:
-$(RM) ./A1_MODULE.mod ./A2_MODULE.mod ./ABC_MODULE.mod ./A_MODULE.mod ./B1_MODULE.mod ./B2_MODULE.mod ./C1_MODULE.mod ./C2_MODULE.mod ./C3_MODULE.mod ./CBA_MODULE.mod ./CR_MODULE.mod ./D.mod ./ET_MODULE.mod ./F_MODULE.mod ./G_MOD.mod ./JJ_MODULE.mod ./K_MODULE.mod ./L1_MODULE.mod ./L_MODULE.mod ./M1_MODULE.mod ./MF_MODULE.mod ./MG_MODULE.mod ./P_MODULE.mod ./UN_MODULE.mod ./V_MODULE.mod ./W_MODULE.mod ./XXX_MODULE.mod ./XYZ_MODULE.mod ./YYY_MODULE.mod ./e_MODULE.mod ./module/F_module.obj ./module/a1_module.obj ./module/a2_module.obj ./module/a_module.obj ./module/abc_module.obj ./module/b1_module.obj ./module/b2_module.obj ./module/c1_module.obj ./module/c2_module.obj ./module/c3_module.obj ./module/cba_module.obj ./module/cr_module.obj ./module/d.obj ./module/e_module.obj ./module/et_module.obj ./module/g_module.obj ./module/jj_module.obj ./module/k_module.obj ./module/l1_module.obj ./module/l_module.obj ./module/m1_module.obj ./module/mf_module.obj ./module/mg_module.obj ./module/p_module.obj ./module/un_module.obj ./module/v_module.obj ./module/w_module.obj ./module/xxx_module.obj ./module/xyz_module.obj ./module/yyy_module.obj
.PHONY: clean-module

View file

@ -42,7 +42,7 @@ TestATO.out: $(OBJS) $(OPT_SRCS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(ASSIGNTOOPTION_EXECUTABLE_OUTPUTS)$(OBJS) TestATO.out -$(RM) TestATO.out
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -26,3 +26,10 @@ OBJS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./TestATO.obj
.PHONY: clean--2e-

View file

@ -34,3 +34,10 @@ Functions/%.o: ./Functions/%.c Functions/subdir.mk
@echo ' ' @echo ' '
clean: clean-Functions
clean-Functions:
-$(RM) ./Functions/Func1.c ./Functions/Func1.d ./Functions/Func1.o
.PHONY: clean-Functions

View file

@ -58,7 +58,7 @@ USER_OBJS.foo: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(FINAL)$(C_DEPS)$(CS)$(EXECUTABLES) TestCopyandDeploy -$(RM) TestCopyandDeploy USER_OBJS.foo
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -34,3 +34,10 @@ CS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.c ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -60,7 +60,7 @@ DeleteFile: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) DeleteFile -$(RM) DeleteFile
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -24,3 +24,10 @@ CXX_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ inputTypeOption: $(OBJS) C:\An\ Absolute\ Path\ With\ Spaces\foo.linker $(USER_O
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) inputTypeOption -$(RM) inputTypeOption
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -48,3 +48,10 @@ resourceSettingRelativeCompiler.o: ../resourceSettingRelativeCompiler.c ../A\ Fo
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./picksUpGlobalAbsoluteInputOptionPath.d ./picksUpGlobalAbsoluteInputOptionPath.o ./resourceSettingAbsoluteCompiler.d ./resourceSettingAbsoluteCompiler.o ./resourceSettingRelativeCompiler.d ./resourceSettingRelativeCompiler.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ liblinkedFolder.a: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(ARCHIVES) liblinkedFolder.a -$(RM) liblinkedFolder.a
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -27,3 +27,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./f1.d ./f1.o ./f2.d ./f2.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ liblinkedLib.a: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(ARCHIVES)$(C_DEPS) liblinkedLib.a -$(RM) liblinkedLib.a
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -60,3 +60,10 @@ f2_30.o: C:/Documents\ and\ Settings/agvozdev/CDTMBSTest/f2_30.c subdir.mk
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./f1.d ./f1.o ./f1_30.d ./f1_30.o ./f2.d ./f2.o ./f2_30.d ./f2_30.o
.PHONY: clean--2e-

View file

@ -63,7 +63,7 @@ multiResConfig: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) multiResConfig -$(RM) multiResConfig
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -24,3 +24,10 @@ source1/%.o: ../source1/%.cpp source1/subdir.mk
@echo ' ' @echo ' '
clean: clean-source1
clean-source1:
-$(RM) ./source1/Class1.d ./source1/Class1.o
.PHONY: clean-source1

View file

@ -24,3 +24,10 @@ source2/source21/Class21.o: ../source2/source21/Class21.cpp source2/source21/sub
@echo ' ' @echo ' '
clean: clean-source2-2f-source21
clean-source2-2f-source21:
-$(RM) ./source2/source21/Class21.d ./source2/source21/Class21.o
.PHONY: clean-source2-2f-source21

View file

@ -24,3 +24,10 @@ source2/%.o: ../source2/%.cpp source2/subdir.mk
@echo ' ' @echo ' '
clean: clean-source2
clean-source2:
-$(RM) ./source2/Class2.d ./source2/Class2.o
.PHONY: clean-source2

View file

@ -24,3 +24,10 @@ CPP_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -61,7 +61,7 @@ preAndPostBuildSteps: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_D
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) preAndPostBuildSteps -$(RM) preAndPostBuildSteps
-@echo ' ' -@echo ' '
pre-build: pre-build:

View file

@ -24,3 +24,10 @@ CXX_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ rcbsBasicTest: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) rcbsBasicTest -$(RM) rcbsBasicTest
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -19,3 +19,10 @@ rcbsBasicTest.o: ../rcbsBasicTest.c subdir.mk
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./rcbsBasicTest.o
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ singleFileExe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) singleFileExe -$(RM) singleFileExe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -24,3 +24,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main.d ./main.o
.PHONY: clean--2e-

View file

@ -49,7 +49,7 @@ testwithspaces.exe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEP
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) testwithspaces.exe -$(RM) testwithspaces.exe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -22,3 +22,10 @@ sub\ folder\ with\ spaces/foo\ with\ spaces.o: ../sub\ folder\ with\ spaces/foo\
@echo ' ' @echo ' '
clean: clean-sub-20-folder-20-with-20-spaces
clean-sub-20-folder-20-with-20-spaces:
-$(RM) ./sub\ folder\ with\ spaces/foo\ with\ spaces.d ./sub\ folder\ with\ spaces/foo\ with\ spaces.o
.PHONY: clean-sub-20-folder-20-with-20-spaces

View file

@ -22,3 +22,10 @@ main\ with\ spaces.o: ../main\ with\ spaces.c subdir.mk
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./main\ with\ spaces.d ./main\ with\ spaces.o
.PHONY: clean--2e-

View file

@ -62,7 +62,7 @@ test30_1.so.1.2.3: $(STRIPPEDOBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(STRIPPEDOBJS)$(OBJS)$(FINAL)$(TEST30_1_GNU_SO_CJPEG_OUTPUT_OUTPUTS)$(C_DEPS)$(TEST30_1_GNU_SO_DEPLOY_OUTPUT_OUTPUTS)$(TEST30_1_GNU_SO_TAR_OUTPUTH_OUTPUTS)$(TEST30_1_GNU_SO_TAR_OUTPUTBMP_OUTPUTS)$(EXECUTABLES)$(TEST30_1_GNU_SO_TAR_OUTPUTC_OUTPUTS) Test30_1.so.4.5.6 -$(RM) Test30_1.so.4.5.6 default.so.4.5.6 test30_1.so.1.2.3
-@echo ' ' -@echo ' '
secondary-outputs: $(TEST30_1_GNU_SO_CJPEG_OUTPUT_OUTPUTS) secondary-outputs: $(TEST30_1_GNU_SO_CJPEG_OUTPUT_OUTPUTS)

View file

@ -63,3 +63,10 @@ CDT.bmp: f1.c
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./CDT.bmp ./CDT.jpeg ./f1.c ./f1.d ./f1.o ./f1.oprestripped ./f2.c ./f2.d ./f2.o ./f2.oprestripped ./test_ar.h
.PHONY: clean--2e-

View file

@ -61,7 +61,7 @@ new.log: $(TAROUT) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(TAROUT)$(TERMINAL__DUMMY_OUTPUT__OUTPUTS)$(LOGFILE) test30_2.tmp -$(RM) new.log new.tar test30_2.tmp
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -48,7 +48,7 @@ test.exe: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) test.exe -$(RM) test.exe
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -22,3 +22,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./test.d ./test.o
.PHONY: clean--2e-

View file

@ -42,7 +42,7 @@ testMacroSupportInBuildDefinitions.tar: $(BAR_FILES) makefile objects.mk $(OPTIO
# Other Targets # Other Targets
clean: clean:
-$(RM) $(TAR_FILE_OUTPUTS)$(BAR_FILES) testMacroSupportInBuildDefinitions.tar -$(RM) testMacroSupportInBuildDefinitions.tar
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -19,3 +19,10 @@ this_is_a_test_prefix_with_a_macro_for_the_project_name_between_here_testMacroSu
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./this_is_a_test_prefix_with_a_macro_for_the_project_name_between_here_testMacroSupportInBuildDefinitions_and_heresomefile.bar
.PHONY: clean--2e-

View file

@ -48,7 +48,7 @@ libtwoFileSO.SOS: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C_DEPS)$(LIBRARIES) libtwoFileSO.SOS -$(RM) libtwoFileSO.SOS
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -27,3 +27,10 @@ C_DEPS += \
@echo ' ' @echo ' '
clean: clean--2e-
clean--2e-:
-$(RM) ./so1.d ./so1.o ./so2.d ./so2.o
.PHONY: clean--2e-

View file

@ -25,3 +25,10 @@ d1/d2/d3/%.o: ../d1/d2/d3/%.cpp d1/d2/d3/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1-2f-d2-2f-d3
clean-d1-2f-d2-2f-d3:
-$(RM) ./d1/d2/d3/t.d ./d1/d2/d3/t.o ./d1/d2/d3/y.d ./d1/d2/d3/y.o
.PHONY: clean-d1-2f-d2-2f-d3

View file

@ -32,3 +32,10 @@ d1/d2/%.o: ../d1/d2/%.cpp d1/d2/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1-2f-d2
clean-d1-2f-d2:
-$(RM) ./d1/d2/e.d ./d1/d2/e.o ./d1/d2/r.d ./d1/d2/r.o
.PHONY: clean-d1-2f-d2

View file

@ -28,3 +28,10 @@ d1/%.o: ../d1/%.cpp d1/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1
clean-d1:
-$(RM) ./d1/q.d ./d1/q.o ./d1/u.d ./d1/u.o ./d1/w.d ./d1/w.o
.PHONY: clean-d1

View file

@ -25,3 +25,10 @@ d1_1/d2_1/%.o: ../d1_1/d2_1/%.cpp d1_1/d2_1/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1_1-2f-d2_1
clean-d1_1-2f-d2_1:
-$(RM) ./d1_1/d2_1/a.d ./d1_1/d2_1/a.o ./d1_1/d2_1/p.d ./d1_1/d2_1/p.o
.PHONY: clean-d1_1-2f-d2_1

View file

@ -25,3 +25,10 @@ d1_1/%.o: ../d1_1/%.cpp d1_1/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1_1
clean-d1_1:
-$(RM) ./d1_1/i.d ./d1_1/i.o ./d1_1/o.d ./d1_1/o.o
.PHONY: clean-d1_1

View file

@ -22,3 +22,10 @@ dir1/dd/excluded_c/asd/%.o: ../dir1/dd/excluded_c/asd/%.cpp dir1/dd/excluded_c/a
@echo ' ' @echo ' '
clean: clean-dir1-2f-dd-2f-excluded_c-2f-asd
clean-dir1-2f-dd-2f-excluded_c-2f-asd:
-$(RM) ./dir1/dd/excluded_c/asd/s.d ./dir1/dd/excluded_c/asd/s.o
.PHONY: clean-dir1-2f-dd-2f-excluded_c-2f-asd

View file

@ -22,3 +22,10 @@ dir1/dd/excluded_c/%.o: ../dir1/dd/excluded_c/%.cpp dir1/dd/excluded_c/subdir.mk
@echo ' ' @echo ' '
clean: clean-dir1-2f-dd-2f-excluded_c
clean-dir1-2f-dd-2f-excluded_c:
-$(RM) ./dir1/dd/excluded_c/inc.d ./dir1/dd/excluded_c/inc.o
.PHONY: clean-dir1-2f-dd-2f-excluded_c

View file

@ -36,3 +36,10 @@ dir1/dd/ff/%.o: ../dir1/dd/ff/%.cpp dir1/dd/ff/subdir.mk
@echo ' ' @echo ' '
clean: clean-dir1-2f-dd-2f-ff
clean-dir1-2f-dd-2f-ff:
-$(RM) ./dir1/dd/ff/vbn.d ./dir1/dd/ff/vbn.o ./dir1/dd/ff/zxc.d ./dir1/dd/ff/zxc.o
.PHONY: clean-dir1-2f-dd-2f-ff

View file

@ -71,7 +71,7 @@ test_40: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C++_DEPS)$(EXECUTABLES)$(CC_DEPS)$(C_DEPS)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) test_40 -$(RM) test_40
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -25,3 +25,10 @@ d1/d2/d3/%.o: ../d1/d2/d3/%.cpp d1/d2/d3/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1-2f-d2-2f-d3
clean-d1-2f-d2-2f-d3:
-$(RM) ./d1/d2/d3/t.d ./d1/d2/d3/t.o ./d1/d2/d3/y.d ./d1/d2/d3/y.o
.PHONY: clean-d1-2f-d2-2f-d3

View file

@ -32,3 +32,10 @@ d1/d2/%.o: ../d1/d2/%.cpp d1/d2/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1-2f-d2
clean-d1-2f-d2:
-$(RM) ./d1/d2/e.d ./d1/d2/e.o ./d1/d2/r.d ./d1/d2/r.o
.PHONY: clean-d1-2f-d2

View file

@ -28,3 +28,10 @@ d1/%.o: ../d1/%.cpp d1/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1
clean-d1:
-$(RM) ./d1/q.d ./d1/q.o ./d1/u.d ./d1/u.o ./d1/w.d ./d1/w.o
.PHONY: clean-d1

View file

@ -25,3 +25,10 @@ d1_1/d2_1/%.o: ../d1_1/d2_1/%.cpp d1_1/d2_1/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1_1-2f-d2_1
clean-d1_1-2f-d2_1:
-$(RM) ./d1_1/d2_1/a.d ./d1_1/d2_1/a.o ./d1_1/d2_1/p.d ./d1_1/d2_1/p.o
.PHONY: clean-d1_1-2f-d2_1

View file

@ -25,3 +25,10 @@ d1_1/%.o: ../d1_1/%.cpp d1_1/subdir.mk
@echo ' ' @echo ' '
clean: clean-d1_1
clean-d1_1:
-$(RM) ./d1_1/i.d ./d1_1/i.o ./d1_1/o.d ./d1_1/o.o
.PHONY: clean-d1_1

View file

@ -22,3 +22,10 @@ dir1/dd/excluded_c/asd/%.o: ../dir1/dd/excluded_c/asd/%.cpp dir1/dd/excluded_c/a
@echo ' ' @echo ' '
clean: clean-dir1-2f-dd-2f-excluded_c-2f-asd
clean-dir1-2f-dd-2f-excluded_c-2f-asd:
-$(RM) ./dir1/dd/excluded_c/asd/s.d ./dir1/dd/excluded_c/asd/s.o
.PHONY: clean-dir1-2f-dd-2f-excluded_c-2f-asd

View file

@ -22,3 +22,10 @@ dir1/dd/excluded_c/%.o: ../dir1/dd/excluded_c/%.cpp dir1/dd/excluded_c/subdir.mk
@echo ' ' @echo ' '
clean: clean-dir1-2f-dd-2f-excluded_c
clean-dir1-2f-dd-2f-excluded_c:
-$(RM) ./dir1/dd/excluded_c/inc.d ./dir1/dd/excluded_c/inc.o
.PHONY: clean-dir1-2f-dd-2f-excluded_c

View file

@ -36,3 +36,10 @@ dir1/dd/ff/%.o: ../dir1/dd/ff/%.cpp dir1/dd/ff/subdir.mk
@echo ' ' @echo ' '
clean: clean-dir1-2f-dd-2f-ff
clean-dir1-2f-dd-2f-ff:
-$(RM) ./dir1/dd/ff/vbn.d ./dir1/dd/ff/vbn.o ./dir1/dd/ff/zxc.d ./dir1/dd/ff/zxc.o
.PHONY: clean-dir1-2f-dd-2f-ff

View file

@ -71,7 +71,7 @@ test_40: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
# Other Targets # Other Targets
clean: clean:
-$(RM) $(OBJS)$(C++_DEPS)$(EXECUTABLES)$(CC_DEPS)$(C_DEPS)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) test_40 -$(RM) test_40
-@echo ' ' -@echo ' '
.PHONY: all clean dependents main-build .PHONY: all clean dependents main-build

View file

@ -27,6 +27,7 @@ import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -35,6 +36,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
@ -344,6 +346,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
private static final String POSTBUILD = "post-build"; //$NON-NLS-1$ private static final String POSTBUILD = "post-build"; //$NON-NLS-1$
private static final String SECONDARY_OUTPUTS = "secondary-outputs"; //$NON-NLS-1$ private static final String SECONDARY_OUTPUTS = "secondary-outputs"; //$NON-NLS-1$
/**
* On Windows XP and above, the maximum command line length is 8191, on Linux it is at least 131072, but
* that includes the environment. We want to limit the invocation of a single command to this number of
* characters, and we want to ensure that the number isn't so low as to slow down operation.
*
* Doing each rm in its own command would be very slow, especially on Windows.
*/
private static final int MAX_CLEAN_LENGTH = 6000;
// Enumerations // Enumerations
public static final int PROJECT_RELATIVE = 1, PROJECT_SUBDIR_RELATIVE = 2, ABSOLUTE = 3; public static final int PROJECT_RELATIVE = 1, PROJECT_SUBDIR_RELATIVE = 2, ABSOLUTE = 3;
@ -388,7 +399,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
private final HashMap<String, List<IPath>> buildOutVars = new HashMap<>(); private final HashMap<String, List<IPath>> buildOutVars = new HashMap<>();
// Map of dependency file build variable names to a List of GnuDependencyGroupInfo objects // Map of dependency file build variable names to a List of GnuDependencyGroupInfo objects
private final HashMap<String, GnuDependencyGroupInfo> buildDepVars = new HashMap<>(); private final HashMap<String, GnuDependencyGroupInfo> buildDepVars = new HashMap<>();
private final LinkedHashMap<String, String> topBuildOutVars = new LinkedHashMap<>(); private final Map<String, Set<String>> topBuildOutVars = new LinkedHashMap<>();
// Dependency file variables // Dependency file variables
// private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute // private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute
@ -1008,7 +1019,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
IFile modMakefile = createFile(moduleOutputDir.append(MODFILE_NAME)); IFile modMakefile = createFile(moduleOutputDir.append(MODFILE_NAME));
StringBuffer makeBuf = new StringBuffer(); StringBuffer makeBuf = new StringBuffer();
makeBuf.append(addFragmentMakefileHeader()); makeBuf.append(addFragmentMakefileHeader());
makeBuf.append(addSources(module)); makeBuf.append(addSources(module, toCleanTarget(moduleRelativePath)));
// Save the files // Save the files
save(makeBuf, modMakefile); save(makeBuf, modMakefile);
@ -1627,11 +1638,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Always add a clean target // Always add a clean target
buffer.append("clean:").append(NEWLINE); //$NON-NLS-1$ buffer.append("clean:").append(NEWLINE); //$NON-NLS-1$
buffer.append(TAB).append("-$(RM)").append(WHITESPACE); //$NON-NLS-1$
for (Entry<String, List<IPath>> entry : buildOutVars.entrySet()) { Set<String> filesToClean = new HashSet<>();
String macroName = entry.getKey();
buffer.append("$(").append(macroName).append(')'); //$NON-NLS-1$
}
String outputPrefix = EMPTY_STRING; String outputPrefix = EMPTY_STRING;
if (targetTool != null) { if (targetTool != null) {
outputPrefix = targetTool.getOutputPrefix(); outputPrefix = targetTool.getOutputPrefix();
@ -1640,11 +1648,42 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (buildTargetExt.length() > 0) { if (buildTargetExt.length() > 0) {
completeBuildTargetName = completeBuildTargetName + DOT + buildTargetExt; completeBuildTargetName = completeBuildTargetName + DOT + buildTargetExt;
} }
if (completeBuildTargetName.contains(" ")) { //$NON-NLS-1$ completeBuildTargetName = ensurePathIsGNUMakeTargetRuleCompatibleSyntax(completeBuildTargetName);
buffer.append(WHITESPACE).append('"').append(completeBuildTargetName).append('"'); filesToClean.add(completeBuildTargetName);
} else {
buffer.append(WHITESPACE).append(completeBuildTargetName); Map<String, Set<String>> map = getTopBuildOutputVars();
for (String macroName : outputVarsAdditionsList) {
Set<String> set = map.getOrDefault(macroName, Collections.emptySet());
filesToClean.addAll(set);
} }
if (!filesToClean.isEmpty()) {
StringBuffer rmLineBuffer = new StringBuffer();
rmLineBuffer.append(TAB).append("-$(RM)"); //$NON-NLS-1$
// Convert the set to an ordered list. Without this "unneeded" sorting, the unit tests will fail
List<String> filesToCleanOrdered = new ArrayList<>(filesToClean);
filesToCleanOrdered.sort((p1, p2) -> p1.toString().compareTo(p2.toString()));
for (String path : filesToCleanOrdered) {
// Bug 417228, ilg@livius.net & freidin.alex@gmail.com
path = ensurePathIsGNUMakeTargetRuleCompatibleSyntax(path);
// There is a max length for a command line, wrap to multiple invocations if needed.
if (rmLineBuffer.length() + path.length() > MAX_CLEAN_LENGTH) {
// Terminate this RM line
buffer.append(rmLineBuffer).append(NEWLINE);
// Start a new RM line
rmLineBuffer = new StringBuffer();
rmLineBuffer.append(TAB).append("-$(RM)"); //$NON-NLS-1$
}
rmLineBuffer.append(WHITESPACE).append(path);
}
buffer.append(rmLineBuffer);
}
buffer.append(NEWLINE); buffer.append(NEWLINE);
buffer.append(TAB).append(DASH).append(AT).append(ECHO_BLANK_LINE).append(NEWLINE); buffer.append(TAB).append(DASH).append(AT).append(ECHO_BLANK_LINE).append(NEWLINE);
@ -2014,7 +2053,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
* @param module project resource directory/subdirectory * @param module project resource directory/subdirectory
* @return StringBuffer generated text for the fragement makefile * @return StringBuffer generated text for the fragement makefile
*/ */
protected StringBuffer addSources(IContainer module) throws CoreException { protected StringBuffer addSources(IContainer module, String cleanTarget) throws CoreException {
// Calculate the new directory relative to the build output // Calculate the new directory relative to the build output
IPath moduleRelativePath = module.getProjectRelativePath(); IPath moduleRelativePath = module.getProjectRelativePath();
String relativePath = moduleRelativePath.toString(); String relativePath = moduleRelativePath.toString();
@ -2047,6 +2086,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
IResourceInfo rcInfo; IResourceInfo rcInfo;
IFolder folder = project.getFolder(computeTopBuildDir(config.getName())); IFolder folder = project.getFolder(computeTopBuildDir(config.getName()));
Set<IPath> filesToClean = new HashSet<>();
for (IResource resource : resources) { for (IResource resource : resources) {
if (resource.getType() == IResource.FILE) { if (resource.getType() == IResource.FILE) {
@ -2058,16 +2098,50 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// if( (rcInfo.isExcluded()) ) // if( (rcInfo.isExcluded()) )
// continue; // continue;
addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer, folder, relativePath, resource, addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer, folder, relativePath, resource,
getPathForResource(resource), rcInfo, null, false); getPathForResource(resource), rcInfo, null, false, filesToClean);
} }
} }
// Write out the macro addition entries to the buffer // Write out the macro addition entries to the buffer
buffer.append(writeAdditionMacros(buildVarToRuleStringMap)); buffer.append(writeAdditionMacros(buildVarToRuleStringMap));
return buffer.append(ruleBuffer).append(NEWLINE); buffer.append(ruleBuffer).append(NEWLINE);
if (cleanTarget != null && !filesToClean.isEmpty()) {
buffer.append("clean: " + cleanTarget).append(NEWLINE).append(NEWLINE); //$NON-NLS-1$
buffer.append(cleanTarget + COLON).append(NEWLINE);
StringBuffer rmLineBuffer = new StringBuffer();
rmLineBuffer.append(TAB).append("-$(RM)"); //$NON-NLS-1$
// Convert the set to an ordered list. Without this "unneeded" sorting, the unit tests will fail
List<IPath> filesToCleanOrdered = new ArrayList<>(filesToClean);
filesToCleanOrdered.sort((p1, p2) -> p1.toString().compareTo(p2.toString()));
for (IPath fileToClean : filesToCleanOrdered) {
String path = escapeWhitespaces(
(fileToClean.isAbsolute() || fileToClean.segment(0).equals(".") ? EMPTY_STRING : "./") //$NON-NLS-1$ //$NON-NLS-2$
+ fileToClean.toString());
// There is a max length for a command line, wrap to multiple invocations if needed.
if (rmLineBuffer.length() + path.length() > MAX_CLEAN_LENGTH) {
// Terminate this RM line
buffer.append(rmLineBuffer).append(NEWLINE);
// Start a new RM line
rmLineBuffer = new StringBuffer();
rmLineBuffer.append(TAB).append("-$(RM)"); //$NON-NLS-1$
}
rmLineBuffer.append(WHITESPACE).append(path);
}
buffer.append(rmLineBuffer).append(NEWLINE).append(NEWLINE);
buffer.append(".PHONY: ").append(cleanTarget).append(NEWLINE).append(NEWLINE); //$NON-NLS-1$
}
return buffer;
} }
/* (non-Javadoc /**
* Adds the entries for a particular source file to the fragment makefile * Adds the entries for a particular source file to the fragment makefile
* *
* @param buildVarToRuleStringMap map of build variable names to the list of files assigned to the variable * @param buildVarToRuleStringMap map of build variable names to the list of files assigned to the variable
@ -2083,7 +2157,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
*/ */
protected void addFragmentMakefileEntriesForSource(LinkedHashMap<String, String> buildVarToRuleStringMap, protected void addFragmentMakefileEntriesForSource(LinkedHashMap<String, String> buildVarToRuleStringMap,
StringBuffer ruleBuffer, IFolder folder, String relativePath, IResource resource, IPath sourceLocation, StringBuffer ruleBuffer, IFolder folder, String relativePath, IResource resource, IPath sourceLocation,
IResourceInfo rcInfo, String varName, boolean generatedSource) { IResourceInfo rcInfo, String varName, boolean generatedSource, Set<IPath> filesToClean) {
// Determine which tool, if any, builds files with this extension // Determine which tool, if any, builds files with this extension
String ext = sourceLocation.getFileExtension(); String ext = sourceLocation.getFileExtension();
@ -2213,8 +2287,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
nextRcInfo = rcInfo; nextRcInfo = rcInfo;
} }
addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer, folder, relativePath, addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer, folder, relativePath,
generateOutputResource, generatedOutput, nextRcInfo, buildVariable, true); generateOutputResource, generatedOutput, nextRcInfo, buildVariable, true, filesToClean);
} }
filesToClean.addAll(generatedDepFiles);
filesToClean.addAll(generatedOutputs);
} }
} else { } else {
// If this is a secondary input, add it to build vars // If this is a secondary input, add it to build vars
@ -3860,24 +3937,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
/** /**
* Adds file(s) to an entry in a map of macro names to entries. * Adds file(s) to an entry in a map of macro names to entries.
* File additions look like:
* example.c, \
*/ */
public void addMacroAdditionFiles(HashMap<String, String> map, String macroName, Vector<String> filenames) { public void addMacroAdditionFiles(Map<String, Set<String>> map, String macroName, Vector<String> filenames) {
StringBuffer buffer = new StringBuffer(); Set<String> set = map.get(macroName);
buffer.append(map.get(macroName));
for (int i = 0; i < filenames.size(); i++) {
String filename = filenames.get(i);
if (filename.length() > 0) {
// Bug 417288, ilg@livius.net & freidin.alex@gmail.com for (String filename : filenames) {
filename = ensurePathIsGNUMakeTargetRuleCompatibleSyntax(filename); if (!filename.isEmpty()) {
set.add(filename);
buffer.append(filename).append(WHITESPACE).append(LINEBREAK);
} }
} }
// re-insert string in the map
map.put(macroName, buffer.toString());
} }
/** /**
@ -3914,20 +3982,25 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
/** /**
* Write all macro addition entries in a map to the buffer * Write all macro addition entries in a map to the buffer
*/ */
protected StringBuffer writeTopAdditionMacros(List<String> varList, HashMap<String, String> varMap) { protected StringBuffer writeTopAdditionMacros(List<String> varList, Map<String, Set<String>> varMap) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
// Add the comment // Add the comment
buffer.append(COMMENT_SYMBOL).append(WHITESPACE).append(ManagedMakeMessages.getResourceString(MOD_VARS)) buffer.append(COMMENT_SYMBOL).append(WHITESPACE).append(ManagedMakeMessages.getResourceString(MOD_VARS))
.append(NEWLINE); .append(NEWLINE);
for (int i = 0; i < varList.size(); i++) { for (String macroName : varList) {
String addition = varMap.get(varList.get(i)); Set<String> files = varMap.get(macroName);
StringBuffer currentBuffer = new StringBuffer();
currentBuffer.append(addition);
currentBuffer.append(NEWLINE);
// append the contents of the buffer to the master buffer for the whole file buffer.append(macroName).append(WHITESPACE).append(MACRO_ADDITION_PREFIX_SUFFIX);
buffer.append(currentBuffer);
for (String filename : files) {
// Bug 417228, ilg@livius.net & freidin.alex@gmail.com
filename = ensurePathIsGNUMakeTargetRuleCompatibleSyntax(filename);
buffer.append(filename).append(WHITESPACE).append(LINEBREAK);
}
buffer.append(NEWLINE);
} }
return buffer.append(NEWLINE); return buffer.append(NEWLINE);
} }
@ -3992,16 +4065,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
} }
// Initialize the build output variable to file additions map // Initialize the build output variable to file additions map
LinkedHashMap<String, String> map = getTopBuildOutputVars(); Map<String, Set<String>> map = getTopBuildOutputVars();
Set<Entry<String, List<IPath>>> set = buildOutVars.entrySet(); Set<Entry<String, List<IPath>>> set = buildOutVars.entrySet();
for (Entry<String, List<IPath>> entry : set) { for (Entry<String, List<IPath>> entry : set) {
String macroName = entry.getKey(); String macroName = entry.getKey();
// for projects with specific setting on folders/files do // for projects with specific setting on folders/files do
// not clear the macro value on subsequent passes // not clear the macro value on subsequent passes
if (!map.containsKey(macroName)) { map.putIfAbsent(macroName, new HashSet<>());
addMacroAdditionPrefix(map, macroName, "", false); //$NON-NLS-1$
}
} }
// Set of input extensions for which macros have been created so far // Set of input extensions for which macros have been created so far
@ -4146,10 +4217,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
/** /**
* Returns the map of build variables used in the top makefile to list of files * Returns the map of build variables used in the top makefile to list of files
*
* @return HashMap
*/ */
public LinkedHashMap<String, String> getTopBuildOutputVars() { public Map<String, Set<String>> getTopBuildOutputVars() {
return topBuildOutVars; return topBuildOutVars;
} }
@ -4787,4 +4856,24 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
return root; return root;
} }
private String toCleanTarget(IPath path) {
final BitSet allowedCodePoints = new BitSet(128);
allowedCodePoints.set("A".codePointAt(0), "Z".codePointAt(0) + 1); //$NON-NLS-1$ //$NON-NLS-2$
allowedCodePoints.set("a".codePointAt(0), "z".codePointAt(0) + 1); //$NON-NLS-1$ //$NON-NLS-2$
allowedCodePoints.set("0".codePointAt(0), "9".codePointAt(0) + 1); //$NON-NLS-1$ //$NON-NLS-2$
allowedCodePoints.set("_".codePointAt(0)); //$NON-NLS-1$
StringBuilder sb = new StringBuilder("clean-"); //$NON-NLS-1$
(path.isEmpty() ? DOT : path.toString()).codePoints().forEach(c -> {
if (allowedCodePoints.get(c)) {
sb.append(Character.toChars(c));
} else {
sb.append("-"); //$NON-NLS-1$
sb.append(Long.toHexString(c));
sb.append("-"); //$NON-NLS-1$
}
});
return sb.toString();
}
} }

View file

@ -19,6 +19,7 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
@ -765,9 +766,9 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
enumeratedSecondaryOutputs.addAll(myEnumeratedSecondaryOutputs); enumeratedSecondaryOutputs.addAll(myEnumeratedSecondaryOutputs);
outputVariables.addAll(myOutputMacros.keySet()); outputVariables.addAll(myOutputMacros.keySet());
outputsCalculated = true; outputsCalculated = true;
Map<String, Set<String>> map = makeGen.getTopBuildOutputVars();
for (int i = 0; i < myBuildVars.size(); i++) { for (int i = 0; i < myBuildVars.size(); i++) {
makeGen.addMacroAdditionFiles(makeGen.getTopBuildOutputVars(), myBuildVars.get(i), makeGen.addMacroAdditionFiles(map, myBuildVars.get(i), myBuildVarsValues.get(i));
myBuildVarsValues.get(i));
} }
return true; return true;
} }