Any qmake experts out there?

Lubomir I. Ivanov neolit123 at gmail.com
Thu Jan 29 05:44:58 PST 2015


On 29 January 2015 at 15:38, Thiago Macieira <thiago at macieira.org> wrote:
> On Thursday 29 January 2015 15:30:43 Lubomir I. Ivanov wrote:
>> 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 $@
>>     rm -f $@.tmp
>>
>> main.o: main.c version.h
>>     gcc -c main.c -o main.o
>>
>> main.exe: main.o
>>     gcc main.o -o main.exe
>>
>> -------------------
>>
>> what it does is, it writes the output of "git rev-parse" to a TMP file
>> and if that TMP file differs to the previous version.h file it updates
>> version.h
>> but since version.h may not change, main is not recompiled.
>
> The way I read this, persist is phony, so it will always be found to be out-
> of-date. Therefore, version.h is always out of date, so is main.o and
> therefore main.exe will too.
>
> Are you saying that if the version.h command doesn't actually touch version.h,
> then Make does not find it to be out of date?
>

it works for me,

version.h is not updated with "persist", because the diff fails.
and main.o is only recompiled if i change the HEAD (e.g. add a commit,
change branch etc..).

but i may be missing something.

lubomir
--


More information about the subsurface mailing list