[vala] Make .vapi files on the command line generate quoted includes



commit 0edf174b9747075c8102db270ae023fce6a9c4f4
Author: Daniel Silverstone <dsilvers codethink co uk>
Date:   Thu Oct 20 00:29:20 2011 +0900

    Make .vapi files on the command line generate quoted includes
    
    Use #include "..." rather than #include <...>

 codegen/valaccodebasemodule.vala |    4 +++-
 compiler/valacompiler.vala       |    2 +-
 vala/valacodecontext.vala        |    7 ++++---
 vala/valasourcefile.vala         |    8 +++++++-
 vala/valasymbol.vala             |   13 +++++++++++++
 5 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 233b666..0fd4c71 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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;
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 1ffc858..799d968 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -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;
 				}
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index 250e09e..b0a3fd8 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -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);
diff --git a/vala/valasourcefile.vala b/vala/valasourcefile.vala
index 97cde15..e925a6b 100644
--- a/vala/valasourcefile.vala
+++ b/vala/valasourcefile.vala
@@ -43,6 +43,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;
 	}
 
 	/**
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index d5716af..cc92116 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -200,6 +200,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.
 	 */



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