From b8f2dc704b8790afbbdd2766fb58534f7678527b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Urb=C3=A1n?= Date: Fri, 24 Mar 2023 11:51:46 +0100 Subject: [PATCH] Add include-what-you-use test for public headers --- src/cyw43_internal.h | 6 ++++++ src/cyw43_sdio.h | 4 ++++ src/cyw43_spi.h | 5 +++++ tests/sdio/Makefile | 24 +++++++++++++++++++++++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/cyw43_internal.h b/src/cyw43_internal.h index d38b968..3acac96 100644 --- a/src/cyw43_internal.h +++ b/src/cyw43_internal.h @@ -34,6 +34,12 @@ #ifndef CYW43_INCLUDED_CYW43_INTERNAL_H #define CYW43_INCLUDED_CYW43_INTERNAL_H +#include "cyw43_ll.h" + +#include +#include +#include + #define BUS_FUNCTION (0) #define BACKPLANE_FUNCTION (1) #define WLAN_FUNCTION (2) diff --git a/src/cyw43_sdio.h b/src/cyw43_sdio.h index 6dc1188..d2a5e45 100644 --- a/src/cyw43_sdio.h +++ b/src/cyw43_sdio.h @@ -34,6 +34,10 @@ #ifndef CYW43_INCLUDED_CYW43_SDIO_H #define CYW43_INCLUDED_CYW43_SDIO_H +#include +#include +#include + // These must be provided by a port, if the SDIO bus interface is used. void cyw43_sdio_init(void); void cyw43_sdio_reinit(void); diff --git a/src/cyw43_spi.h b/src/cyw43_spi.h index 9594190..8c3d94d 100644 --- a/src/cyw43_spi.h +++ b/src/cyw43_spi.h @@ -34,6 +34,11 @@ #ifndef CYW43_INCLUDED_CYW43_SPI_H #define CYW43_INCLUDED_CYW43_SPI_H +#include "cyw43_internal.h" + +#include +#include + // Test register value #define TEST_PATTERN 0xFEEDBEADu diff --git a/tests/sdio/Makefile b/tests/sdio/Makefile index 449bc2a..9f29e0e 100644 --- a/tests/sdio/Makefile +++ b/tests/sdio/Makefile @@ -48,10 +48,32 @@ $(OBJ): | $(OBJ_DIRS) $(OBJ_DIRS): $(MKDIR) -p $@ +# "Include-what-you-use"-test compilation for public headers +PUBLIC_HEADER := \ + src/cyw43.h \ + src/cyw43_btbus.h \ + src/cyw43_country.h \ + src/cyw43_sdio.h \ + src/cyw43_spi.h \ + src/cyw43_stats.h \ + +vpath %.h . $(CYW43_TOP) + +PUBLIC_HEADER_GCH := $(patsubst %,$(BUILD)/%.gch,$(PUBLIC_HEADER)) + +# Static pattern rule testing header compilation by making a pre-compiled header of each +$(PUBLIC_HEADER_GCH): $(BUILD)/%.h.gch: %.h +# Pass -Wno-pedantic to suppress "empty translation unit" errors + $(CC) $(CFLAGS) -Wno-pedantic -c $< -o $@ + +# Add to phony test target trigger +test: $(PUBLIC_HEADER_GCH) + # Dependency generation %.o: %.d +%.gch: %.d CFLAGS += -MP -MMD -DEP := $(OBJ:.o=.d) +DEP := $(OBJ:.o=.d) $(PUBLIC_HEADER_GCH:.gch=.d) $(DEP): -include $(DEP)