From 6c0f94cbd0ede1dad6383ea27a8d8569123afefc Mon Sep 17 00:00:00 2001 From: Darryl Green Date: Wed, 17 Oct 2018 16:12:33 +0100 Subject: [PATCH] Add better handling when deleting files on Windows Windows complains if you try to delete a file that doesn't exist. Makefiles now check if the files exist before trying to delete them. --- library/Makefile | 3 ++- programs/Makefile | 4 +++- tests/Makefile | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/library/Makefile b/library/Makefile index f4b39bdeb..cf6750d05 100644 --- a/library/Makefile +++ b/library/Makefile @@ -200,5 +200,6 @@ clean: ifndef WINDOWS rm -f *.o libmbed* else - del /Q /F *.o libmbed* + if exist *.o del /Q /F *.o + if exist libmbed* del /Q /F libmbed* endif diff --git a/programs/Makefile b/programs/Makefile index 9cc28c47e..f3627c906 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -322,7 +322,9 @@ clean: ifndef WINDOWS rm -f $(APPS) $(EXTRA_GENERATED) else - del /S /Q /F *.o *.exe $(EXTRA_GENERATED) + if exist *.o del /S /Q /F *.o + if exist *.exe del /S /Q /F *.exe + if exist $(EXTRA_GENERATED) del /S /Q /F $(EXTRA_GENERATED) endif list: diff --git a/tests/Makefile b/tests/Makefile index b6e49bf8a..889d2a7da 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -107,7 +107,9 @@ clean: ifndef WINDOWS rm -rf $(BINARIES) *.c *.datax TESTS else - del /Q /F *.c *.exe *.datax + if exist *.c del /Q /F *.c + if exist *.exe del /Q /F *.exe + if exist *.datax del /Q /F *.datax ifneq ($(wildcard TESTS/.*),) rmdir /Q /S TESTS endif