D packages, include directories, and rdmd

Nick Sabalausky a at a.a
Thu Oct 27 15:28:46 PDT 2011


"Andrew Pennebaker" <andrew.pennebaker at gmail.com> wrote in message 
news:mailman.543.1319752640.24802.digitalmars-d at puremagic.com...
> I've got a single-file D module,
> dashcheck.d<https://github.com/mcandre/dashcheck>,
> that I'd like to install as a local package. In other words, I'd like to 
> be
> able to "import dashcheck;" from any directory.
>
> I put dashcheck.d in ~/.d/, and I put export DFLAGS=-I~/.d in ~/.profile,
> but when I try to run example.d from another directory, I get:
>
> $ ./example.d
> ./example.d(3): Error: module dashcheck is in file 'dashcheck.d' which
> cannot be read
> import path[0] = /usr/local/Cellar/dmd/2.051/src/phobos
> import path[1] = /usr/local/Cellar/dmd/2.051/src/druntime/importCheers,
>
> It appears that rdmd ignores $DFLAGS.
>

I guess DFLAGS isn't an env var (which actually surprises me, it probably 
should be, is there already an enhancement request in bugzilla for that? Is 
is there some deliberate reason for this?).

DFLAGS is normally set in your dmd.conf file (sc.ini on Windows). Do a 
"which dmd" to see where your dmd binary is, and your dmd.conf will be in 
the same directory (at least if you used the .zip releases or DVM, I don't 
know where the distros will put dmd.conf).

Another approach that many of us use is to just pass the -Ipath option to 
dmd or rdmd in your buildscript to tell dmd/rdmd where to look for look for 
imports (sort of the D counterpart to Java's classpaths).

> Also, when I change the shebang in example.d to #!/usr/bin/env rdmd 
> $DFLAGS,
> I get:
>
> $ ./example.d
> sh: -I~/.d.d.deps: No such file or directory
>
> So I'm not using import directives correctly. How do I generate
> dashcheck.d.deps?
>

Part of the problem here is the same as above, DFLAGS needs to be set in 
dmd.conf, not an env var. But also, when you use rdmd as a shebang, you 
should use the --shebang option (always as the first argument), ie:

#!/usr/bin/env rdmd --shebang {whatever other options here}

Apperently, shebangs tend to mess up the params that get sent to rdmd, and 
the --shebang makes it use an alternate approach made specifically for that 
situation.





More information about the Digitalmars-d mailing list