]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scripts/get_abi.pl: Add filtering capabilities to rest output
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 10 Feb 2025 10:18:07 +0000 (11:18 +0100)
committerJonathan Corbet <corbet@lwn.net>
Mon, 10 Feb 2025 18:19:57 +0000 (11:19 -0700)
This way, Sphinx ABI extension can parse symbols only once, while
keep displaying results in separate files.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/41e108e816e46434aa596e5c0d25d227cb9f0fe5.1739182025.git.mchehab+huawei@kernel.org
scripts/lib/abi/abi_parser.py

index 1db6c54fc65ada397c13bcc0bbae1d9f66404422..b20d5c9d920e0147dbacf50b40b76d6a1fffe8c2 100644 (file)
@@ -160,6 +160,7 @@ class AbiParser:
                         self.data[fdata.key] = {
                             "what": [content],
                             "file": [fdata.file_ref],
+                            "path": fdata.ftype,
                             "line_no": fdata.ln,
                         }
 
@@ -182,8 +183,6 @@ class AbiParser:
                 if new_what:
                     fdata.label = ""
 
-                    self.data[fdata.key]["type"] = fdata.ftype
-
                     if "description" in self.data[fdata.key]:
                         self.data[fdata.key]["description"] += "\n\n"
 
@@ -299,6 +298,7 @@ class AbiParser:
         fdata.nametag = {}
         fdata.nametag["what"] = [f"File {path}/{basename}"]
         fdata.nametag["type"] = "File"
+        fdata.nametag["path"] = fdata.ftype
         fdata.nametag["file"] = [fdata.file_ref]
         fdata.nametag["line_no"] = 1
         fdata.nametag["description"] = ""
@@ -427,7 +427,8 @@ class AbiParser:
 
         return new_desc + "\n\n"
 
-    def doc(self, output_in_txt=False, show_file=True):
+    def doc(self, output_in_txt=False, show_symbols=True, show_file=True,
+            filter_path=None):
         """Print ABI at stdout"""
 
         part = None
@@ -435,12 +436,20 @@ class AbiParser:
                              key=lambda x: (x[1].get("type", ""),
                                             x[1].get("what"))):
 
-            wtype = v.get("type", "Var")
+            wtype = v.get("type", "Symbol")
             file_ref = v.get("file")
             names = v.get("what", [""])
 
-            if not show_file and wtype == "File":
-                continue
+            if wtype == "File":
+                if not show_file:
+                    continue
+            else:
+                if not show_symbols:
+                    continue
+
+            if filter_path:
+                if v.get("path") != filter_path:
+                    continue
 
             msg = ""