Skip to contentSkip to conversation

Track explicit module dependencies in Makefile.core.def

PATCH In review Oliver Steffen 2 participants 2 messages Feb 28, 2024 – Mar 4, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Track explicit module dependencies in Makefile.core.def

Add a new keyword, "depends", to the module definition syntax used in Makefile.core.def. This allows specifying explicit module dependencies together with the module definition.

Do not track the "extra_deps.lst" file in the repository anymore, it is now auto-generated.

Make use of this new keyword in the bli module definition.

---
v2:
- fix out-of-source builds

 .gitignore                  | 1 -
 conf/Makefile.common        | 1 +
 gentpl.py                   | 7 +++++++
 grub-core/Makefile.am       | 9 ++++++---
 grub-core/Makefile.core.def | 1 +
 grub-core/extra_deps.lst    | 1 -
 grub-core/genmoddep.awk     | 2 +-
 7 files changed, 16 insertions(+), 6 deletions(-)
 delete mode 100644 grub-core/extra_deps.lst
.gitignore +0 -1
index 4d0dfb700..11fcecf5c 100644
@@ -11,7 +11,6 @@
 *.img
 *.log
 *.lst
-!/grub-core/extra_deps.lst
 *.marker
 *.mod
 *.o
conf/Makefile.common +1 -0
index b8f216f6c..c60f55386 100644
@@ -111,6 +111,7 @@ MOD_FILES =
 MODULE_FILES =
 MARKER_FILES =
 KERNEL_HEADER_FILES =
+EXTRA_DEPS =
 
 bin_SCRIPTS =
 bin_PROGRAMS =
gentpl.py +7 -0
index bfab2113a..3b12eca6c 100644
@@ -631,6 +631,9 @@ def platform_values(defn, platform, suffix):
 def extra_dist(defn):
     return foreach_value(defn, "extra_dist", lambda value: value + " ")
 
+def extra_dep(defn):
+    return foreach_value(defn, "depends", lambda value: value + " ")
+
 def platform_sources(defn, p): return platform_values(defn, p, "")
 def platform_nodist_sources(defn, p): return platform_values(defn, p, "_nodist")
 
@@ -699,6 +702,10 @@ def module(defn, platform):
     gvar_add("MOD_FILES", name + ".mod")
     gvar_add("MARKER_FILES", name + ".marker")
     gvar_add("CLEANFILES", name + ".marker")
+
+    for dep in defn.find_all("depends"):
+        gvar_add("EXTRA_DEPS", "depends " + name + " " + dep + ":")
+
     output("""
 """ + name + """.marker: $(""" + cname(defn) + """_SOURCES) $(nodist_""" + cname(defn) + """_SOURCES)
 	$(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname(defn) + """_CPPFLAGS) $(CPPFLAGS) $^ > [email protected] || (rm -f $@; exit 1)
grub-core/Makefile.am +6 -3
index f18550c1c..1eda467e0 100644
@@ -454,8 +454,11 @@ crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst
 platform_DATA += crypto.lst
 CLEANFILES += crypto.lst
 
-syminfo.lst: gensyminfo.sh kernel_syms.lst $(top_srcdir)/grub-core/extra_deps.lst $(MODULE_FILES)
-	cat kernel_syms.lst $(top_srcdir)/grub-core/extra_deps.lst > [email protected]
+extra_deps.lst:
+	@echo $(EXTRA_DEPS) | sed "s/\s*:\s*/\n/g" > $@
+
+syminfo.lst: gensyminfo.sh kernel_syms.lst extra_deps.lst $(MODULE_FILES)
+	cat kernel_syms.lst extra_deps.lst > [email protected]
 	for m in $(MODULE_FILES); do \
 	  sh $< $$m >> [email protected] || exit 1; \
 	done
@@ -465,7 +468,7 @@ syminfo.lst: gensyminfo.sh kernel_syms.lst $(top_srcdir)/grub-core/extra_deps.ls
 moddep.lst: syminfo.lst genmoddep.awk video.lst
 	cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1)
 platform_DATA += moddep.lst
-CLEANFILES += config.log syminfo.lst moddep.lst
+CLEANFILES += config.log syminfo.lst moddep.lst extra_deps.lst
 
 $(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT)
 	TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
grub-core/Makefile.core.def +1 -0
index 1571421d7..142faeff0 100644
@@ -2594,4 +2594,5 @@ module = {
   name = bli;
   efi = commands/bli.c;
   enable = efi;
+  depends = part_gpt;
 };
grub-core/extra_deps.lst deleted +0 -1
deleted file mode 100644
index f44ad6a0c..000000000
@@ -1 +0,0 @@
-depends bli part_gpt
grub-core/genmoddep.awk +1 -1
index cc987a53a..ab457cb2b 100644
@@ -35,7 +35,7 @@ BEGIN {
     for (i = 3; i <= NF; i++) {
       modtab[$2] = modtab[$2] " " $i;
     }
-  }
+  } else if ($1 == "") {} #Skip empty lines
   else {
     printf "error: %u: unrecognized input format\n", NR >"/dev/stderr";
     error++;
Signature · 7 lines
2.44.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Tested-by on v2 1/1
#1 lore raw
Quoted 7 lines · Oliver Steffen

Add a new keyword, "depends", to the module definition syntax used in Makefile.core.def. This allows specifying explicit module dependencies together with the module definition.

Do not track the "extra_deps.lst" file in the repository anymore, it is now auto-generated.

Quoted 8 lines

Make use of this new keyword in the bli module definition.

---
v2:
- fix out-of-source builds

This fixes the build issue I mentioned in v1 based on running through the same steps again.

However, it feels like there are two distinct things going on in this patch:

1. Code to generate the extra_deps.lst at make-time using the new "depends" keyword
2. Use the new "depends" keyword for the bli module

Would it make more sense to split this patch into two?

Otherwise,

- Oskari

Side note, overall this change is simpler than I expected.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel