From 63fb3721efda2d1388129c68b5b3c594677009f3 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Thu, 3 Dec 2020 21:32:47 +0100 Subject: [PATCH] ports/unix/check: Split depfiles for faster build Having just one depfile (.depend) means it has to be fully regenerated on every change, and it can't be done in parallel. After this change the rebuild time after touching a single test file has gone from 5.0 to 0.9 seconds. (make -j12) Build of tests from clean has gone from 8.1 to 5.5s. We could go even further and have one depfile per c-file, but this felt like a simple first step giving a nice improvement. --- .gitignore | 2 +- contrib/ports/unix/check/Makefile | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index a007392e..3b9d7d07 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ *lwip_unittests.xml *.suo *.log -.depend +.depend* /.vscode/ipch diff --git a/contrib/ports/unix/check/Makefile b/contrib/ports/unix/check/Makefile index 01a6d05e..4200c368 100644 --- a/contrib/ports/unix/check/Makefile +++ b/contrib/ports/unix/check/Makefile @@ -57,22 +57,28 @@ TESTDIR=$(LWIPDIR)/../test/unit include $(TESTDIR)/Filelists.mk TESTOBJS=$(notdir $(TESTFILES:.c=.o)) +DEPFILES=.depend_test .depend_lwip .depend_app + clean: - @rm -f *.o $(LWIPLIBCOMMON) $(APPLIB) lwip_unittests *.s .depend* *.core core lwip_unittests.xml + @rm -f *.o $(LWIPLIBCOMMON) $(APPLIB) lwip_unittests *.s $(DEPFILES) *.core core lwip_unittests.xml -depend dep: .depend +depend dep: $(DEPFILES) -include .depend +include $(DEPFILES) -.depend: $(LWIPFILES) $(APPFILES) $(TESTFILES) - $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend +.depend_test: $(TESTFILES) + $(CCDEP) $(CFLAGS) -MM $^ > .depend_test || rm -f .depend_test +.depend_lwip: $(LWIPFILES) + $(CCDEP) $(CFLAGS) -MM $^ > .depend_lwip || rm -f .depend_lwip +.depend_app: $(APPFILES) + $(CCDEP) $(CFLAGS) -MM $^ > .depend_app || rm -f .depend_app ifneq ($(UNAME_S),Darwin) # clang on Darwin doesn't support --start-group -lwip_unittests: .depend $(TESTOBJS) $(LWIPLIBCOMMON) $(APPLIB) +lwip_unittests: $(DEPFILES) $(TESTOBJS) $(LWIPLIBCOMMON) $(APPLIB) $(CC) $(CFLAGS) -o lwip_unittests $(TESTOBJS) -Wl,--start-group $(LWIPLIBCOMMON) $(APPLIB) $(LDFLAGS) -Wl,--end-group else -lwip_unittests: .depend $(TESTOBJS) $(LWIPLIBCOMMON) $(APPLIB) +lwip_unittests: $(DEPFILES) $(TESTOBJS) $(LWIPLIBCOMMON) $(APPLIB) $(CC) $(CFLAGS) -o lwip_unittests $(TESTOBJS) $(LWIPLIBCOMMON) $(APPLIB) $(LDFLAGS) endif