summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorFlorian Brosch <flo.brosch@gmail.com>2014-09-02 21:17:46 +0200
committerLuca Bruno <luca.bruno@immobiliare.it>2014-09-23 11:42:03 +0200
commit4fb521efd3ea9b38aba5ae599d55083d1c2f9a93 (patch)
tree8e6098e8985549b9491f9b01db1e4e5b5570888d /compiler
parented48a4c737aa15f969c0a21f38acf69c85de971e (diff)
downloadvala-4fb521efd3ea9b38aba5ae599d55083d1c2f9a93.tar.gz
Add colored output
Use --no-color to disable colors Use VALA_COLORS to change colors E.g. VALA_COLORS = "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01" Fixes bug 734627.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/valacompiler.vala21
1 files changed, 18 insertions, 3 deletions
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index cbb661c72..3f881244d 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -24,6 +24,8 @@
using GLib;
class Vala.Compiler {
+ private const string DEFAULT_COLORS = "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01";
+
static string basedir;
static string directory;
static bool version;
@@ -84,6 +86,7 @@ class Vala.Compiler {
static bool enable_version_header;
static bool disable_version_header;
static bool fatal_warnings;
+ static bool disable_diagnostic_colors;
static string dependencies;
static string entry_point;
@@ -140,6 +143,7 @@ class Vala.Compiler {
{ "profile", 0, 0, OptionArg.STRING, ref profile, "Use the given profile instead of the default", "PROFILE" },
{ "quiet", 'q', 0, OptionArg.NONE, ref quiet_mode, "Do not print messages to the console", null },
{ "verbose", 'v', 0, OptionArg.NONE, ref verbose_mode, "Print additional messages to the console", null },
+ { "no-color", 0, 0, OptionArg.NONE, ref disable_diagnostic_colors, "Disable colored output", null },
{ "target-glib", 0, 0, OptionArg.STRING, ref target_glib, "Target version of glib for code generation", "MAJOR.MINOR" },
{ "gresources", 0, 0, OptionArg.STRING_ARRAY, ref gresources, "XML of gresources", "FILE..." },
{ "enable-version-header", 0, 0, OptionArg.NONE, ref enable_version_header, "Write vala build version in generated files", null },
@@ -147,7 +151,7 @@ class Vala.Compiler {
{ "", 0, 0, OptionArg.FILENAME_ARRAY, ref sources, null, "FILE..." },
{ null }
};
-
+
private int quit () {
if (context.report.get_errors () == 0 && context.report.get_warnings () == 0) {
return 0;
@@ -169,6 +173,17 @@ class Vala.Compiler {
context = new CodeContext ();
CodeContext.push (context);
+ if (disable_diagnostic_colors == false) {
+ string[] env_args = Environ.get ();
+ unowned string env_colors = Environ.get_variable (env_args, "VALA_COLORS");
+ if (env_colors != null) {
+ context.report.set_colors (env_colors);
+ } else {
+ context.report.set_colors (DEFAULT_COLORS);
+ }
+ }
+
+
// default to build executable
if (!ccode_only && !compile_only && output == null) {
// strip extension if there is one
@@ -292,7 +307,7 @@ class Vala.Compiler {
}
context.gresources = gresources;
-
+
if (context.report.get_errors () > 0 || (fatal_warnings && context.report.get_warnings () > 0)) {
return quit ();
}
@@ -319,7 +334,7 @@ class Vala.Compiler {
if (context.report.get_errors () > 0 || (fatal_warnings && context.report.get_warnings () > 0)) {
return quit ();
}
-
+
var parser = new Parser ();
parser.parse (context);