From 346093c29041f39f963fc8a1c2e6a1363da7e5f2 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 14 Feb 2020 13:43:24 +0100 Subject: [PATCH] usb: Move Kconfig/Makefile merging into main Makefile.include This allows the check for test IDs to run independently of the configuration source, and provides a canonical point for the configurable (and tested) Makefile variable to enter CFLAGS. --- Makefile.include | 17 +++++++++++++++++ examples/usbus_minimal/Makefile | 13 ------------- tests/usbus/Makefile | 2 -- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Makefile.include b/Makefile.include index 4a6ffc7769..a6faea4790 100644 --- a/Makefile.include +++ b/Makefile.include @@ -662,6 +662,23 @@ endif @$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)' @$(COLOR_ECHO) +# Set USB VID/PID via CFLAGS if not being set via Kconfig +ifndef CONFIG_USB_VID + ifdef USB_VID + CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) + endif +else + USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID)) +endif + +ifndef CONFIG_USB_PID + ifdef USB_PID + CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID) + endif +else + USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID)) +endif + # Exported for the benefit of Kconfig export USB_VID_TESTING = 1209 export USB_PID_TESTING = 7D01 diff --git a/examples/usbus_minimal/Makefile b/examples/usbus_minimal/Makefile index 21f182f584..b9d5dfb4a6 100644 --- a/examples/usbus_minimal/Makefile +++ b/examples/usbus_minimal/Makefile @@ -26,16 +26,3 @@ QUIET ?= 1 SHOULD_RUN_KCONFIG ?= include $(RIOTBASE)/Makefile.include - -# Set USB VID/PID via CFLAGS if not being set via Kconfig -ifndef CONFIG_USB_VID - CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -else - USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID)) -endif - -ifndef CONFIG_USB_PID - CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID) -else - USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID)) -endif diff --git a/tests/usbus/Makefile b/tests/usbus/Makefile index 43abe21364..236d98343c 100644 --- a/tests/usbus/Makefile +++ b/tests/usbus/Makefile @@ -9,6 +9,4 @@ DISABLE_MODULE += auto_init_usbus USB_VID ?= $(USB_VID_TESTING) USB_PID ?= $(USB_PID_TESTING) -CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) - include $(RIOTBASE)/Makefile.include