[vala] valac: Add flag to specify a separate basedir for the public header



commit 9cb64c536e0255089ee929052fb81c49e8756b3e
Author: Mark Lee <marklee src gnome org>
Date:   Wed Jul 15 00:41:02 2009 -0700

    valac: Add flag to specify a separate basedir for the public header
    
    This basedir is used in the VAPI file. Needed because of the way that build
    systems such as Waf deal with the location of the public header.
    
    Fixes GNOME Bug #589964.

 compiler/valacompiler.vala |    3 +++
 vala/valacodecontext.vala  |    5 +++++
 vala/valasourcefile.vala   |    3 +++
 3 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 76c6698..3ea847b 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -45,6 +45,7 @@ class Vala.Compiler {
 	static string header_filename;
 	static string internal_header_filename;
 	static string internal_vapi_filename;
+	static string includedir;
 	static bool compile_only;
 	static string output;
 	static bool debug;
@@ -81,6 +82,7 @@ class Vala.Compiler {
 		{ "version", 0, 0, OptionArg.NONE, ref version, "Display version number", null },
 		{ "ccode", 'C', 0, OptionArg.NONE, ref ccode_only, "Output C code", null },
 		{ "header", 'H', 0, OptionArg.FILENAME, ref header_filename, "Output C header file", "FILE" },
+		{ "includedir", 0, 0, OptionArg.FILENAME, ref includedir, "Directory used to include the C header file", "DIRECTORY" },
 		{ "internal-header", 'h', 0, OptionArg.FILENAME, ref internal_header_filename, "Output internal C header file", "FILE" },
 		{ "internal-vapi", 0, 0, OptionArg.FILENAME, ref internal_vapi_filename, "Output vapi with internal api", "FILE" },
 		{ "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null },
@@ -188,6 +190,7 @@ class Vala.Compiler {
 		context.compile_only = compile_only;
 		context.header_filename = header_filename;
 		context.internal_header_filename = internal_header_filename;
+		context.includedir = includedir;
 		context.output = output;
 		if (basedir == null) {
 			context.basedir = realpath (".");
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index a6d783c..5add468 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -73,6 +73,11 @@ public class Vala.CodeContext {
 	public string? internal_header_filename { get; set; }
 
 	/**
+	 * Base directory used for header_filename in the VAPIs.
+	 */
+	public string? includedir { get; set; }
+
+	/**
 	 * Compile but do not link.
 	 */
 	public bool compile_only { get; set; }
diff --git a/vala/valasourcefile.vala b/vala/valasourcefile.vala
index 4c1dfc7..0ec4429 100644
--- a/vala/valasourcefile.vala
+++ b/vala/valasourcefile.vala
@@ -222,6 +222,9 @@ public class Vala.SourceFile {
 		if (cinclude_filename == null) {
 			if (context.header_filename != null) {
 				cinclude_filename = Path.get_basename (context.header_filename);
+				if (context.includedir != null) {
+					cinclude_filename = "%s/%s".printf (context.includedir, cinclude_filename);
+				}
 			} else {
 				cinclude_filename = "%s%s.h".printf (get_subdir (), get_basename ());
 			}



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