t/linux: output modules.builtin.modinfo

This makes the linux_image rule provide modules.builtin.modinfo, a
kernel image build side effect, in a separate output group.

Change-Id: I1323089864831e0eefae42c6a0d02288abe179b7
Reviewed-on: https://review.monogon.dev/c/monogon/+/507
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/third_party/linux/def.bzl b/third_party/linux/def.bzl
index 21282f4..c1b3232 100644
--- a/third_party/linux/def.bzl
+++ b/third_party/linux/def.bzl
@@ -69,10 +69,10 @@
     # Tuple containing information about how to build and access the resulting
     # image.
     # The first element (target) is the make target to build, the second
-    # (output_source) is the resulting file to be copied and the last
-    # (output_name) is the name of the output that will be generated by this
+    # (image_source) is the resulting file to be copied and the last
+    # (image_name) is the name of the image that will be generated by this
     # rule.
-    (target, output_source, output_name) = {
+    (target, image_source, image_name) = {
         'vmlinux': ('vmlinux', 'vmlinux', 'vmlinux'),
         'bzImage': ('all', 'arch/x86/boot/bzImage', 'bzImage'),
     }[image_format]
@@ -80,36 +80,45 @@
     # Root of the given Linux sources.
     root = detect_root(ctx.attr.kernel_src)
 
-    output = ctx.actions.declare_file(output_name)
+    image = ctx.actions.declare_file(image_name)
+    modinfo = ctx.actions.declare_file("modules.builtin.modinfo")
     ctx.actions.run_shell(
-        outputs = [ output ],
+        outputs = [ image, modinfo ],
         inputs = [ kernel_config ] + kernel_src,
         command = '''
             kconfig=$1
             target=$2
-            output_source=$3
-            output=$4
+            image_source=$3
+            image=$4
             root=$5
+            modinfo=$6
 
             mkdir ${root}/.bin
             cp ${kconfig} ${root}/.config
             (cd ${root} && make -j $(nproc) ${target} >/dev/null)
-            cp ${root}/${output_source} ${output}
+            cp ${root}/${image_source} ${image}
+            cp ${root}/modules.builtin.modinfo ${modinfo}
         ''',
         arguments = [
             kernel_config.path,
             target,
-            output_source,
-            output.path,
+            image_source,
+            image.path,
             root,
+            modinfo.path
         ],
         use_default_shell_env = True,
     )
 
-    files = depset([output])
-    runfiles = ctx.runfiles(files=[output])
-    return [DefaultInfo(files=files, runfiles=runfiles)]
-
+    return [
+      DefaultInfo(
+        files=depset([image]),
+        runfiles=ctx.runfiles(files=[image])
+      ),
+      OutputGroupInfo(
+        modinfo = depset([modinfo])
+      )
+    ]
 
 linux_image = rule(
     doc = '''