Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Jan 3, 2016
2 parents b45a695 + 5b21861 commit da0a2e0
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 64 deletions.
54 changes: 27 additions & 27 deletions catdoc.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,51 @@ int main(string[] args)
{
if (args.length < 2)
{
writeln("catdoc: Concatenate Ddoc files
writeln("catdoc: Concatenate Ddoc files
Usage:
catdoc -o=outputfile sourcefiles...
");
return 1;
return 1;
}

string ofile;
getopt(args, "o", &ofile);
if (!ofile.ptr)
{
writeln("catdoc: set output file with -o=filename");
return 1;
writeln("catdoc: set output file with -o=filename");
return 1;
}
if (args.length < 2)
{
writeln("catdoc: no input files");
return 1;
writeln("catdoc: no input files");
return 1;
}

string comment = "Ddoc\n";
string macros;
foreach (arg; args[1..$])
{
//writeln(arg);
string input = cast(string)std.file.read(arg);
if (input.length < 4 || input[0..4] != "Ddoc")
{ writefln("catdoc: %s is not a Ddoc file", arg);
return 1;
}
foreach (i, c; input)
{
if (c == '\n')
{
if (i + 8 < input.length && std.string.icmp(input[i + 1 .. i + 8], "Macros:") == 0)
{
comment ~= input[4 .. i + 1];
if (!macros.ptr)
macros = "Macros:\n";
macros ~= input[i + 8 .. $];
goto L1;
}
}
}
comment ~= input[4 .. $];
//writeln(arg);
string input = cast(string)std.file.read(arg);
if (input.length < 4 || input[0..4] != "Ddoc")
{ writefln("catdoc: %s is not a Ddoc file", arg);
return 1;
}
foreach (i, c; input)
{
if (c == '\n')
{
if (i + 8 < input.length && std.string.icmp(input[i + 1 .. i + 8], "Macros:") == 0)
{
comment ~= input[4 .. i + 1];
if (!macros.ptr)
macros = "Macros:\n";
macros ~= input[i + 8 .. $];
goto L1;
}
}
}
comment ~= input[4 .. $];
L1: ;
}

Expand Down
32 changes: 16 additions & 16 deletions get_dlibcurl32.d
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,27 @@ int main(string[] args)
showHelp();
return 1;
}

if(args[1] == "--help")
{
showHelp();
return 0;
}

// Setup paths
auto curlVersion = args[1];
curlUrl = curlUrl .replace("$(CURL_VERSION)", curlVersion);
curlZipBase = curlZipBase.replace("$(CURL_VERSION)", curlVersion);
outputDir ~= "-" ~ curlVersion;
workDir = buildPath(tempDir(), workDirName);

checkImplib();

// Clear temporary work dir
writeln("Clearing temporary work dir: ", workDir);
removeDir(workDir);
makeDir(workDir);

// Archive paths
auto unzipArchivePath = buildPath(workDir, "unzip", unzipArchiveName);
auto basicUtilsArchivePath = buildPath(workDir, "bup", basicUtilsArchiveName);
Expand All @@ -122,7 +122,7 @@ int main(string[] args)
if(!hasImplib)
download(basicUtilsUrl, basicUtilsArchivePath);
download(curlUrl, curlArchivePath);

// Extract
{
auto saveDir = getcwd();
Expand All @@ -140,20 +140,20 @@ int main(string[] args)
chdir(workDir);
unzip(curlArchivePath);
}

// Generate import lib
auto curlDir = buildPath(workDir, curlZipBase);
implib(buildPath(curlDir, "libcurl"));

// Copy results out of temp dir
writeln("Copying results to '", outputDir, "'");
removeDir(outputDir);
copyDir(curlDir, outputDir);
writeln("Done.");
writeln("Your OPTLINK-compatable libcurl.lib, along with the rest of libcurl,");
writeln("is in the directory: ", outputDir);

writeln("Done.");
writeln("Your OPTLINK-compatable libcurl.lib, along with the rest of libcurl,");
writeln("is in the directory: ", outputDir);

return 0;
}

Expand All @@ -169,7 +169,7 @@ void copyDir(string src, string dest)
// Needed to generate 'relativePath' correctly.
if(!src.endsWith(dirSeparator))
src ~= dirSeparator;

makeDir(dest);
foreach(DirEntry entry; dirEntries(src, SpanMode.breadth))
{
Expand All @@ -191,11 +191,11 @@ void removeDir(string path)
{
if(exists(path))
{
auto failMsg =
auto failMsg =
"Failed to remove directory: "~path~"\n"~
" A process may still holding an open handle within the directory.\n"~
" Either delete the directory manually or try again later.";

try
system("rmdir /S /Q "~quote(path));
catch(Exception e)
Expand Down
32 changes: 14 additions & 18 deletions man/man1/rdmd.1
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,13 @@ if specified, but uses
by default.

.SH OPTIONS
.IP --help
Print help

.IP --force
Force re-compilation of source code [default = do not
force]

.IP --compiler=(dmd|gdmd)
Specify compiler [default = \fBdmd\fR]

.IP --tmpdir=\fItmp_dir_path\fR
Specify directory to store cached program and other
temporaries [default = \fI/tmp\fR]

.IP --build-only
Just build the executable, don't run it

.IP --chatty
Write compiler commands to stdout before executing them

.IP --compiler=\fIcomp\fR
.IP --compiler=(dmd|gdmd|ldmd2)
Use the specified compiler (e.g. gdmd) instead of dmd

.IP --dry-run
Expand All @@ -67,6 +53,13 @@ file rather than the
file) when compiling the program (multiple --extra-file
allowed).

.IP --force
Force re-compilation of source code [default = do not
force]

.IP --help
Print help

.IP --loop
Assume \fI"foreach (line; stdin.byLine()) { ... }"\fR for eval

Expand All @@ -82,8 +75,9 @@ Print dependencies in makefile format to file and continue
.IP --man
Open web browser on manual page

.IP --shebang
\fBrdmd\fR is in a shebang line (put as first argument)
.IP --tmpdir=\fItmp_dir_path\fR
Specify directory to store cached program and other
temporaries [default = as per \fIhttp://dlang.org/phobos/std_file.html#.tempDir\fR]

.SH NOTES
.B dmd
Expand All @@ -105,7 +99,9 @@ extension
dmd itself

.SH AUTHOR
Written by Dave Fladebo and Robert Mariottini
Written by Andrei Alexandrescu

Originally written by Dave Fladebo and Robert Mariottini

.SH "SEE ALSO"
.BR dmd (1)
Expand Down
7 changes: 5 additions & 2 deletions rdmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ else
}

private bool chatty, buildOnly, dryRun, force, preserveOutputPaths;
private string exe;
private string exe, userTempDir;
private string[] exclusions = ["std", "etc", "core"]; // packages that are to be excluded
private string[] extraFiles = [];

Expand Down Expand Up @@ -137,6 +137,7 @@ int main(string[] args)
"makedepend", &makeDepend,
"makedepfile", &makeDepFile,
"man", { man(); bailout = true; },
"tmpdir", &userTempDir,
"o", &dashOh);
if (bailout) return 0;
if (dryRun) chatty = true; // dry-run implies chatty
Expand Down Expand Up @@ -173,13 +174,15 @@ int main(string[] args)
~ "foreach (line; std.stdio.stdin.byLine()) {\n"
~ std.string.join(loop, "\n")
~ ";\n} }");
argsBeforeProgram ~= "-d";
}
else if (eval.ptr)
{
enforce(programPos == args.length, "Cannot have both --eval and a " ~
"program file ('" ~ args[programPos] ~ "').");
root = makeEvalFile(importWorld ~ "void main(char[][] args) {\n"
~ std.string.join(eval, "\n") ~ ";\n}");
argsBeforeProgram ~= "-d";
}
else if (programPos < args.length)
{
Expand Down Expand Up @@ -366,7 +369,7 @@ bool inALibrary(string source, string object)

private @property string myOwnTmpDir()
{
auto tmpRoot = tempDir();
auto tmpRoot = userTempDir ? userTempDir : tempDir();
version (Posix)
{
import core.sys.posix.unistd;
Expand Down
21 changes: 20 additions & 1 deletion rdmd_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void runTests()
assert(res.status == 0, res.output); // --build-only should not interfere with --dry-run

/* Test --eval. */
res = execute([rdmdApp, compilerSwitch, "--force", "--eval=writeln(`eval_works`);"]);
res = execute([rdmdApp, compilerSwitch, "--force", "-de", "--eval=writeln(`eval_works`);"]);
assert(res.status == 0, res.output);
assert(res.output.canFind("eval_works")); // there could be a "DMD v2.xxx header in the output"

Expand Down Expand Up @@ -337,6 +337,25 @@ void runTests()
res = execute([rdmdApp, "--compiler=" ~ fullCompilerPath, forceSrc]);
assert(res.status == 0, res.output ~ "\nCan't run with --compiler=" ~ fullCompilerPath);
assert(res.output.canFind("compile_force_src"));

/* tmpdir */

res = execute([rdmdApp, compilerSwitch, forceSrc, "--build-only"]);
assert(res.status == 0, res.output);

auto tmpdir = "rdmdTest";
if (exists(tmpdir)) rmdirRecurse(tmpdir);
mkdir(tmpdir);
scope(exit)
{
import core.thread;
Thread.sleep(100.msecs); // Hack around Windows locking the directory
rmdirRecurse(tmpdir);
}

res = execute([rdmdApp, compilerSwitch, "--tmpdir=" ~ tmpdir, forceSrc, "--build-only"]);
assert(res.status == 0, res.output);
assert(res.output.canFind("compile_force_src"));
}

void runConcurrencyTest()
Expand Down

0 comments on commit da0a2e0

Please sign in to comment.