[vala] Make vapigen obey deps files for --pkg arguments.



commit 6b52989eb7e7b1c59d6ff2cc46ad2898f7c713fc
Author: Rob Taylor <rob taylor codethink co uk>
Date:   Tue Jun 9 11:51:15 2009 +0100

    Make vapigen obey deps files for --pkg arguments.

 vapigen/valavapigen.vala |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/vapigen/valavapigen.vala b/vapigen/valavapigen.vala
index 4b8f352..e65df13 100644
--- a/vapigen/valavapigen.vala
+++ b/vapigen/valavapigen.vala
@@ -65,6 +65,7 @@ class Vala.VAPIGen : Object {
 		}
 	}
 
+	/* TODO: this is duplicated between here and the compiler. its should go somewhere on its own */
 	private bool add_package (string pkg) {
 		if (context.has_package (pkg)) {
 			// ignore multiple occurences of the same package
@@ -80,7 +81,26 @@ class Vala.VAPIGen : Object {
 		context.add_package (pkg);
 
 		context.add_source_file (new SourceFile (context, package_path, true));
-		
+
+		var deps_filename = Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg));
+		if (FileUtils.test (deps_filename, FileTest.EXISTS)) {
+			try {
+				string deps_content;
+				ulong deps_len;
+				FileUtils.get_contents (deps_filename, out deps_content, out deps_len);
+				foreach (string dep in deps_content.split ("\n")) {
+					dep.strip ();
+					if (dep != "") {
+						if (!add_package (dep)) {
+							Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg));
+						}
+					}
+				}
+			} catch (FileError e) {
+				Report.error (null, "Unable to read dependency file: %s".printf (e.message));
+			}
+		}
+
 		return true;
 	}
 	



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