{"thread":{"id":"29419","subject":"Including git-describe info as version strings for generic \"-v\" output","startedAt":"2012-01-21T19:09:56Z","lastAt":"2012-01-23T11:16:23Z","messageCount":4,"participants":["Harry portobello","Junio C Hamano","Dirk Süsserott","demerphq"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"182901","messageId":"CAG_NL2So7cf6o+en9ktHGr94Eu5WJ9giWq6OmSxK+ZL4RdtaGA@mail.gmail.com","threadId":"29419","inReplyTo":null,"subject":"Including git-describe info as version strings for generic \"-v\" output","fromName":"Harry portobello","fromEmail":"harryportobello@gmail.com","sentAt":"2012-01-21T19:09:56Z","receivedAt":"2012-01-21T19:09:56Z","isPatch":false,"sender":{"key":"harryportobello@gmail.com","avatar":null},"body":"Hi all,\n\nI hope the subject makes sense -- I'll explain what I'm trying to do.\n\nI'm wondering what the best approaches are to being able to include\noutput from git-describe [1] for generic version strings in projects\nmanaged by Git? This would have to work from within an\nautotools-managed project.\n\nAt the moment, I've managed to hook the output from git-describe in to\na few .m4 files, which works only at ./configure time -- but of\ncourse, with this being Git, I'd ideally like the same mechanism to\nwork in a situation where someone does:\n\n$ git pull && make\n\nIt's knowing how to plumb this in to the Makefile.am part I'm hazy over.\n\nAny help would be much appreciated.\n\nHarry\n\n[1] I know it's \"git describe\"; I'm using its hyphenated form for\nclarity of context.\n"},{"id":"182908","messageId":"7vd3acbtn3.fsf@alter.siamese.dyndns.org","threadId":"29419","inReplyTo":"CAG_NL2So7cf6o+en9ktHGr94Eu5WJ9giWq6OmSxK+ZL4RdtaGA@mail.gmail.com","subject":"Re: Including git-describe info as version strings for generic \"-v\" output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-21T22:03:28Z","receivedAt":"2012-01-21T22:03:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Harry portobello <harryportobello@gmail.com> writes:\n\n> I hope the subject makes sense -- I'll explain what I'm trying to do.\n\nPerhaps take a look at GIT-VERSION-GEN that is part of the Git source?\n"},{"id":"182939","messageId":"4F1C335D.7020802@dirk.my1.cc","threadId":"29419","inReplyTo":"7vd3acbtn3.fsf@alter.siamese.dyndns.org","subject":"Re: Including git-describe info as version strings for generic \"-v\" output","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2012-01-22T16:03:41Z","receivedAt":"2012-01-22T16:03:41Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 21.01.2012 23:03 schrieb Junio C Hamano:\n> Harry portobello <harryportobello@gmail.com> writes:\n> \n>> I hope the subject makes sense -- I'll explain what I'm trying to do.\n> \n> Perhaps take a look at GIT-VERSION-GEN that is part of the Git source?\n\n\nAt work, we have the same \"problem\". I solved it like so:\n\nversion.h:\n----------------------------------------------\n#ifndef __version_h__\n#define __version_h__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Returns a version string as defined with the -D compiler switch.\n */\nchar const * software_version();\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n----------------------------------------------\n\n\nversion.c:\n----------------------------------------------\n#include \"version.h\"\n\nchar const * software_version()\n{\n    return SW_VERSION;\n}\n----------------------------------------------\n\nAnd then make sure that ONLY version.c gets compiled like this:\n\ngcc -DSW_VERSION=\\\"$(git describe --dirty)\\\" \\\n    [other options] \\\n    -c version.c -o version.o\n\nActually I use Scons to build my software (not Make). Scons\nautomatically keeps track of dependencies and changed compiler switches\nbetween its runs. Thus it will re-compile version.c if the output of\ngit-describe changes. That's why Scons users must make sure that the\n-D-switch is given only to version.c (else Scons would re-compile ALL\nfiles because of the different argument to -D).\n\nIf you are using Make then make sure that version.c gets compiled\nalways. The drawback is that your app will be re-linked with every\nsingle Make run.\n\nThat's why I prefer Scons: it calculates the dependencies on a checksum\nbasis. If the *contents* of version.c together with the compiler options\ndidn't change, it won't re-compile it. Furtermore: if the *contents* of\nversion.o didn't change, it won't re-link. Timestamps don't matter to\nScons. But that's another topic :-)\n\nHTH\n    Dirk\n"},{"id":"182959","messageId":"CANgJU+XUg8=WMjHLNhe9kxgoGna6m4+YyduBRNGurAke12vLgg@mail.gmail.com","threadId":"29419","inReplyTo":"CAG_NL2So7cf6o+en9ktHGr94Eu5WJ9giWq6OmSxK+ZL4RdtaGA@mail.gmail.com","subject":"Re: Including git-describe info as version strings for generic \"-v\" output","fromName":"demerphq","fromEmail":"demerphq@gmail.com","sentAt":"2012-01-23T11:16:23Z","receivedAt":"2012-01-23T11:16:23Z","isPatch":false,"sender":{"key":"demerphq@gmail.com","avatar":null},"body":"On 21 January 2012 20:09, Harry portobello <harryportobello@gmail.com> wrote:\n> Hi all,\n>\n> I hope the subject makes sense -- I'll explain what I'm trying to do.\n>\n> I'm wondering what the best approaches are to being able to include\n> output from git-describe [1] for generic version strings in projects\n> managed by Git? This would have to work from within an\n> autotools-managed project.\n>\n> At the moment, I've managed to hook the output from git-describe in to\n> a few .m4 files, which works only at ./configure time -- but of\n> course, with this being Git, I'd ideally like the same mechanism to\n> work in a situation where someone does:\n>\n> $ git pull && make\n>\n> It's knowing how to plumb this in to the Makefile.am part I'm hazy over.\n>\n> Any help would be much appreciated.\n\nFWIW Perl does something like this. Have a look at the Perl makefiles\nfor an example.\n\nYves\n\n\n-- \nperl -Mre=debug -e \"/just|another|perl|hacker/\"\n"}]}