Skip to content

Commit 91932ac

Browse files
committed
refactor(Makefile.posix): DRY $SOFTDEVICE definedness check
1 parent db6b60b commit 91932ac

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

make/Makefile.posix

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@ flash.stlinkv2:
7474
$(MAKE_BUILD_FOLDER)
7575
$(OPENOCD) -c 'program $(HEX) verify reset exit'
7676

77-
test-softdevice: test-softdevice.jlink
7877
ifndef SOFTDEVICE
78+
define softdevice-defined=
7979
$(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file")
80+
endef
81+
else
82+
define softdevice-defined=
83+
endef
8084
endif
8185

86+
test-softdevice: test-softdevice.jlink $(softdevice-defined)
87+
8288
ifneq ($(SOFTDEVICE_MODEL),blank)
8389
$(MAKE_BUILD_FOLDER)
8490
@touch $(SOFTDEVICE_TEST_FLASH)
@@ -98,12 +104,9 @@ test-softdevice.jlink:
98104
printf "r\nsavebin $(SOFTDEVICE_TEST_FLASH) $(SOFTDEVICE_TEST_ADDR) $(SOFTDEVICE_TEST_LEN)\nexit\n" > $(OUTPUT_PATH)test-softdevice.jlink
99105

100106
ifeq ($(PROGRAMMER),stlinkv2)
101-
flash-softdevice: erase-all flash-softdevice.stlinkv2
107+
flash-softdevice: erase-all $(softdevice-defined) flash-softdevice.stlinkv2
102108
else
103-
flash-softdevice: erase-all flash-softdevice.jlink
104-
ifndef SOFTDEVICE
105-
$(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file")
106-
endif
109+
flash-softdevice: erase-all $(softdevice-defined) flash-softdevice.jlink
107110
$(MAKE_BUILD_FOLDER)
108111
$(OBJCOPY) -Iihex -Obinary $(SOFTDEVICE) $(SOFTDEVICE_OUTPUT:.hex=.bin)
109112
$(JLINK) $(OUTPUT_PATH)flash-softdevice.jlink
@@ -115,9 +118,6 @@ flash-softdevice.jlink:
115118
printf "w4 4001e504 1\nloadbin \"$(SOFTDEVICE_OUTPUT:.hex=.bin)\" 0\nr\ng\nexit\n" > $(OUTPUT_PATH)flash-softdevice.jlink
116119

117120
flash-softdevice.stlinkv2:
118-
ifndef SOFTDEVICE
119-
$(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file")
120-
endif
121121
$(MAKE_BUILD_FOLDER)
122122
$(OPENOCD) -c 'program $(SOFTDEVICE) verify reset exit'
123123

0 commit comments

Comments
 (0)