From 94d2f776432da7da68e4b6ecaed58b8ac4b2eb1f Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 6 Dec 2016 10:52:40 -0800 Subject: [PATCH] build system: Remove FLAGS_XXX variable option, replace with per-target overrides Use for targeted disabling of warnings in LWIP. --- components/lwip/component.mk | 4 +++- docs/build_system.rst | 7 ++++++- make/component_wrapper.mk | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/lwip/component.mk b/components/lwip/component.mk index 49fc644ae4..df116f1a06 100644 --- a/components/lwip/component.mk +++ b/components/lwip/component.mk @@ -6,5 +6,7 @@ COMPONENT_ADD_INCLUDEDIRS := include/lwip include/lwip/port include/lwip/posix COMPONENT_SRCDIRS := api apps/sntp apps core/ipv4 core/ipv6 core netif port/freertos port/netif port -CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable +CFLAGS += -Wno-address # lots of LWIP source files evaluate macros that check address of stack variables +api/tcpip.o apps/dhcpserver.o: CFLAGS += -Wno-unused-variable +apps/dhcpserver.o core/pbuf.o core/tcp_in.o: CFLAGS += -Wno-unused-but-set-variable diff --git a/docs/build_system.rst b/docs/build_system.rst index ad263da7af..75f48bb248 100644 --- a/docs/build_system.rst +++ b/docs/build_system.rst @@ -244,7 +244,12 @@ The following variables can be set inside ``component.mk`` to control the build settings. Component-specific additions can be made via ``CXXFLAGS +=``. It is also possible (although not recommended) to override this variable completely for a component. -- ``FLAGS_basename`` allows you to set compilation flags to apply to a single source file only. For example, this can useful for disabling warnings in a single upstream source file. The ``basename`` portion is the directory (relative to ``COMPONENT_PATH``) and the base filename (without extension) of the source file. For example, if a file inside ``COMPONENT_PATH`` is ``library/alpha/widget.c`` then you can set variable ``FLAGS_library/alpha/widget := -DTEST`` to pass the TEST macro when compiling this source file only. + +To apply compilation flags to a single source file, you can add a variable override as a target, ie:: + + apps/dhcpserver.o: CFLAGS += -Wno-unused-variable + +This can be useful if there is upstream code that emits warnings. Component Configuration ----------------------- diff --git a/make/component_wrapper.mk b/make/component_wrapper.mk index 63f687d930..75bb4b1a03 100644 --- a/make/component_wrapper.mk +++ b/make/component_wrapper.mk @@ -157,15 +157,15 @@ define GenerateCompileTargets # $(1) - directory containing source files, relative to $(COMPONENT_PATH) $(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.c $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(1) $$(summary) CC $$@ - $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(FLAGS_$$(subst .o,,$$(@))) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@ + $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@ $(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.cpp $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(1) $$(summary) CXX $$@ - $$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) $$(FLAGS_$$(subst .o,,$$(@))) $$(addprefix -I,$$(COMPONENT_INCLUDES)) $$(addprefix -I,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@ + $$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) $$(addprefix -I,$$(COMPONENT_INCLUDES)) $$(addprefix -I,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@ $(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.S $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(1) $$(summary) AS $$@ - $$(CC) $$(CPPFLAGS) $$(FLAGS_$$(subst .o,,$$(@))) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@ + $$(CC) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@ # CWD is build dir, create the build subdirectory if it doesn't exist $(1): -- 2.40.0