]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Make .vapi files on the command line generate quoted includes
authorDaniel Silverstone <dsilvers@codethink.co.uk>
Wed, 19 Oct 2011 15:29:20 +0000 (00:29 +0900)
committerJürg Billeter <j@bitron.ch>
Tue, 15 Nov 2011 17:44:55 +0000 (17:44 +0000)
Use #include "..." rather than #include <...>

codegen/valaccodebasemodule.vala
compiler/valacompiler.vala
vala/valacodecontext.vala
vala/valasourcefile.vala
vala/valasymbol.vala

index 233b666b5a551009d8ffd588a0a2f14e928f0201..0fd4c71a760ef13a28ddb7478719723cd2abe7d3 100644 (file)
@@ -597,7 +597,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) {
                        // add appropriate include file
                        foreach (string header_filename in get_ccode_header_filenames (sym).split (",")) {
-                               decl_space.add_include (header_filename, !sym.external_package);
+                               decl_space.add_include (header_filename, !sym.external_package ||
+                                                                        (sym.external_package &&
+                                                                         sym.from_commandline));
                        }
                        // declaration complete
                        return true;
index 1ffc8589a4e7b04c5642a381d6b706bec93aafc6..799d9683daadcc23b4ae38aab6e2e4bfb853b437 100644 (file)
@@ -298,7 +298,7 @@ class Vala.Compiler {
                bool has_c_files = false;
 
                foreach (string source in sources) {
-                       if (context.add_source_filename (source, run_output)) {
+                       if (context.add_source_filename (source, run_output, true)) {
                                if (source.has_suffix (".c")) {
                                        has_c_files = true;
                                }
index 250e09eeb141cb696e74fe81a1fd2546f39e4001..b0a3fd812b9d96f74ed4cbee186b59c5fec8ba96 100644 (file)
@@ -388,9 +388,10 @@ public class Vala.CodeContext {
         *
         * @param filename a filename
         * @param is_source true to force adding the file as .vala or .gs
+        * @param cmdline true if the file came from the command line.
         * @return false if the file is not recognized or the file does not exist
         */
-       public bool add_source_filename (string filename, bool is_source = false) {
+       public bool add_source_filename (string filename, bool is_source = false, bool cmdline = false) {
                if (!FileUtils.test (filename, FileTest.EXISTS)) {
                        Report.error (null, "%s not found".printf (filename));
                        return false;
@@ -398,7 +399,7 @@ public class Vala.CodeContext {
 
                var rpath = realpath (filename);
                if (is_source || filename.has_suffix (".vala") || filename.has_suffix (".gs")) {
-                       var source_file = new SourceFile (this, SourceFileType.SOURCE, rpath);
+                       var source_file = new SourceFile (this, SourceFileType.SOURCE, rpath, null, cmdline);
                        source_file.relative_filename = filename;
 
                        if (profile == Profile.POSIX) {
@@ -420,7 +421,7 @@ public class Vala.CodeContext {
 
                        add_source_file (source_file);
                } else if (filename.has_suffix (".vapi") || filename.has_suffix (".gir")) {
-                       var source_file = new SourceFile (this, SourceFileType.PACKAGE, rpath);
+                       var source_file = new SourceFile (this, SourceFileType.PACKAGE, rpath, null, cmdline);
                        source_file.relative_filename = filename;
 
                        add_source_file (source_file);
index 97cde15d8e4305d3e4893f78cb523431fff4522c..e925a6ba2b152ac0a9107e5eafc7770c9b468eef 100644 (file)
@@ -42,6 +42,11 @@ public class Vala.SourceFile {
         */
        public SourceFileType file_type { get; set; }
 
+       /**
+        * Specifies whether this file came from the command line directly.
+        */
+       public bool from_commandline { get; set; }
+
        /**
         *  GIR Namespace for this source file, if it's a VAPI package
         */
@@ -97,11 +102,12 @@ public class Vala.SourceFile {
         * @param pkg      true if this is a VAPI package file
         * @return         newly created source file
         */
-       public SourceFile (CodeContext context, SourceFileType type, string filename, string? content = null) {
+       public SourceFile (CodeContext context, SourceFileType type, string filename, string? content = null, bool cmdline = false) {
                this.context = context;
                this.file_type = type;
                this.filename = filename;
                this.content = content;
+               this.from_commandline = cmdline;
        }
 
        /**
index d5716af01e1499e129f7b4dc47a43b37d6235b4a..cc92116966c768570d5ef173108b2fa77a617c0c 100644 (file)
@@ -199,6 +199,19 @@ public abstract class Vala.Symbol : CodeNode {
                }
        }
 
+       /**
+        * Specifies whether the implementation came from the commandline.
+        */
+       public bool from_commandline {
+               get {
+                       if (source_reference != null) {
+                               return source_reference.file.from_commandline;
+                       } else {
+                               return false;
+                       }
+               }
+       }
+
        /**
         * Gets the SourceFileType of the source file that this symbol
         * came from, or SourceFileType.NONE.