mirror of
https://github.com/dlang/tools.git
synced 2025-04-25 12:40:21 +03:00
Add support for environment variable RDMD_DMD into rdmd
This commit is contained in:
parent
c46aebfec0
commit
2d0c822203
3 changed files with 29 additions and 8 deletions
3
changelog/rdmd-environment-args.dd
Normal file
3
changelog/rdmd-environment-args.dd
Normal file
|
@ -0,0 +1,3 @@
|
|||
rdmd now supports specifying the D compiler using the `RDMD_DMD` environment variable
|
||||
|
||||
rdmd now uses the `RDMD_DMD` environment variable, if it is present in the environment, to choose the D compiler to use. As with the `--compiler` option, the variable's value must specify the name or path of a compiler with a DMD-like command line syntax, such as `gdmd` or `ldmd2`. The variable overrides the default (which is decided at the time `rdmd` was built), but can still be overridden by the `--compiler` option.
|
|
@ -89,6 +89,12 @@ of the options.
|
|||
Specify directory to store cached program and other
|
||||
temporaries [default = as per \fIhttp://dlang.org/phobos/std_file.html#.tempDir\fR]
|
||||
|
||||
.SH ENVIRONMENT
|
||||
.TP
|
||||
.B RDMD_DMD
|
||||
Specifies the D compiler to use, in the same way as \fB--compiler\fR, when \fB--compiler\fR is not specified.
|
||||
.PP
|
||||
|
||||
.SH NOTES
|
||||
.B dmd
|
||||
or
|
||||
|
|
28
rdmd.d
28
rdmd.d
|
@ -64,18 +64,11 @@ else version (LDC)
|
|||
private enum defaultCompiler = "ldmd2";
|
||||
else
|
||||
static assert(false, "Unknown compiler");
|
||||
|
||||
private string compiler = defaultCompiler;
|
||||
private string compiler = null;
|
||||
|
||||
version(unittest) {} else
|
||||
int main(string[] args)
|
||||
{
|
||||
// Look for the D compiler rdmd invokes automatically in the same directory as rdmd
|
||||
// and fall back to using the one in your path otherwise.
|
||||
string compilerPath = buildPath(dirName(thisExePath()), defaultCompiler ~ binExt);
|
||||
if (Filesystem.existsAsFile(compilerPath))
|
||||
compiler = compilerPath;
|
||||
|
||||
if (args.length > 1 && args[1].startsWith("--shebang ", "--shebang="))
|
||||
{
|
||||
// multiple options wrapped in one
|
||||
|
@ -142,6 +135,7 @@ int main(string[] args)
|
|||
string[] eval; // set by --eval
|
||||
bool makeDepend;
|
||||
string makeDepFile;
|
||||
|
||||
try
|
||||
{
|
||||
getopt(argsBeforeProgram,
|
||||
|
@ -173,6 +167,24 @@ int main(string[] args)
|
|||
if (bailout) return 0;
|
||||
if (dryRun) chatty = true; // dry-run implies chatty
|
||||
|
||||
// If we don't have a known compiler specified by the user,
|
||||
// then we need to look to see if it was specified via an environmental argument.
|
||||
// We need to do this due to rdmd being used as the execution engine for shebang files.
|
||||
// This was originally tested with both $DMD, and $DC variable support.
|
||||
// It was removed due to the current test suites being fragile enough that it broke them.
|
||||
if (!compiler)
|
||||
compiler = environment.get("RDMD_DMD", null);
|
||||
if (!compiler)
|
||||
{
|
||||
compiler = defaultCompiler;
|
||||
|
||||
// Look for the D compiler rdmd invokes automatically in the same directory as rdmd
|
||||
// and fall back to using the one in your path otherwise.
|
||||
string compilerPath = buildPath(dirName(thisExePath()), compiler ~ binExt);
|
||||
if (Filesystem.existsAsFile(compilerPath))
|
||||
compiler = compilerPath;
|
||||
}
|
||||
|
||||
/* Only -of is supported because Make is very susceptible to file names, and
|
||||
* it doesn't do a good job resolving them. One option would be to use
|
||||
* std.path.buildNormalizedPath(), but some corner cases will break, so it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue