summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2022-08-31 14:15:16 -0400
committerThibault Saunier <tsaunier@igalia.com>2023-04-22 09:32:32 -0400
commitb14e675a2786c31aa614ed23591fbed03d05a946 (patch)
tree734669cdb6c63a3fbe7ab27f796e044d47665094 /scripts
parentd4a910649955ecbee2db1ced67eed748995f6d58 (diff)
downloadgstreamer-b14e675a2786c31aa614ed23591fbed03d05a946.tar.gz
gir: Checkout all .gir files and check that they are updated on the CI
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3010>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/update-girs.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/update-girs.py b/scripts/update-girs.py
new file mode 100755
index 0000000000..db115481fc
--- /dev/null
+++ b/scripts/update-girs.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python3
+import os
+import sys
+from lxml import etree
+
+from pathlib import Path as P
+import argparse
+
+PARSER = argparse.ArgumentParser()
+PARSER.add_argument('builddir')
+PARSER.add_argument('girs', nargs="+")
+
+
+def make_rel(elem, gir_relpath):
+ filepath = P(elem.attrib["filename"])
+ filedir = filepath.parent
+ girdir = gir_relpath.parent
+
+ while filedir.name != girdir.name:
+ filedir = filedir.parent
+
+ while filedir.name == girdir.name:
+ filedir = filedir.parent
+ girdir = girdir.parent
+ elem.attrib["filename"] = str('..' / girdir / filepath)
+
+
+if __name__ == "__main__":
+ opts = PARSER.parse_args()
+ girdir = P(__file__).parent.parent / 'girs'
+
+ for girfile in opts.girs:
+ gir_relpath = P(os.path.relpath(girfile, opts.builddir))
+ et = etree.parse(girfile)
+ # Remove line numbers from the girs as those would change all the time.
+ for n in et.iter("{http://www.gtk.org/introspection/core/1.0}source-position"):
+ del n.attrib["line"]
+ make_rel(n, gir_relpath)
+ for n in et.iter("{http://www.gtk.org/introspection/core/1.0}doc"):
+ del n.attrib["line"]
+ make_rel(n, gir_relpath)
+ et.write(str(girdir / os.path.basename(girfile)), pretty_print=True)