summaryrefslogtreecommitdiffstats
path: root/tools/wixl
diff options
context:
space:
mode:
Diffstat (limited to 'tools/wixl')
-rw-r--r--tools/wixl/builder.vala2
-rw-r--r--tools/wixl/preprocessor.vala54
2 files changed, 38 insertions, 18 deletions
diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala
index 65f4540..11e6309 100644
--- a/tools/wixl/builder.vala
+++ b/tools/wixl/builder.vala
@@ -395,6 +395,8 @@ namespace Wixl {
}
void feature_add_component (WixFeature feature, WixComponent component) throws GLib.Error {
+ if (component.in_feature.find (feature) != null)
+ return;
component.in_feature.append (feature);
db.table_feature_components.add (feature.Id, component.Id);
}
diff --git a/tools/wixl/preprocessor.vala b/tools/wixl/preprocessor.vala
index fe75244..73fe114 100644
--- a/tools/wixl/preprocessor.vala
+++ b/tools/wixl/preprocessor.vala
@@ -85,8 +85,8 @@ namespace Wixl {
}
class Location: Object {
- File file;
- int line;
+ public File file;
+ public int line;
public Location (Xml.TextReader reader, File file) {
this.file = file;
@@ -199,23 +199,13 @@ namespace Wixl {
var value = reader.const_value ().strip ();
undefine_variable (value);
break;
+ case "require":
+ var value = eval (reader.const_value (), file).strip ();
+ include (value, loc, writer, true);
+ break;
case "include":
var value = eval (reader.const_value (), file).strip ();
- 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);
- }
+ include (value, loc, writer);
break;
case "warning":
print ("warning", loc, eval (reader.const_value (), file));
@@ -264,7 +254,7 @@ namespace Wixl {
throw new Wixl.Error.FAILED ("Missing endif");
}
- bool include (string filename, Xml.TextWriter writer) throws GLib.Error {
+ bool include_try (string filename, Xml.TextWriter writer) throws GLib.Error {
string data;
var file = File.new_for_path (filename);
@@ -279,6 +269,34 @@ namespace Wixl {
return true;
}
+ // Use it as a set
+ HashTable<string,string*> requires = new HashTable<string, string*> (str_hash, str_equal);
+ void include (string name, Location loc, Xml.TextWriter writer, bool is_req = false) throws GLib.Error {
+ var success = false;
+
+ if (is_req) {
+ if (requires.lookup_extended (name, null, null))
+ return;
+ requires.add (name);
+ }
+
+ string[] dirs = {};
+ dirs += name;
+ dirs += loc.file.get_parent ().get_child (name).get_path ();
+ foreach (var dir in includedirs)
+ dirs += dir.get_child (name).get_path ();
+
+ foreach (var inc in dirs) {
+ success = include_try (inc, writer);
+ if (success)
+ break;
+ }
+ if (!success) {
+ print ("error", loc, "Failed to include %s".printf (name));
+ Posix.exit (1);
+ }
+ }
+
public Xml.Doc preprocess (string data, File? file) throws GLib.Error {
Xml.Doc doc;
Xml.TextWriter writer = new Xml.TextWriter.doc (out doc);