RejectedSoftware Forums

Sign up

preBuildCommands of dub package file

I use preBuildCommands to run simple d program that using results of git commands generates gitinfo.d file with current git commit hash and datetime to include in binary. All works fine but only the second time. The first time preBuildCommands executes and gitinfo.d file is generated as expected and project compiles but linking fails - and only the first time. I suspect it's due to internal structure of dub, but don't know it yet. How can I solve this annoying issue?

Re: preBuildCommands of dub package file

Am 22.10.2013 16:16, schrieb Alexandr Druzninin:

I use preBuildCommands to run simple d program that using results of git commands generates gitinfo.d file with current git commit hash and datetime to include in binary. All works fine but only the second time. The first time preBuildCommands executes and gitinfo.d file is generated as expected and project compiles but linking fails - and only the first time. I suspect it's due to internal structure of dub, but don't know it yet. How can I solve this annoying issue?

The problem here is that the source file list has already been assembled
before the "generate" and "build" phases.It should be possible to work
around that by using the "sourceFiles" field (e.g. "sourceFiles": <br>["source/gitinfo.d"]).

And it's not possible right now, but I think it would be useful to shift
the collection of files to the "generate" phase, so that the
"preGenerateCommands" field could be used instead. I've created issue
#144
for this.

Re: preBuildCommands of dub package file

On Thu, 24 Oct 2013 08:24:46 +0200, Sönke Ludwig wrote:

Am 22.10.2013 16:16, schrieb Alexandr Druzninin:

I use preBuildCommands to run simple d program that using results of git commands generates gitinfo.d file with current git commit hash and datetime to include in binary. All works fine but only the second time. The first time preBuildCommands executes and gitinfo.d file is generated as expected and project compiles but linking fails - and only the first time. I suspect it's due to internal structure of dub, but don't know it yet. How can I solve this annoying issue?

The problem here is that the source file list has already been assembled
before the "generate" and "build" phases.It should be possible to work
around that by using the "sourceFiles" field (e.g. "sourceFiles": <br>["source/gitinfo.d"]).

And it's not possible right now, but I think it would be useful to shift
the collection of files to the "generate" phase, so that the
"preGenerateCommands" field could be used instead. I've created issue
#144
for this.

I see. But I guess preGenerateCommands run only one time, not every building?

Re: preBuildCommands of dub package file

Am 28.10.2013 15:48, schrieb Alexandr Druzninin:

On Thu, 24 Oct 2013 08:24:46 +0200, Sönke Ludwig wrote:

Am 22.10.2013 16:16, schrieb Alexandr Druzninin:

I use preBuildCommands to run simple d program that using results of git commands generates gitinfo.d file with current git commit hash and datetime to include in binary. All works fine but only the second time. The first time preBuildCommands executes and gitinfo.d file is generated as expected and project compiles but linking fails - and only the first time. I suspect it's due to internal structure of dub, but don't know it yet. How can I solve this annoying issue?

The problem here is that the source file list has already been assembled
before the "generate" and "build" phases.It should be possible to work
around that by using the "sourceFiles" field (e.g. "sourceFiles":<br>["source/gitinfo.d"]).

And it's not possible right now, but I think it would be useful to shift
the collection of files to the "generate" phase, so that the
"preGenerateCommands" field could be used instead. I've created issue
#144
for this.
I see. But I guess preGenerateCommands run only one time, not every building?

Yes, the command would have to be in both, preGenerateCommands and
preBuildCommands, if it needs to be run for every build. But maybe for
this particular case the "sourceFiles" solution is actually the most
clean way.

Re: preBuildCommands of dub package file

On Mon, 28 Oct 2013 17:28:57 +0100, Sönke Ludwig wrote:

Yes, the command would have to be in both, preGenerateCommands and
preBuildCommands, if it needs to be run for every build. But maybe for
this particular case the "sourceFiles" solution is actually the most
clean way.

Yes, "sourceFiles" works very well. Thanks for your good job!