Skip to content

Commit 3bf4958

Browse files
committed
Add ddoc for -i
1 parent 11fc856 commit 3bf4958

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

changelog/includeimports.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ $(CONSOLE dmd -i=foo -i=-foo.bar)
66

77
The option -i by itself is equivalent to:
88

9-
$(CONSOLE dmd -i=-std,-core,-etc,-object)
9+
$(CONSOLE dmd -i=-std -i=-core -i=-etc -i=-object)

src/dmd/cli.d

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,32 @@ dmd -cov -unittest myprog.d
310310
Option("I=<directory>",
311311
"look for imports also in directory"
312312
),
313-
Option("i",
314-
"include imported modules except from druntime/phobos (equivalent to -i=-std -i=-core -i=-etc -i=-object)"
315-
),
316-
Option("i=[-]<pattern>",
317-
"include (or exclude if prefixed with '-') imported modules whose names match <pattern>"
313+
Option("i[=<pattern>]",
314+
"include imported modules in the compilation",
315+
q"{$(P Enables "include imports" mode, where the compiler will include imported
316+
modules in the compilation, as if they were given on the command line. By default, when
317+
this option is enabled, all imported modules are included except those in
318+
druntime/phobos. This behavior can be overriden by providing patterns via `-i=<pattern>`.
319+
A pattern of the form `-i=<package>` is an "inclusive pattern", whereas a pattern
320+
of the form `-i=-<package>` is an "exclusive pattern". Inclusive patterns will include
321+
all module's whose names match the pattern, whereas exclusive patterns will exclude them.
322+
For example. all modules in the package `foo.bar` can be included using `-i=foo.bar` or excluded
323+
using `-i=-foo.bar`. Note that each component of the fully qualified name must match the
324+
pattern completely, so the pattern `foo.bar` would not match a module named `foo.barx`.)
325+
326+
$(P The default behavior of excluding druntime/phobos is accomplished by internally adding a
327+
set of standard exclusions, namely, `-i=-std -i=-core -i=-etc -i=-object`. Note that these
328+
can be overriden with `-i=std -i=core -i=etc -i=object`.)
329+
330+
$(P When a module matches multiple patterns, matches are prioritized by their component length, where
331+
a match with more components takes priority (i.e. pattern `foo.bar.baz` has priority over `foo.bar`).)
332+
333+
$(P By default modules that don't match any pattern will be included. However, if at
334+
least one inclusive pattern is given, then modules not matching any pattern will
335+
be excluded. This behavior can be overriden by usig `-i=.` to include by default or `-i=-.` to
336+
exclude by default.)
337+
338+
$(P Note that multiple `-i=...` options are allowed, each one adds a pattern.)}"
318339
),
319340
Option("ignore",
320341
"ignore unsupported pragmas"

0 commit comments

Comments
 (0)