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.d
will generate theid.d
file which is then imported by other modules. The Dub file for DMD is located in the root directory of the project.idgen.d
will read theddmd/id.h
file, meaning that the expected working directory issrc
.I have a test project located in
test/dub_package
with the following simple Dub file:name "dmd-dub-test" dependency "dmd" path="../../"
When I run
dub test
inside thetest/dub_package
directory Dub will need to compile the dependency, DMD. But when it compiles the dependency it fails because thesrc
directory doesn't exist. The reason for that is because the working directory is stilltest/dub_package
instead of../../
, the DMD root project directory, which is what I expected. I confirmed this by invokingpwd
inpreGenerateCommands
in 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 [1].
[1]
https://github.com/dlang/dmd/pull/6771/files#diff-406ece895a5b70a272cd76a2ef902836R41
/Jacob Carlborg