Skip to content

Commit

Permalink
tests,examples/usb: PID, VID warning only when building.
Browse files Browse the repository at this point in the history
The warning issued when the PID and VID are set to the default values should
not be printed on `make clean` and other targets, only with `make all` and it
should be a proper target.

To do: replace shell echos with proper $(warning ..) calls.
  • Loading branch information
jcarrano committed Sep 2, 2019
1 parent d991883 commit 8b88666
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
18 changes: 12 additions & 6 deletions examples/usbus_minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ USEMODULE += usbus
USEMODULE += auto_init_usbus

# USB device vendor and product ID
USB_VID ?= 1209
USB_PID ?= 0001
DEFAULT_VID = 1209
DEFAULT_PID = 0001
USB_VID ?= $(DEFAULT_VID)
USB_PID ?= $(DEFAULT_PID)

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1
Expand All @@ -26,7 +28,11 @@ CFLAGS += -DUSB_CONFIG_VID=0x$(USB_VID) -DUSB_CONFIG_PID=0x$(USB_PID)

include $(RIOTBASE)/Makefile.include

ifeq ($(USB_VID):$(USB_PID), 1209:0001)
$(shell $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2)
$(shell $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2)
endif
.PHONY: usb_id_check
usb_id_check:
@if [ $(USB_VID) = $(DEFAULT_VID) -o $(USB_PID) = $(DEFAULT_PID) ] ; then \
$(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \
$(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \
fi

all: | usb_id_check
18 changes: 12 additions & 6 deletions tests/usbus_cdc_ecm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ CFLAGS += -DGNRC_NETIF_NUMOF=2

# USB device vendor and product ID
# pid.codes test VID/PID, not globally unique
USB_VID ?= 1209
USB_PID ?= 0001
DEFAULT_VID = 1209
DEFAULT_PID = 0001
USB_VID ?= $(DEFAULT_VID)
USB_PID ?= $(DEFAULT_PID)

CFLAGS += -DUSB_CONFIG_VID=0x$(USB_VID) -DUSB_CONFIG_PID=0x$(USB_PID)

include $(RIOTBASE)/Makefile.include

ifeq ($(USB_VID):$(USB_PID), 1209:0001)
$(shell $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2)
$(shell $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2)
endif
.PHONY: usb_id_check
usb_id_check:
@if [ $(USB_VID) = $(DEFAULT_VID) -o $(USB_PID) = $(DEFAULT_PID) ] ; then \
$(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \
$(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \
fi

all: | usb_id_check

0 comments on commit 8b88666

Please sign in to comment.