File 1431-snmp-example-ex2-Add-dialyzer-make-targets.patch of Package erlang

From 3c5d70c49a21ed79efb18485b09fe0f998420a4c Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Mon, 11 Jul 2022 18:21:47 +0200
Subject: [PATCH 1/3] [snmp|example|ex2] Add dialyzer (make) targets

OTP-18180
---
 lib/snmp/examples/ex2/Makefile | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/lib/snmp/examples/ex2/Makefile b/lib/snmp/examples/ex2/Makefile
index 829297e802..b6d1c14c60 100644
--- a/lib/snmp/examples/ex2/Makefile
+++ b/lib/snmp/examples/ex2/Makefile
@@ -65,6 +65,19 @@ TARGET_FILES= \
 	$(ERL_FILES:%.erl=%.$(EMULATOR))
 
 
+DIA_PLT      = snmp_example_ex2.plt
+DIA_ANALYSIS = $(basename $(DIA_PLT)).dialyzer_analysis
+ifeq ($(DIAW_EH),true)
+DIA_WARNINGS += -Werror_handling
+endif
+ifeq ($(DIAW_US),true)
+DIA_WARNINGS += -Wunderspecs
+endif
+ifeq ($(DIAW_UR),true)
+DIA_WARNINGS += -Wunmatched_returns
+endif
+
+
 # ----------------------------------------------------
 # Targets
 # ----------------------------------------------------
@@ -80,6 +93,35 @@ docs:
 build: $(TARGET_FILES)
 
 
+dclean:
+	rm -f $(DIA_PLT)
+	rm -f $(DIA_ANALYSIS)
+
+dialyzer_plt: $(DIA_PLT)
+
+$(DIA_PLT): $(ERL_FILES)
+	@echo "Building ($(basename $(DIA_PLT))) plt file"
+	@dialyzer --build_plt \
+                  --output_plt $@ \
+                  -r ../../ebin \
+                     ../../../../lib/kernel/ebin \
+                     ../../../../lib/stdlib/ebin \
+                     ../../../../lib/crypto/ebin \
+                     ../../../../lib/mnesia/ebin \
+                     ../../../../lib/runtime_tools/ebin \
+                     ../../../../lib/compiler/ebin \
+                     ../../../../erts/preloaded/ebin \
+                  --output $(DIA_ANALYSIS) \
+                  --verbose
+
+dialyzer: $(DIA_PLT)
+	@echo "Running dialyzer on $(basename $(DIA_PLT))"
+	@dialyzer --plt $< \
+                  -r ../../ebin \
+                  $(DIA_WARNINGS) \
+                  --verbose
+
+
 # ----------------------------------------------------
 # Release Target
 # ---------------------------------------------------- 
-- 
2.35.3

openSUSE Build Service is sponsored by