diff options
-rw-r--r-- | tools/wixl/builder.vala | 7 | ||||
-rw-r--r-- | tools/wixl/preprocessor.vala | 22 | ||||
-rw-r--r-- | tools/wixl/wixl.vala | 5 |
3 files changed, 26 insertions, 8 deletions
diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala index 252517b..50fbdd3 100644 --- a/tools/wixl/builder.vala +++ b/tools/wixl/builder.vala @@ -2,13 +2,16 @@ namespace Wixl { class WixBuilder: WixNodeVisitor { - public WixBuilder () { + public WixBuilder (string[] includedirs) { add_path ("."); + foreach (var i in includedirs) + this.includedirs.append (File.new_for_path (i)); } WixRoot root; MsiDatabase db; HashTable<string, string> variables; + List<File> includedirs; construct { variables = new HashTable<string, string> (str_hash, str_equal); @@ -43,7 +46,7 @@ namespace Wixl { string data; FileUtils.get_contents (file.get_path (), out data); - var p = new Preprocessor (variables); + var p = new Preprocessor (variables, includedirs); var doc = p.preprocess (data, file); if (preproc_only) { doc.dump_format (FileStream.fdopen (1, "w")); 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<File> includedirs; HashTable<string, string> globals; HashTable<string, string> variables; construct { variables = new HashTable<string, string> (str_hash, str_equal); } - public Preprocessor (HashTable<string, string> globals) { + public Preprocessor (HashTable<string, string> globals, List<File> 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)); diff --git a/tools/wixl/wixl.vala b/tools/wixl/wixl.vala index 057749d..a4ea371 100644 --- a/tools/wixl/wixl.vala +++ b/tools/wixl/wixl.vala @@ -10,12 +10,15 @@ namespace Wixl { static string[] files; [CCode (array_length = false, array_null_terminated = true)] static string[] defines; + [CCode (array_length = false, array_null_terminated = true)] + static string[] includedirs; private const OptionEntry[] options = { { "version", 0, 0, OptionArg.NONE, ref version, N_("Display version number"), null }, { "verbose", 'v', 0, OptionArg.NONE, ref verbose, N_("Verbose output"), null }, { "output", 'o', 0, OptionArg.FILENAME, ref output, N_("Output file"), null }, { "define", 'D', 0, OptionArg.STRING_ARRAY, ref defines, N_("Define variable"), null }, + { "includedir", 'I', 0, OptionArg.STRING_ARRAY, ref includedirs, N_("Include directory"), null }, { "only-preproc", 'E', 0, OptionArg.NONE, ref preproc, N_("Stop after the preprocessing stage"), null }, { "", 0, 0, OptionArg.FILENAME_ARRAY, ref files, null, N_("INPUT_FILE...") }, { null } @@ -57,7 +60,7 @@ namespace Wixl { } try { - var builder = new WixBuilder (); + var builder = new WixBuilder (includedirs); foreach (var d in defines) { var def = d.split ("=", 2); |