On Tuesday, 5 November 2019 at 20:28:49 UTC, Andre Pany wrote:
On Tuesday, 5 November 2019 at 19:26:54 UTC, user5678 wrote:
On Monday, 4 November 2019 at 13:37:47 UTC, Sebastiaan Koppe
wrote:
Does anyone know a reliable way of having a dub package that
contains git submodules and is to be used as a dependency?
I am looking for a way to ensure the submodules are
initialised before a build.
You can use the "preGenerateCommands" to launch the adequate
git commands. The submodule needs to be indicated using the
"path" property :
"preGenerateCommands" : ["git submodule update --init
--recursive"],
"dependencies" : {
"theGitSubModule" : {
"path" : "./theGitSubModulePath"
},
I have done this before and while it worked I had to "dub
build" twice because the project needed to be read a second
time to discover new source files generated by the commands.
There's a PR that is supposed to fix that:
https://github.com/dlang/dub/pull/1708
But more likely at some point git submodules will be supported
natively.
I noticed 1 thing with preGenerateCommands. They are executed
"every time" even if nothing has to be rebuild. The
preBuildCommands are executed only if there is a build needed.
I didn't know that but I think this is necessary, isn't it ?
If the command creates or update a few D sources then how would
DUB knows that everything is up-to-date ? (in an ideal world,
were the double dub build would not be necessary).
For the purpose of pulling one can obviously optimize using more
complex commands in a script. In my case I used the date of the
last pull so that finally the submodule got pulled only once per
day.
The command is still executed but you save the useless web
request.
The mentioned pr only takes care about the preGenerateCommands
but not preBuildCommands.
Kind regards
Andre