diff options
-rw-r--r-- | tests/data/wixl/IncludeTest.wxs | 4 | ||||
-rw-r--r-- | tests/wixl.at | 2 | ||||
-rw-r--r-- | tools/wixl/preprocessor.vala | 17 |
3 files changed, 19 insertions, 4 deletions
diff --git a/tests/data/wixl/IncludeTest.wxs b/tests/data/wixl/IncludeTest.wxs index a5ea0c7..ea1832a 100644 --- a/tests/data/wixl/IncludeTest.wxs +++ b/tests/data/wixl/IncludeTest.wxs @@ -2,6 +2,10 @@ <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'> <?ifdef var.Foo?> <?warning Foo?> + <?undef Foo?> + <?ifdef var.Foo?> + <?error Foo?> + <?endif?> <?else?> <?ifdef var.Bar?> <?warning Bar?> diff --git a/tests/wixl.at b/tests/wixl.at index 4e3eb9a..f9babd9 100644 --- a/tests/wixl.at +++ b/tests/wixl.at @@ -93,7 +93,7 @@ AT_CHECK_WIXL([-o out.msi IncludeTest.wxs], [0], [ignore], [IncludeWarn.wxi:3: warning: IncludeWarn is included ]) AT_CHECK_WIXL([-D Bar -o out.msi IncludeTest.wxs], [0], [ignore], -[IncludeTest.wxs:7: warning: Bar +[IncludeTest.wxs:11: warning: Bar ]) AT_CHECK_WIXL([-D Foo -o out.msi IncludeTest.wxs], [0], [ignore], [IncludeTest.wxs:4: warning: Foo diff --git a/tools/wixl/preprocessor.vala b/tools/wixl/preprocessor.vala index d00e705..fe75244 100644 --- a/tools/wixl/preprocessor.vala +++ b/tools/wixl/preprocessor.vala @@ -3,14 +3,17 @@ 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, List<File> includedirs) { - this.globals = globals; + string name, value; + var it = HashTableIter <string, string> (globals); + while (it.next (out name, out value)) + define_variable (name, value); + this.includedirs = includedirs; } @@ -18,8 +21,12 @@ namespace Wixl { variables.insert (name, value); } + public void undefine_variable (string name) { + variables.remove (name); + } + public string? lookup_variable (string name) { - return variables.lookup (name) ?? globals.lookup (name); + return variables.lookup (name); } public string eval_variable (string str, File? file, bool needed = true) throws GLib.Error { @@ -188,6 +195,10 @@ namespace Wixl { } else throw new Wixl.Error.FAILED ("invalid define"); break; + case "undef": + var value = reader.const_value ().strip (); + undefine_variable (value); + break; case "include": var value = eval (reader.const_value (), file).strip (); var success = false; |