scripts: update-girs: Normalize shared-library extensions for macOS

So the script can be used on mac

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8476>
This commit is contained in:
Thibault Saunier 2025-02-13 11:49:24 -03:00 committed by GStreamer Marge Bot
parent 7a70860ac0
commit 2df47c1300

View File

@ -25,6 +25,15 @@ def make_rel(elem, gir_relpath):
elem.attrib["filename"] = str('..' / girdir / filepath)
def normalize_shared_library(namespace_elem):
"""Replace .dylib with .so.0 in shared-library attribute"""
if "shared-library" in namespace_elem.attrib:
shared_lib = namespace_elem.attrib["shared-library"]
if shared_lib.endswith(".0.dylib"):
normalized_lib = shared_lib.replace(".0.dylib", ".so.0")
namespace_elem.attrib["shared-library"] = normalized_lib
if __name__ == "__main__":
opts = PARSER.parse_args()
girdir = P(__file__).parent.parent / 'girs'
@ -39,4 +48,7 @@ if __name__ == "__main__":
for n in et.iter("{http://www.gtk.org/introspection/core/1.0}doc"):
del n.attrib["line"]
make_rel(n, gir_relpath)
# Normalize shared library names
for namespace in et.iter("{http://www.gtk.org/introspection/core/1.0}namespace"):
normalize_shared_library(namespace)
et.write(str(girdir / os.path.basename(girfile)), pretty_print=True)