From 009bd4ac0175fcbd3254505faf722dbb14e0078c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 13 May 2022 20:44:15 +0200 Subject: [PATCH] [apidiff] Simplify code a bit to use templates and iterate over the selected platforms. (#15006) --- tools/apidiff/Makefile | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/tools/apidiff/Makefile b/tools/apidiff/Makefile index 9105f4ac5f..dcaf46f8b2 100644 --- a/tools/apidiff/Makefile +++ b/tools/apidiff/Makefile @@ -205,6 +205,14 @@ API_DIFF_DEPENDENCIES += $(foreach assembly,$(DOTNET_ASSEMBLIES),$(APIDIFF_DIR)/ API_DIFF_DEPENDENCIES += $(foreach assembly,$(DOTNET_LEGACY_ASSEMBLIES),$(APIDIFF_DIR)/dotnet/legacy-diff/$(assembly)-api-diff.html) endif +define ApiDiffReport + if ! grep "No change detected" $(APIDIFF_DIR)/dotnet/Microsoft.$(1).Ref/ref/$(DOTNET_TFM)/Microsoft.$(1)-api-diff.html >/dev/null 2>&1; then \ + echo "

Microsoft.$(1) (.NET) API diff

" >> $(2); \ + else \ + echo "

Microsoft.$(1) (.NET) API diff is empty

" >> $(2); \ + fi; +endef + $(APIDIFF_DIR)/api-diff.html: $(API_DIFF_DEPENDENCIES) $(QF_GEN) echo "

API diffs

" > $@ ifdef INCLUDE_IOS @@ -237,35 +245,7 @@ ifdef INCLUDE_MAC endif # New Dotnet vs Stable Dotnet -ifdef ENABLE_DOTNET -ifdef INCLUDE_IOS - $(Q) if ! grep "No change detected" $(APIDIFF_DIR)/dotnet/Microsoft.iOS.Ref/ref/$(DOTNET_TFM)/Microsoft.iOS-api-diff.html >/dev/null 2>&1; then \ - echo "

Microsoft.iOS Dotnet API diff

" >> $@; \ - else \ - echo "

Microsoft.iOS Dotnet API diff is empty

" >> $@; \ - fi; -ifdef INCLUDE_TVOS - $(Q) if ! grep "No change detected" $(APIDIFF_DIR)/dotnet/Microsoft.tvOS.Ref/ref/$(DOTNET_TFM)/Microsoft.tvOS-api-diff.html >/dev/null 2>&1; then \ - echo "

Microsoft.tvOS Dotnet API diff

" >> $@; \ - else \ - echo "

Microsoft.tvOS Dotnet API diff is empty

" >> $@; \ - fi; -endif -ifdef INCLUDE_MACCATALYST - $(Q) if ! grep "No change detected" $(APIDIFF_DIR)/dotnet/Microsoft.MacCatalyst.Ref/ref/$(DOTNET_TFM)/Microsoft.MacCatalyst-api-diff.html >/dev/null 2>&1; then \ - echo "

Microsoft.MacCatalyst Dotnet API diff

" >> $@; \ - else \ - echo "

Microsoft.MacCatalyst Dotnet API diff is empty

" >> $@; \ - fi; -endif -endif -ifdef INCLUDE_MAC - $(Q) if ! grep "No change detected" $(APIDIFF_DIR)/dotnet/Microsoft.macOS.Ref/ref/$(DOTNET_TFM)/Microsoft.macOS-api-diff.html >/dev/null 2>&1; then \ - echo "

Microsoft.macOS Dotnet API diff

" >> $@; \ - else \ - echo "

Microsoft.macOS Dotnet API diff is empty

" >> $@; \ - fi; -endif + $(Q) $(foreach platform,$(DOTNET_PLATFORMS),$(call ApiDiffReport,$(platform),$@)) # New Dotnet vs. Stable Legacy ifdef INCLUDE_IOS @@ -284,7 +264,6 @@ ifdef INCLUDE_MACCATALYST $(Q) echo "

Microsoft.iOS vs Microsoft.MacCatalyst API diff

" >> $@ endif endif -endif # ENABLE_DOTNET # easy-to-type helper targets. # one rule to create all the api diffs