RejectedSoftware Forums

Sign up

dub and auto-generated dependencies

dub is a source package manager but it is also a build system. Are there currently any plans to allow dependencies that should be auto-generated to be specified? I'm talking about something like the custom targets of CMake.

In terms of implementation I was thinking of a D file that is compiled, executed and run by dub as part of the build process in order to satisfy a dependency. Or any script I guess.

Atila

Re: dub and auto-generated dependencies

On Sun, 02 Feb 2014 22:19:21 GMT, Atila Neves wrote:

dub is a source package manager but it is also a build system. Are there currently any plans to allow dependencies that should be auto-generated to be specified? I'm talking about something like the custom targets of CMake.

In terms of implementation I was thinking of a D file that is compiled, executed and run by dub as part of the build process in order to satisfy a dependency. Or any script I guess.

Atila

There was a big e-mail discussion about this last year. What can be done now using "preBuildCommands" is to run an external tool that is installed on the system. The generated file then just needs to be specified as a source file:

"preBuildCommands": ["yacc ..."],
"sourceFiles": ["generated/parser.d"]

What's still missing here is dependency tracking (which DUB so far only does on the package scale). A simple workaround is to use a separate make file for that and encode the dependencies there:

"preBuildCommands": ["make parser -f deps.mak"],
"sourceFiles": ["generated/parser.d"]

To use tools that are built using DUB themselves and which are not installed system wide, there was the idea to allow "executable" configurations for dependencies and make the target-paths available as variables:

"dependencies": {"dyacc": ">=1.0.0"},
"subConfigurations": {"dyacc": "application"},
"preBuildCommands": ["$dyacc ..."]

DUB would then build "dyacc" prior to the main project, so that it can be invoked as a pre-build-command.

There is also a way to achieve this now by invoking dub separately:

"preBuildCommands": [
    "dub fetch dyacc",
    "dub run dyacc -- ..."
]

But the solution for the issue of tracking dependencies (i.e. only invoking yacc when the corresponding "parser.y", or any dependency thereof has changed) is still totally unclear, especially considering that IDE project files still need to be supported somehow.

Some related topics on the forum:
How to invoke a dependency?
Development dependencies?

PS: I know my reply may not match your question exactly, it was mainly intended to give an overview of the current state. In short, "preBuildCommands" is the closest thing to a custom target right now and the rest still needs to get carefully designed. CMake may be a good role model there.

Re: dub and auto-generated dependencies

PS: I know my reply may not match your question exactly, it was mainly intended to give an overview of the current state. In short, "preBuildCommands" is the closest thing to a custom target right now and the rest still needs to get carefully designed. CMake may be a good role model there.

No, that was exactly what I wanted to know, thanks!

If it weren't being considered then I might have started thinking about implementing and sending a pull request, but getting the design right is definitely very important.

Atila