]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Infer gir_namespace/version from target GIR filename
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 29 Apr 2019 14:48:55 +0000 (16:48 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 5 Nov 2020 18:38:33 +0000 (19:38 +0100)
See https://gitlab.gnome.org/GNOME/vala/issues/606

codegen/valagirwriter.vala

index eea87bc3e32f2c481490424ee8d1c7b8b4d7546b..14f0819a0fd29ea6ae6d850c8f105b6878816339 100644 (file)
@@ -337,6 +337,16 @@ public class Vala.GIRWriter : CodeVisitor {
                        return;
                }
 
+               // Use given gir_namespace and gir_version for our top-level namespace
+               var old_gir_namespace = ns.get_attribute_string ("CCode", "gir_namespace");
+               var old_gir_version = ns.get_attribute_string ("CCode", "gir_version");
+               if ((old_gir_namespace != null && old_gir_namespace != gir_namespace)
+                   || (old_gir_version != null && old_gir_version != gir_version)) {
+                       Report.warning (ns.source_reference, "Replace conflicting CCode.gir_* attributes for namespace `%s'".printf (ns.name));
+               }
+               ns.set_attribute_string ("CCode", "gir_namespace", gir_namespace);
+               ns.set_attribute_string ("CCode", "gir_version", gir_version);
+
                write_c_includes (ns);
 
                write_indent ();