mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 02:45:25 +03:00
Add -enable-color/-disable-color switches
This commit is contained in:
parent
a7e7304d0e
commit
a81c6c6f48
3 changed files with 37 additions and 1 deletions
|
@ -406,6 +406,9 @@ cl::opt<bool, true> vgc("vgc",
|
||||||
cl::desc("list all gc allocations including hidden ones"),
|
cl::desc("list all gc allocations including hidden ones"),
|
||||||
cl::location(global.params.vgc));
|
cl::location(global.params.vgc));
|
||||||
|
|
||||||
|
cl::opt<bool, true, FlagParser> color("color",
|
||||||
|
cl::desc("Force colored console output"),
|
||||||
|
cl::location(global.params.color));
|
||||||
|
|
||||||
static cl::extrahelp footer("\n"
|
static cl::extrahelp footer("\n"
|
||||||
"-d-debug can also be specified without options, in which case it enables all\n"
|
"-d-debug can also be specified without options, in which case it enables all\n"
|
||||||
|
|
|
@ -233,7 +233,8 @@ Usage:\n\
|
||||||
\n\
|
\n\
|
||||||
files.d D source files\n\
|
files.d D source files\n\
|
||||||
@cmdfile read arguments from cmdfile\n\
|
@cmdfile read arguments from cmdfile\n\
|
||||||
-c do not link\n"
|
-c do not link\n\
|
||||||
|
-color[=on|off] force colored console output on or off\n"
|
||||||
#if 0
|
#if 0
|
||||||
" -cov do code coverage analysis\n"
|
" -cov do code coverage analysis\n"
|
||||||
#endif
|
#endif
|
||||||
|
@ -380,6 +381,16 @@ void appendEnvVar(const char* envVarName, std::vector<char*>& args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Color
|
||||||
|
{
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
automatic,
|
||||||
|
on,
|
||||||
|
off
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
struct Debug
|
struct Debug
|
||||||
{
|
{
|
||||||
enum Type
|
enum Type
|
||||||
|
@ -460,6 +471,7 @@ struct Params
|
||||||
char* defaultLibName;
|
char* defaultLibName;
|
||||||
char* debugLibName;
|
char* debugLibName;
|
||||||
char* moduleDepsFile;
|
char* moduleDepsFile;
|
||||||
|
Color::Type color;
|
||||||
|
|
||||||
bool hiddenDebugB;
|
bool hiddenDebugB;
|
||||||
bool hiddenDebugC;
|
bool hiddenDebugC;
|
||||||
|
@ -519,6 +531,7 @@ struct Params
|
||||||
defaultLibName(0),
|
defaultLibName(0),
|
||||||
debugLibName(0),
|
debugLibName(0),
|
||||||
moduleDepsFile(0),
|
moduleDepsFile(0),
|
||||||
|
color(Color::automatic),
|
||||||
hiddenDebugB(false),
|
hiddenDebugB(false),
|
||||||
hiddenDebugC(false),
|
hiddenDebugC(false),
|
||||||
hiddenDebugF(false),
|
hiddenDebugF(false),
|
||||||
|
@ -557,6 +570,22 @@ Params parseArgs(size_t originalArgc, char** originalArgv, const std::string &ld
|
||||||
result.allowDeprecated = true;
|
result.allowDeprecated = true;
|
||||||
else if (strcmp(p + 1, "c") == 0)
|
else if (strcmp(p + 1, "c") == 0)
|
||||||
result.compileOnly = true;
|
result.compileOnly = true;
|
||||||
|
else if (strncmp(p + 1, "color", 5) == 0)
|
||||||
|
{
|
||||||
|
result.color = Color::on;
|
||||||
|
// Parse:
|
||||||
|
// -color
|
||||||
|
// -color=on|off
|
||||||
|
if (p[6] == '=')
|
||||||
|
{
|
||||||
|
if (strcmp(p + 7, "off") == 0)
|
||||||
|
result.color = Color::off;
|
||||||
|
else if (strcmp(p + 7, "on") != 0)
|
||||||
|
goto Lerror;
|
||||||
|
}
|
||||||
|
else if (p[6])
|
||||||
|
goto Lerror;
|
||||||
|
}
|
||||||
else if (strcmp(p + 1, "cov") == 0)
|
else if (strcmp(p + 1, "cov") == 0)
|
||||||
result.coverage = true;
|
result.coverage = true;
|
||||||
else if (strcmp(p + 1, "shared") == 0
|
else if (strcmp(p + 1, "shared") == 0
|
||||||
|
@ -933,6 +962,8 @@ void buildCommandLine(std::vector<const char*>& r, const Params& p)
|
||||||
if (p.defaultLibName) r.push_back(concat("-defaultlib=", p.defaultLibName));
|
if (p.defaultLibName) r.push_back(concat("-defaultlib=", p.defaultLibName));
|
||||||
if (p.debugLibName) r.push_back(concat("-debuglib=", p.debugLibName));
|
if (p.debugLibName) r.push_back(concat("-debuglib=", p.debugLibName));
|
||||||
if (p.moduleDepsFile) r.push_back(concat("-deps=", p.moduleDepsFile));
|
if (p.moduleDepsFile) r.push_back(concat("-deps=", p.moduleDepsFile));
|
||||||
|
if (p.color == Color::on) r.push_back("-enable-color");
|
||||||
|
if (p.color == Color::off) r.push_back("-disable-color");
|
||||||
if (p.hiddenDebugB) r.push_back("-hidden-debug-b");
|
if (p.hiddenDebugB) r.push_back("-hidden-debug-b");
|
||||||
if (p.hiddenDebugC) r.push_back("-hidden-debug-c");
|
if (p.hiddenDebugC) r.push_back("-hidden-debug-c");
|
||||||
if (p.hiddenDebugF) r.push_back("-hidden-debug-f");
|
if (p.hiddenDebugF) r.push_back("-hidden-debug-f");
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
#include "color.h"
|
||||||
#include "doc.h"
|
#include "doc.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "hdrgen.h"
|
#include "hdrgen.h"
|
||||||
|
@ -267,6 +268,7 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool &
|
||||||
// Set some default values.
|
// Set some default values.
|
||||||
global.params.useSwitchError = 1;
|
global.params.useSwitchError = 1;
|
||||||
global.params.useArrayBounds = 2;
|
global.params.useArrayBounds = 2;
|
||||||
|
global.params.color = isConsoleColorSupported();
|
||||||
|
|
||||||
global.params.linkswitches = new Strings();
|
global.params.linkswitches = new Strings();
|
||||||
global.params.libfiles = new Strings();
|
global.params.libfiles = new Strings();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue