Is it legal to have physical package structure not corresponding to logical one? How to generate .di from that?

Max Samukha maxsamukha at gmail.com
Mon Sep 16 07:02:04 UTC 2019


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?




More information about the Digitalmars-d-learn mailing list