[vala/staging] vapigen: Warn if the library argument doesn't match any package attribute



commit 2539c2db72f59cba9ff1008c5abb94de1ca15329
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Sep 9 18:12:03 2018 +0200

    vapigen: Warn if the library argument doesn't match any package attribute
    
    GIR files can contain a package key referring to the pkg-config name which
    is the recommended and even required naming of a vapi.
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/669

 vapigen/valavapigen.vala | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/vapigen/valavapigen.vala b/vapigen/valavapigen.vala
index 9fe8ea6f0..f4ae9a50e 100644
--- a/vapigen/valavapigen.vala
+++ b/vapigen/valavapigen.vala
@@ -170,6 +170,9 @@ class Vala.VAPIGen {
                        return quit ();
                }
 
+               // candidates to match library against
+               string[] package_names = {};
+
                // interface writer ignores external packages
                foreach (SourceFile file in context.get_source_files ()) {
                        if (file.filename.has_suffix (".vapi")) {
@@ -187,10 +190,18 @@ class Vala.VAPIGen {
                                                        }
                                                }
                                        }
+                                       if (file.explicit && file.package_name != null) {
+                                               package_names += file.package_name;
+                                       }
                                }
                        }
                }
 
+               var library_name = Path.get_basename (library);
+               if (package_names.length > 0 && !(library_name in package_names)) {
+                       Report.warning (null, "Given library name `%s' does not match pkg-config name 
`%s'".printf (library_name, string.join ("', `", package_names)));
+               }
+
                var interface_writer = new CodeWriter (CodeWriterType.VAPIGEN);
                var vapi_filename = "%s.vapi".printf (library);
                if (directory != null) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]