From 86948b9b08000540129787331b951a9018bf734c Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Fri, 11 Jan 2013 17:55:03 +0100 Subject: wixl: add --includedir to add directory to search for included files --- tools/wixl/preprocessor.vala | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'tools/wixl/preprocessor.vala') diff --git a/tools/wixl/preprocessor.vala b/tools/wixl/preprocessor.vala index 2d87b21..d53f341 100644 --- a/tools/wixl/preprocessor.vala +++ b/tools/wixl/preprocessor.vala @@ -2,14 +2,16 @@ namespace Wixl { class Preprocessor: Object { + unowned List includedirs; HashTable globals; HashTable variables; construct { variables = new HashTable (str_hash, str_equal); } - public Preprocessor (HashTable globals) { + public Preprocessor (HashTable globals, List includedirs) { this.globals = globals; + this.includedirs = includedirs; } public void define_variable (string name, string value) { @@ -114,11 +116,21 @@ namespace Wixl { break; case "include": var value = eval (reader.const_value (), file).strip (); - foreach (var inc in new string[] { - value, - file.get_parent ().get_child (value).get_path () }) - if (include (inc, writer)) + var success = false; + string[] dirs = {}; + dirs += value; + dirs += file.get_parent ().get_child (value).get_path (); + foreach (var dir in includedirs) + dirs += dir.get_child (value).get_path (); + foreach (var inc in dirs) { + success = include (inc, writer); + if (success) break; + } + if (!success) { + print ("error", loc, "Failed to include %s".printf (value)); + Posix.exit (1); + } break; case "warning": print ("warning", loc, eval (reader.const_value (), file)); -- cgit