[Lldb-commits] [lldb] r228285 - Clean up dependency .d.$$$$ files for tests

Pavel Labath labath at google.com
Thu Feb 5 01:52:43 PST 2015


Author: labath
Date: Thu Feb  5 03:52:42 2015
New Revision: 228285

URL: http://llvm.org/viewvc/llvm-project?rev=228285&view=rev
Log:
Clean up dependency .d.$$$$ files for tests

Summary:
Mac-only tests were leaving .d.$$$$ dependency files left in the test tree. This happened
because:
1) "make clean" was invoked although no tests in the folder were run
2) The Makefile had main.d as a dependency, which meant it tried to compile the source file (to extract
dependencies).
3) The compile failed (does not compile on linux) and left behind a main.d.$$$$ temporary file.
4) "make clean" tried to clean up these temporary files, but the expansion $(wildcard *.d.[0-9]*)
was performed before the temporary file was created, so this file was not caught.

I fix this by giving all the temporary files deterministic names, which makes it easier to clean
them up afterwards. I also make the rules for generating the dependency files more robust and
less likely to leak files in the first place.

Reviewers: vharron, zturner

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7406

Modified:
    lldb/trunk/test/make/Makefile.rules

Modified: lldb/trunk/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=228285&r1=228284&r2=228285&view=diff
==============================================================================
--- lldb/trunk/test/make/Makefile.rules (original)
+++ lldb/trunk/test/make/Makefile.rules Thu Feb  5 03:52:42 2015
@@ -399,28 +399,28 @@ endif
 # and the -MM option will list all non-system dependencies.
 #----------------------------------------------------------------------
 %.d: %.c
-	@set -e; rm -f $@; \
-	$(CC) -M $(CFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
+	@rm -f $@; \
+	$(CC) -M $(CFLAGS) $< > $@.tmp && \
+	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	rm -f $@.tmp
 
 %.d: %.cpp
-	@set -e; rm -f $@; \
-	$(CXX) -M $(CXXFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
+	@rm -f $@; \
+	$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
+	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	rm -f $@.tmp
 
 %.d: %.m
-	@set -e; rm -f $@; \
-	$(CC) -M $(CFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
+	@rm -f $@; \
+	$(CC) -M $(CFLAGS) $< > $@.tmp && \
+	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	rm -f $@.tmp
 
 %.d: %.mm
-	@set -e; rm -f $@; \
-	$(CXX) -M $(CXXFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
+	@rm -f $@; \
+	$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
+	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	rm -f $@.tmp
 
 #----------------------------------------------------------------------
 # Include all of the makefiles for each source file so we don't have
@@ -440,11 +440,10 @@ endif
 dsym:	$(DSYM)
 all:	$(EXE) $(DSYM)
 clean::
-	$(RM) "$(EXE)" $(OBJECTS) $(PREREQS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
-	$(RM) -r $(wildcard *.d.[0-9] *.d.[0-9][0-9] *.d.[0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9][0-9])
+	$(RM) "$(EXE)" $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
 ifneq "$(DYLIB_NAME)" ""
 	$(RM) -r $(DYLIB_FILENAME).dSYM
-	$(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug
+	$(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug
 endif
 ifneq "$(DSYM)" ""
 	$(RM) -r "$(DSYM)"





More information about the lldb-commits mailing list