Any qmake experts out there?

Lubomir I. Ivanov neolit123 at gmail.com
Thu Jan 29 05:30:43 PST 2015


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 $@
    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.

qmake is my problem as i can't get it to write my rules to the
Makefile for some reason.
will try again later.

lubomir
--


More information about the subsurface mailing list