Skip to content

Commit

Permalink
selftests: net: rebuild YNL if dependencies changed
Browse files Browse the repository at this point in the history
Try to rebuild YNL if either user added a new family or the specs
of the families have changed. Stanislav's ncdevmem cause a false
positive build failure in NIPA because libynl.a isn't rebuilt
after ethtool is added to YNL_GENS.

Note that sha1sum is already used in other parts of the build system.

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20241011230311.2529760-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Oct 15, 2024
1 parent 2a22bea commit 0cb06dc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tools/testing/selftests/net/ynl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,28 @@
# YNL_GEN_FILES: TEST_GEN_FILES which need YNL

YNL_OUTPUTS := $(patsubst %,$(OUTPUT)/%,$(YNL_GEN_FILES))
YNL_SPECS := \
$(patsubst %,$(top_srcdir)/Documentation/netlink/specs/%.yaml,$(YNL_GENS))

$(YNL_OUTPUTS): $(OUTPUT)/libynl.a
$(YNL_OUTPUTS): CFLAGS += \
-I$(top_srcdir)/usr/include/ $(KHDR_INCLUDES) \
-I$(top_srcdir)/tools/net/ynl/lib/ \
-I$(top_srcdir)/tools/net/ynl/generated/

$(OUTPUT)/libynl.a:
# Make sure we rebuild libynl if user added a new family. We can't easily
# depend on the contents of a variable so create a fake file with a hash.
YNL_GENS_HASH := $(shell echo $(YNL_GENS) | sha1sum | cut -c1-8)
$(OUTPUT)/.libynl-$(YNL_GENS_HASH).sig:
$(Q)rm -f $(OUTPUT)/.libynl-*.sig
$(Q)touch $(OUTPUT)/.libynl-$(YNL_GENS_HASH).sig

$(OUTPUT)/libynl.a: $(YNL_SPECS) $(OUTPUT)/.libynl-$(YNL_GENS_HASH).sig
$(Q)rm -f $(top_srcdir)/tools/net/ynl/libynl.a
$(Q)$(MAKE) -C $(top_srcdir)/tools/net/ynl GENS="$(YNL_GENS)" libynl.a
$(Q)cp $(top_srcdir)/tools/net/ynl/libynl.a $(OUTPUT)/libynl.a

EXTRA_CLEAN += \
$(top_srcdir)/tools/net/ynl/lib/__pycache__ \
$(top_srcdir)/tools/net/ynl/lib/*.[ado]
$(top_srcdir)/tools/net/ynl/lib/*.[ado] \
$(OUTPUT)/.libynl-*.sig

0 comments on commit 0cb06dc

Please sign in to comment.