Please consider a project:

src/p2/
    |---a.d
    |---b.d

in which it is desirable that the logical package tree does not fully correspond to the filesystem subtree:

src/p2/a.d:
module p1.p2.a;
...

src/p2/b.d:
module p1.p2.b;
import p1.p2.a;
...

dmd compiles the above structure successfully, even though the spec explicitly states that "The packages correspond to directory names in the source file path" (https://dlang.org/spec/module.html#module_declaration, item 2):

dmd -lib src/p2/a.d src/p2/b.d // ok

Is the spec wrong? Can the current dmd behavior be relied on?


If yes, how does one create an import tree from the structure like that?

'dmd -H -o- -Hdimport -op src/p1/a.d src/p2/b.d' is close, but it places the .di files into 'import/src/p1' directory (which is useless for automatic importing) instead of the expected 'import/p1/p2'. Is it possible to achieve that without making the build process unreasonably complex?


Reply via email to