From: "Dirk Süsserott" <newsletter@dirk.my1.cc>
To: Harry portobello <harryportobello@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Including git-describe info as version strings for generic "-v" output
Date: Sun, 22 Jan 2012 17:03:41 +0100 [thread overview]
Message-ID: <4F1C335D.7020802@dirk.my1.cc> (raw)
In-Reply-To: <7vd3acbtn3.fsf@alter.siamese.dyndns.org>
Am 21.01.2012 23:03 schrieb Junio C Hamano:
> Harry portobello <harryportobello@gmail.com> writes:
>
>> I hope the subject makes sense -- I'll explain what I'm trying to do.
>
> Perhaps take a look at GIT-VERSION-GEN that is part of the Git source?
At work, we have the same "problem". I solved it like so:
version.h:
----------------------------------------------
#ifndef __version_h__
#define __version_h__
#ifdef __cplusplus
extern "C" {
#endif
/*
* Returns a version string as defined with the -D compiler switch.
*/
char const * software_version();
#ifdef __cplusplus
}
#endif
#endif
----------------------------------------------
version.c:
----------------------------------------------
#include "version.h"
char const * software_version()
{
return SW_VERSION;
}
----------------------------------------------
And then make sure that ONLY version.c gets compiled like this:
gcc -DSW_VERSION=\"$(git describe --dirty)\" \
[other options] \
-c version.c -o version.o
Actually I use Scons to build my software (not Make). Scons
automatically keeps track of dependencies and changed compiler switches
between its runs. Thus it will re-compile version.c if the output of
git-describe changes. That's why Scons users must make sure that the
-D-switch is given only to version.c (else Scons would re-compile ALL
files because of the different argument to -D).
If you are using Make then make sure that version.c gets compiled
always. The drawback is that your app will be re-linked with every
single Make run.
That's why I prefer Scons: it calculates the dependencies on a checksum
basis. If the *contents* of version.c together with the compiler options
didn't change, it won't re-compile it. Furtermore: if the *contents* of
version.o didn't change, it won't re-link. Timestamps don't matter to
Scons. But that's another topic :-)
HTH
Dirk
next prev parent reply other threads:[~2012-01-22 16:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-21 19:09 Including git-describe info as version strings for generic "-v" output Harry portobello
2012-01-21 22:03 ` Junio C Hamano
2012-01-22 16:03 ` Dirk Süsserott [this message]
2012-01-23 11:16 ` demerphq
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F1C335D.7020802@dirk.my1.cc \
--to=newsletter@dirk.my1.cc \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=harryportobello@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).