On Wed, 2010-04-21 at 16:06 +1000, Peter Hutterer wrote: > On Mon, Apr 19, 2010 at 10:01:06PM -0400, Gaetan Nadon wrote: > > On Tue, 2010-04-20 at 10:54 +1000, Peter Hutterer wrote: > > > > > On Mon, Apr 19, 2010 at 11:00:08PM +0200, Julien Cristau wrote: > > > > On Mon, Apr 19, 2010 at 14:52:55 -0400, Gaetan Nadon wrote: > > > > > > > > > Generates the git module version according to the "git describe HEAD" > > > > > If the git module has pending changes, it appends "-dirty" to the > > > > > version tag > > > > > > > > > > Signed-off-by: Gaetan Nadon <mems...@videotron.ca> > > > > > --- > > > > > xorg-macros.m4.in | 18 ++++++++++++++++++ > > > > > 1 files changed, 18 insertions(+), 0 deletions(-) > > > > > > > > > > diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in > > > > > index 916b472..efb2e53 100644 > > > > > --- a/xorg-macros.m4.in > > > > > +++ b/xorg-macros.m4.in > > > > > @@ -1009,3 +1009,21 @@ mv \$(top_srcdir)/.INSTALL.tmp > > > > > \$(top_srcdir)/INSTALL) \ > > > > > echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: > > > > > installing possibly empty INSTALL.' >&2)" > > > > > AC_SUBST([INSTALL_CMD]) > > > > > ]) # XORG_INSTALL > > > > > + > > > > > +# XORG_GIT_MODULE_VERSION() > > > > > +# ------------------------- > > > > > +# Minimum version: 1.8.0 > > > > > +# > > > > > +# Generates the git module version according to the "git describe > > > > > HEAD" > > > > > +# If the git module has pending changes, it appends "-dirty" to the > > > > > version tag > > > > > +# > > > > > +AC_DEFUN([XORG_GIT_MODULE_VERSION], [ > > > > > +GIT_MODULE_VERSION_CMD="VER=\`GIT_DIR=\$(top_srcdir)/.git git > > > > > describe HEAD 2>/dev/null\`; \ > > > > > +DVER=\`GIT_DIR=\$(top_srcdir)/.git git diff-index HEAD > > > > > 2>/dev/null\`; \ > > > > > +OUTSTR=\"\#undef XORG_GIT_VERSION\" ; \ > > > > > +OUTFILE=\"xorg-git-version.h\"; \ > > > > > +test -n \"\$\$VER\" && OUTSTR=\"\#define XORG_GIT_VERSION \$\$VER\" > > > > > && test -n \"\$\$DVER\" && OUTSTR=\"\#define XORG_GIT_VERSION > > > > > \$\$VER-dirty\"; \ > > > > > +test -e \"\$\$OUTFILE\" || echo \"\$\$OUTSTR\" > \"\$\$OUTFILE\"; \ > > > > > +CONTENT=\`cat \$\$OUTFILE\` && test \"\$\$CONTENT\" = \"\$\$OUTSTR\" > > > > > || echo \$\$OUTSTR > \$\$OUTFILE;" > > > > > +AC_SUBST([GIT_MODULE_VERSION_CMD]) > > > > > +]) # XORG_GIT_MODULE_VERSION > > > > > > my eyes! > > > > > > > As I said in reply to the initial patch by Peter I'd like a way to > > > > disable this, because packages might be built from a git tree, which > > > > might be unrelated to the xorg one, or outside of any git tree. What's > > > > the output like if not building from git? Does 'make > > > > GIT_MODULE_VERSION_CMD=:' work to disable it (I guess not, because > > > > anything trying to include xorg-git-version.h will be unhappy)? > > > > > > it simply sets the #undef and nothing will be printed to the log file. Is > > > there any specific argument against _running_ the macro as long if it > > > doesn't add anything to the logfile? > > > > > > Gaetan: > > > I'm not a big fan of the -dirty either but I guess if others want it we > > > can > > > leave it in. Two questions though: > > > > If you remotely help someone debugging a problem, you would like to know > > if tag/commit is really the code he is running or if there are local > > changes. With the commit number you can cross-reference the master repo > > and detect unpsuhed local commits. With the -dirty (now called > > -with-uncommitted-changes) you now the code is tainted with local > > changes you know nothing about. It's just additional info. > > I really hope that when I help someone debugging they'd tell me beforehand > if they have local changes. in which case the dirty doesn't help much anyway > because you still don't know what the changes do. > but yeah, doesn't matter either way, I'm fine with it. > > > > - If modules start using this macro, do they stillhave to add to > > > DISTCLEANFILES and friends? > > > - This macro only gets invoked on automake runs, right? So if I pull and > > > just rebuild, would it update the git version? > > > > > > > All options are available in the Makefile.am regarding the invocation of > > the macro (or your original script). I have not paid attention to that, > > it looks you had it covered. The problem domain is similar to ChangeLog. > > You need a trigger when a new commit is available, but the best we could > > do is a dist hook. And you may not be running off git. What use case was > > this feature designed for? > > If someone follows git and files a bug (or sends the log) it'll be easy to > see which commit they have locally. So questions like "do you have commit > 1234deadbeef in your local repo" aren't needed, reducing the turnaround > time. > > > One suggested a dependency on a git file that changes with the HEAD > > commit, don't recall what the objections were. I'll think about it some > > more. > > Acked-by: Peter Hutterer <peter.hutte...@who-t.net> for version 2 but please > make sure that someone else acks it too, automake stuff gives me the creeps. > > would also be good checking through Matthias' script from radeonhd for any > obvious use-cases that this patch doesn't cover. It certainly seems more > complex. >
Same purpose, more features and bullet proof. Has been in use > 3 years. Dan later suggested to distribute a script rather than embed it in a macro. The radeonhd would be the one to distribute. It has a separate makefile.am as well. http://cgit.freedesktop.org/xorg/driver/xf86-video-radeonhd/tree/git_version.sh http://cgit.freedesktop.org/xorg/driver/xf86-video-radeonhd/tree/RadeonHD.am We could use the same mechanism as for the INSTALL_CMD to obtain a copy. Sample output: /* * Basic versioning gathered from the git repository. * Automatically generated by ./git_version.sh. */ #ifndef GIT_VERSION_H #define GIT_VERSION_H 1 /* whether this is a dist tarball or not */ #undef GIT_IS_DIST /* No errors occured while running git */ #undef GIT_ERRORS /* git utilities found */ #undef GIT_NOT_FOUND #define GIT_VERSION "git version 1.6.0.4" /* The following helps debug why we sometimes do not find ".git/": * abs_repo_dir="/home/nadon/xorg/src/driver/xf86-video-radeonhd/.git" (should be "/path/to/.git") * abs_srcdir="/home/nadon/xorg/src/driver/xf86-video-radeonhd" (absolute top source dir "/path/to") * git_repo_dir=".git" (usually ".git" or "/path/to/.git") * PWD="/home/nadon/xorg/src/driver/xf86-video-radeonhd" * srcdir="/home/nadon/xorg/src/driver/xf86-video-radeonhd" * working_dir="/home/nadon/xorg/src/driver/xf86-video-radeonhd" */ /* git repo found */ #define GIT_REPO 1 /* Git SHA ID of last commit */ #define GIT_SHAID "f6c99911" /* Branch this tree is on */ #define GIT_BRANCH "master" /* Local changes might be breaking things */ #define GIT_DIRTY 1 /* Define GIT_MESSAGE such that * printf("%s: built from %s", argv[0], GIT_MESSAGE); * forms a proper sentence. */ #ifdef GIT_DIRTY # define GIT_DIRTY_MSG " + changes" #else /* !GIT_DIRTY */ # define GIT_DIRTY_MSG "" #endif /* GIT_DIRTY */ #ifdef GIT_ERRORS # define GIT_ERROR_MSG " with error: " GIT_ERRORS #else /* !GIT_ERRORS */ # define GIT_ERROR_MSG "" #endif /* GIT_ERRORS */ #ifdef GIT_IS_DIST # define GIT_DIST_MSG "dist of " #else /* !GIT_IS_DIST */ # define GIT_DIST_MSG "" #endif /* GIT_IS_DIST */ #ifdef GIT_REPO # ifdef GIT_NOT_FOUND # define GIT_MESSAGE GIT_DIST_MSG "git sources without git: " GIT_NOT_FOUND # else /* !GIT_NOT_FOUND */ # define GIT_MESSAGE \ GIT_DIST_MSG \ "git branch " GIT_BRANCH ", " \ "commit " GIT_SHAID GIT_DIRTY_MSG \ GIT_ERROR_MSG # endif /* GIT_NOT_FOUND */ #else /* !GIT_REPO */ # define GIT_MESSAGE GIT_DIST_MSG "non-git sources" GIT_ERROR_MSG #endif /* GIT_REPO */ #endif /* GIT_VERSION_H */ This a sample program on how it might be used: /* example program demonstrating the use of git_version.sh output */ #include <stdio.h> #include <string.h> #ifdef HAVE_CONFIG_H # include "config.h" #endif int main(int argc, char *argv[]) { const char *const idx = strrchr(argv[0], '/'); const char *const prog = (idx)?(idx+1):(argv[0]); #ifdef PACKAGE_VERSION printf("%s: version %s, built from %s\n", prog, PACKAGE_VERSION, GIT_MESSAGE); #elif defined(GIT_MESSAGE) printf("%s: built from %s\n", prog, GIT_MESSAGE); #endif return 0; } > Cheers, > Peter
signature.asc
Description: This is a digitally signed message part
_______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel