[vala] Add --shared-library option for GIR files



commit b51ed806a1964191ab3c351eb5d84ca0e6f8987a
Author: David Lechner <david lechnology com>
Date:   Tue Aug 11 11:57:52 2015 +0200

    Add --shared-library option for GIR files
    
    Fixes bug 585116

 codegen/valagirwriter.vala |    7 ++++++-
 compiler/valacompiler.vala |    4 +++-
 doc/valac.1                |    3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index f0a75e2..3a70e68 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -30,6 +30,7 @@ public class Vala.GIRWriter : CodeVisitor {
        private string directory;
        private string gir_namespace;
        private string gir_version;
+       private string gir_shared_library;
 
        protected virtual string? get_interface_comment (Interface iface) {
                return null;
@@ -141,11 +142,12 @@ public class Vala.GIRWriter : CodeVisitor {
         * @param context  a code context
         * @param filename a relative or absolute filename
         */
-       public void write_file (CodeContext context, string directory, string gir_filename, string 
gir_namespace, string gir_version, string package) {
+       public void write_file (CodeContext context, string directory, string gir_filename, string 
gir_namespace, string gir_version, string package, string? gir_shared_library) {
                this.context = context;
                this.directory = directory;
                this.gir_namespace = gir_namespace;
                this.gir_version = gir_version;
+               this.gir_shared_library = gir_shared_library;
 
                var root_symbol = context.root;
                var glib_ns = root_symbol.scope.lookup ("GLib");
@@ -256,6 +258,9 @@ public class Vala.GIRWriter : CodeVisitor {
                write_indent ();
                buffer.append_printf ("<namespace name=\"%s\" version=\"%s\"", gir_namespace, gir_version);
                string? cprefix = CCodeBaseModule.get_ccode_prefix (ns);
+               if (gir_shared_library != null) {
+                       buffer.append_printf(" shared-library=\"%s\"", gir_shared_library);
+               }
                if (cprefix != null) {
                        buffer.append_printf (" c:prefix=\"%s\"", cprefix);
                }
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 11ccb86..ac16d24 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -40,6 +40,7 @@ class Vala.Compiler {
        static string[] metadata_directories;
        static string vapi_filename;
        static string library;
+       static string shared_library;
        static string gir;
        [CCode (array_length = false, array_null_terminated = true)]
        static string[] packages;
@@ -102,6 +103,7 @@ class Vala.Compiler {
                { "pkg", 0, 0, OptionArg.STRING_ARRAY, ref packages, "Include binding for PACKAGE", 
"PACKAGE..." },
                { "vapi", 0, 0, OptionArg.FILENAME, ref vapi_filename, "Output VAPI file name", "FILE" },
                { "library", 0, 0, OptionArg.STRING, ref library, "Library name", "NAME" },
+               { "shared-library", 0, 0, OptionArg.STRING, ref shared_library, "Shared library name used in 
generated gir", "NAME" },
                { "gir", 0, 0, OptionArg.STRING, ref gir, "GObject-Introspection repository file name", 
"NAME-VERSION.gir" },
                { "basedir", 'b', 0, OptionArg.FILENAME, ref basedir, "Base source directory", "DIRECTORY" },
                { "directory", 'd', 0, OptionArg.FILENAME, ref directory, "Output directory", "DIRECTORY" },
@@ -409,7 +411,7 @@ class Vala.Compiler {
                                                        gir_directory = context.directory;
                                                }
 
-                                               gir_writer.write_file (context, gir_directory, gir, 
gir_namespace, gir_version, library);
+                                               gir_writer.write_file (context, gir_directory, gir, 
gir_namespace, gir_version, library, shared_library);
                                        }
                                }
 
diff --git a/doc/valac.1 b/doc/valac.1
index ff24bf5..5000a26 100644
--- a/doc/valac.1
+++ b/doc/valac.1
@@ -36,6 +36,9 @@ Output VAPI file name
 .B \--library=\fINAME\fR
 Library name
 .TP
+.B \--shared-library=\fINAME\fR
+Shared library name used in generated .gir
+.TP
 .B \--gir=\fINAME\fR-\fIVERSION\fR.gir
 GObject-Introspection repository file name
 .TP


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