From 91932ac341f05f282e60b70386d581db89c5db3e Mon Sep 17 00:00:00 2001 From: Dmitriy Volkov Date: Fri, 10 Feb 2017 17:16:24 +0300 Subject: [PATCH] refactor(Makefile.posix): DRY $SOFTDEVICE definedness check --- make/Makefile.posix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/make/Makefile.posix b/make/Makefile.posix index c9d03653..bfe58335 100644 --- a/make/Makefile.posix +++ b/make/Makefile.posix @@ -74,11 +74,17 @@ flash.stlinkv2: $(MAKE_BUILD_FOLDER) $(OPENOCD) -c 'program $(HEX) verify reset exit' -test-softdevice: test-softdevice.jlink ifndef SOFTDEVICE +define softdevice-defined= $(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file") +endef +else +define softdevice-defined= +endef endif +test-softdevice: test-softdevice.jlink $(softdevice-defined) + ifneq ($(SOFTDEVICE_MODEL),blank) $(MAKE_BUILD_FOLDER) @touch $(SOFTDEVICE_TEST_FLASH) @@ -98,12 +104,9 @@ test-softdevice.jlink: printf "r\nsavebin $(SOFTDEVICE_TEST_FLASH) $(SOFTDEVICE_TEST_ADDR) $(SOFTDEVICE_TEST_LEN)\nexit\n" > $(OUTPUT_PATH)test-softdevice.jlink ifeq ($(PROGRAMMER),stlinkv2) -flash-softdevice: erase-all flash-softdevice.stlinkv2 +flash-softdevice: erase-all $(softdevice-defined) flash-softdevice.stlinkv2 else -flash-softdevice: erase-all flash-softdevice.jlink -ifndef SOFTDEVICE - $(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file") -endif +flash-softdevice: erase-all $(softdevice-defined) flash-softdevice.jlink $(MAKE_BUILD_FOLDER) $(OBJCOPY) -Iihex -Obinary $(SOFTDEVICE) $(SOFTDEVICE_OUTPUT:.hex=.bin) $(JLINK) $(OUTPUT_PATH)flash-softdevice.jlink @@ -115,9 +118,6 @@ flash-softdevice.jlink: printf "w4 4001e504 1\nloadbin \"$(SOFTDEVICE_OUTPUT:.hex=.bin)\" 0\nr\ng\nexit\n" > $(OUTPUT_PATH)flash-softdevice.jlink flash-softdevice.stlinkv2: -ifndef SOFTDEVICE - $(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file") -endif $(MAKE_BUILD_FOLDER) $(OPENOCD) -c 'program $(SOFTDEVICE) verify reset exit'