On Monday, 29 February 2016 at 19:03:53 UTC, Sebastien Alaiwan
wrote:
Hi all,
I've came across the following problem number of times.
Let's say I have project A and B, sharing code but having a
different tree structure.
$ find projectA
./projectA/internal/math/algo.d
./projectA/internal/math/lcp.d
./projectA/internal/math/optimize.d
./projectA/gui/main.d
$ find projectB
./projectB/app/render/gfx.d
./projectB/app/render/algo.d
./projectB/app/physics/math/algo.d
./projectB/app/physics/math/lcp.d
./projectB/app/physics/math/optimize.d
./projectB/main.d
The directory "math" is shared between projects. It actually is
an external/submodule. So it has a standalone existence as a
library, and might one day be used by projectC.
(In the context of this issue, I'm using separate compilation).
I'd like to be able to write, in projectA's main:
import internal.math.optimize;
This requires me to add, at the beginning of "optimize.d" file,
this module definition:
module internal.math.optimize;
However, this "optimize.d" file is shared between projects, now
it's becoming specific to projectA.
How am I supposed to share code between projects then?
Would this work?
1. pick a single module name like
module math.optimize;
2. import that module with:
import math.optimize;
3. put this module in a hierarchy like that:
math/optimize.d
4. pass -I<directory-containing-math-directory> to the compiler
However it may clutter your module namespace a bit more.