summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-08 17:46:15 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-08 18:21:13 +0100
commitc6e867fbf33342a047ae4f255c1b8ad3e03c5f69 (patch)
tree81a9495a67d2b3a4f5c290b935a2d1000e374e2b /src
parent9cc9b8d81023f39900115bc38eb48c038c5d182f (diff)
Add preprocessor variables test
Diffstat (limited to 'src')
-rw-r--r--src/builder.vala7
-rw-r--r--src/preprocessor.vala1
-rw-r--r--src/wixl.vala30
3 files changed, 29 insertions, 9 deletions
diff --git a/src/builder.vala b/src/builder.vala
index 5a441dd..d2f5035 100644
--- a/src/builder.vala
+++ b/src/builder.vala
@@ -30,12 +30,17 @@ namespace Wixl {
}
}
- public void load_file (File file) throws GLib.Error {
+ public void load_file (File file, bool preproc_only = false) throws GLib.Error {
string data;
FileUtils.get_contents (file.get_path (), out data);
var p = new Preprocessor ();
var doc = p.preprocess (data, file);
+ if (preproc_only) {
+ doc.dump_format (FileStream.fdopen (1, "w"));
+ return;
+ }
+
load_doc (doc);
}
diff --git a/src/preprocessor.vala b/src/preprocessor.vala
index e5bfd1b..6953aa5 100644
--- a/src/preprocessor.vala
+++ b/src/preprocessor.vala
@@ -107,7 +107,6 @@ namespace Wixl {
}
writer.end_document ();
- doc.dump_format (FileStream.fdopen (1, "w"));
return doc;
}
}
diff --git a/src/wixl.vala b/src/wixl.vala
index 904daf7..24d0ad4 100644
--- a/src/wixl.vala
+++ b/src/wixl.vala
@@ -3,11 +3,17 @@ using Posix;
namespace Wixl {
static bool version;
+ static bool verbose;
+ static bool preproc;
+ static string output;
[CCode (array_length = false, array_null_terminated = true)]
static string[] files;
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 },
+ { "only-preproc", 'E', 0, OptionArg.NONE, ref preproc, N_("Stop after the preprocessing stage"), null },
{ "", 0, 0, OptionArg.FILENAME_ARRAY, ref files, null, N_("OUTPUT_FILE INPUT_FILE...") },
{ null }
};
@@ -37,23 +43,33 @@ namespace Wixl {
exit (0);
}
- if (files.length < 2) {
- GLib.stderr.printf (_("Please specify output and input files.\n"));
+ if (files.length < 1) {
+ GLib.stderr.printf (_("Please specify input files.\n"));
+ exit (1);
+ }
+
+ if (output == null && !preproc) {
+ GLib.stderr.printf (_("Please specify the output file.\n"));
exit (1);
}
try {
var builder = new WixBuilder ();
- foreach (var arg in files[1:files.length]) {
- print ("Loading %s...\n", arg);
+ foreach (var arg in files) {
+ if (verbose)
+ print ("Loading %s...\n", arg);
var file = File.new_for_commandline_arg (arg);
- builder.load_file (file);
+ builder.load_file (file, preproc);
builder.add_path (file.get_parent ().get_path ());
}
- print ("Building %s...\n", files[0]);
+ if (preproc)
+ return 0;
+
+ if (verbose)
+ print ("Building %s...\n", files[0]);
var msi = builder.build ();
- msi.build (files[0]);
+ msi.build (output);
} catch (GLib.Error error) {
printerr (error.message + "\n");
return 1;