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.

The mentioned pr only takes care about the preGenerateCommands but not preBuildCommands.

Kind regards
Andre

Reply via email to