On 2017-05-11 11:18, Jacob Carlborg wrote:
I'm trying to add a Dub file to DMD. I would like to have a test for this as well. So I've created a minimal Dub project that is using the DMD Dub package as a dependency. This is causing some problems when Dub is building DMD.
In the Dub file for DMD I have a pre generate command looking like this:
preGenerateCommands "pushd src > /dev/null && ./ddmd/idgen.d && popd > /dev/null"
idgen.dwill generate the
id.dfile which is then imported by other modules. The Dub file for DMD is located in the root directory of the project.
idgen.dwill read the
ddmd/id.hfile, meaning that the expected working directory is
I have a test project located in
test/dub_packagewith the following simple Dub file:
name "dmd-dub-test" dependency "dmd" path="../../"
When I run
dub testinside the
test/dub_packagedirectory Dub will need to compile the dependency, DMD. But when it compiles the dependency it fails because the
srcdirectory doesn't exist. The reason for that is because the working directory is still
../../, the DMD root project directory, which is what I expected. I confirmed this by invoking
preGenerateCommandsin the DMD Dub file. Is this a bug or expected behavior? If it is expected behavior, is there a solution/workaround?
My changes to DMD are available here: https://github.com/jacob-carlborg/dmd/commit/d285db95da7a368d75be3ae18bce13aa13d2fa27
I solved this in a different way by modifying the idgen.d to take a path
as a command line argument. Then use $PACKAGE_DIR as the argument .