Showing with 25 additions and 2 deletions.
  1. +3 −0 man/man1/rdmd.1
  2. +5 −2 rdmd.d
  3. +17 −0 rdmd_test.d
3 changes: 3 additions & 0 deletions man/man1/rdmd.1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Evaluate code as in perl -e (multiple --eval allowed)
.IP --exclude=\fIpackage\fR
Exclude a package from the build (multiple --exclude allowed)

.IP --include=\fIpackage\fR
Negate an --exclude switch or a package excluded by default

.IP --extra-file=\fIfile\fR
Include an extra source or object in the compilation. Useful
if you need to add an extra object (compiled by another
Expand Down
7 changes: 5 additions & 2 deletions rdmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ else

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

version (DigitalMars)
Expand Down Expand Up @@ -139,6 +140,7 @@ int main(string[] args)
"eval", &eval,
"loop", &loop,
"exclude", &exclusions,
"include", (string opt, string p) { exclusions = exclusions.filter!(ex => ex != p).array(); },
"extra-file", &extraFiles,
"force", &force,
"help", { writeln(helpString); bailout = true; },
Expand Down Expand Up @@ -818,6 +820,7 @@ addition to compiler options, rdmd recognizes the following options:
(implies --chatty)
--eval=code evaluate code as in perl -e (multiple --eval allowed)
--exclude=package exclude a package from the build (multiple --exclude allowed)
--include=package negate --exclude or a standard package (%-(%s, %))
--extra-file=file include an extra source or object in the compilation
(multiple --extra-file allowed)
--force force a rebuild even if apparently not necessary
Expand All @@ -830,7 +833,7 @@ addition to compiler options, rdmd recognizes the following options:
(needs dmd's option `-of` to be present)
--man open web browser on manual page
--shebang rdmd is in a shebang line (put as first argument)
".format(defaultCompiler);
".format(defaultCompiler, defaultExclusions);
}

// For --eval
Expand Down
17 changes: 17 additions & 0 deletions rdmd_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ void runTests()
res = execute([rdmdApp, compilerSwitch, "--force", "--exclude=dsubpack", subModObj, subModUser]);
assert(res.status == 0, res.output); // building with the dependency succeeds

/* Test --include. */
auto packFolder2 = tempDir().buildPath("std");
if (packFolder2.exists) packFolder2.rmdirRecurse();
packFolder2.mkdirRecurse();
scope (exit) packFolder2.rmdirRecurse();

string subModSrc2 = packFolder2.buildPath("foo.d");
std.file.write(subModSrc2, "module std.foo; void foobar() { }");

std.file.write(subModUser, "import std.foo; void main() { foobar(); }");

res = execute([rdmdApp, compilerSwitch, "--force", subModUser]);
assert(res.status == 1, res.output); // building without the --include fails

res = execute([rdmdApp, compilerSwitch, "--force", "--include=std", subModUser]);
assert(res.status == 0, res.output); // building with the --include succeeds

/* Test --extra-file. */

string extraFileDi = tempDir().buildPath("extraFile_.di");
Expand Down