Thread overview
How do i convert this Makefile to dub
Aug 08, 2016
Adil
Aug 08, 2016
Adil
Aug 08, 2016
drug007
Aug 08, 2016
Adil
Aug 08, 2016
drug007
August 08, 2016
I have a Makefile setup that I use to return the latest git tag/commit from within my program. The setup is as below:


````
VERSIONED_LIB = myversion.d && rm -f myversion.d
VERSION_STRING ?= $(shell git rev-parse --short HEAD)

makeVersion:
	echo "module compileConfig; public string versionString = \"$(VERSION_STRING)\";" > myversion.d;

mysoftware: makeVersion
	dmd -de -O /* compiler flags */ source/myprogrma.d myversion.d
	rm -f myversion.d
````

When i run `make mysoftware` my binary now contains the latest git commit HASH, which i use for debugging.

How can i mimic the same setup i dub? Is there an alternative to achieve the same goal?
August 08, 2016
On Monday, 8 August 2016 at 18:29:54 UTC, Adil wrote:
> I have a Makefile setup that I use to return the latest git tag/commit from within my program. The setup is as below:
>
>
> ````
> VERSIONED_LIB = myversion.d && rm -f myversion.d
> VERSION_STRING ?= $(shell git rev-parse --short HEAD)
>
> makeVersion:
> 	echo "module compileConfig; public string versionString = \"$(VERSION_STRING)\";" > myversion.d;
>
> mysoftware: makeVersion
> 	dmd -de -O /* compiler flags */ source/myprogrma.d myversion.d
> 	rm -f myversion.d
> ````
>
> When i run `make mysoftware` my binary now contains the latest git commit HASH, which i use for debugging.
>
> How can i mimic the same setup i dub? Is there an alternative to achieve the same goal?

One minor addition. I use the Makefile in our CI tool, that inserts  auto-increment numbers in place of git hashes. Numbers are a familiar. Ex:

make VERSION_STRING=v%build.number%;
make screener-d-debug VERSION_STRING=v%build.number%;

Can i insert a version number when i run dub?
August 08, 2016
On 08.08.2016 21:35, Adil wrote:
> On Monday, 8 August 2016 at 18:29:54 UTC, Adil wrote:
>> I have a Makefile setup that I use to return the latest git tag/commit
>> from within my program. The setup is as below:
>>
>>
>> ````
>> VERSIONED_LIB = myversion.d && rm -f myversion.d
>> VERSION_STRING ?= $(shell git rev-parse --short HEAD)
>>
>> makeVersion:
>>     echo "module compileConfig; public string versionString =
>> \"$(VERSION_STRING)\";" > myversion.d;
>>
>> mysoftware: makeVersion
>>     dmd -de -O /* compiler flags */ source/myprogrma.d myversion.d
>>     rm -f myversion.d
>> ````
>>
>> When i run `make mysoftware` my binary now contains the latest git
>> commit HASH, which i use for debugging.
>>
>> How can i mimic the same setup i dub? Is there an alternative to
>> achieve the same goal?
>
> One minor addition. I use the Makefile in our CI tool, that inserts
> auto-increment numbers in place of git hashes. Numbers are a familiar. Ex:
>
> make VERSION_STRING=v%build.number%;
> make screener-d-debug VERSION_STRING=v%build.number%;
>
> Can i insert a version number when i run dub?
You can do it by using `preBuildCommands` in dub.sdl, see http://code.dlang.org/package-format?lang=sdl
August 08, 2016
On Monday, 8 August 2016 at 18:45:35 UTC, drug007 wrote:
> On 08.08.2016 21:35, Adil wrote:
>> On Monday, 8 August 2016 at 18:29:54 UTC, Adil wrote:
>>> [...]
>>
>> One minor addition. I use the Makefile in our CI tool, that inserts
>> auto-increment numbers in place of git hashes. Numbers are a familiar. Ex:
>>
>> make VERSION_STRING=v%build.number%;
>> make screener-d-debug VERSION_STRING=v%build.number%;
>>
>> Can i insert a version number when i run dub?
> You can do it by using `preBuildCommands` in dub.sdl, see http://code.dlang.org/package-format?lang=sdl

How can i pass a VERSION_STRING from the cmd line?
August 08, 2016
On 08.08.2016 21:48, Adil wrote:
> On Monday, 8 August 2016 at 18:45:35 UTC, drug007 wrote:
>> On 08.08.2016 21:35, Adil wrote:
>>> On Monday, 8 August 2016 at 18:29:54 UTC, Adil wrote:
>>>> [...]
>>>
>>> One minor addition. I use the Makefile in our CI tool, that inserts
>>> auto-increment numbers in place of git hashes. Numbers are a
>>> familiar. Ex:
>>>
>>> make VERSION_STRING=v%build.number%;
>>> make screener-d-debug VERSION_STRING=v%build.number%;
>>>
>>> Can i insert a version number when i run dub?
>> You can do it by using `preBuildCommands` in dub.sdl, see
>> http://code.dlang.org/package-format?lang=sdl
>
> How can i pass a VERSION_STRING from the cmd line?
I don't know about passing from cli, but you can redirect output to some .d file and import it, for example.