Any qmake experts out there?

Lubomir I. Ivanov neolit123 at gmail.com
Thu Jan 29 06:09:02 PST 2015


On 29 January 2015 at 15:30, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> On 29 January 2015 at 04:59, Thiago Macieira <thiago at macieira.org> wrote:
>> On Wednesday 28 January 2015 11:04:21 Linus Torvalds wrote:
>>> The proper way to get the git version is to just do
>>>
>>>      # get raw SHA1
>>>      git rev-parse HEAD
>>>
>>>      # get "description" of it
>>>      git describe --tags --abbrev=12
>>>
>>> but actually accessing the .git/HEAD file directly is very wrong. But
>>> I have no idea how to do git commands in the *.pri file, and handling
>>> failure gracefully (in case it's not a git repository etc).
>>
>> You're right, but this implies always running the rule. That implies Make must
>> find that a given file is not up to date, otherwise it won't run the rule. In
>> turn, it means the not-up-to--date status cascades down to the binary and Make
>> will recompile and relink, even if nothing changed.
>>
>> I don't know of a way to ask Make to always run some commands and inspect file
>> contents before deciding what is up to date and what isn't. The closest I can
>> think of is to touch or not touch another file, but in a parallel build Make
>> may have already inspected that file and decided it was up-to-date.
>>
>> Do you know of any tricks I'm missing?
>
> this is what i would do:
> -----------------
>
> all: main.exe
>
> .PHONY: persist
>
> version.h: persist
>     cat $@ 2> /dev/null || git rev-parse HEAD > $@
>     git rev-parse HEAD > $@.tmp
>     git diff --quiet $@ $@.tmp || cp $@.tmp $@

"diff -q" should be used instead of "git diff":

because version.h should not be tracked by git and "git diff" is not
reliable if the file is not tracked (i think).
at least it returns no output with msys-git no matter the files (.h /
.h.tmp) being differ or not.

lubomir
--


More information about the subsurface mailing list