[Mesa-dev] [PATCH] mesa: don't touch git_sha1.h if sha1 didn't change

Ian Romanick idr at freedesktop.org
Mon May 2 09:36:20 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/02/2011 06:25 AM, Dan Nicholson wrote:
> On Sun, May 1, 2011 at 2:53 PM, Marcin Slusarz <marcin.slusarz at gmail.com> wrote:
>> Less recompiles...
> 
> Good idea. Couple nits.

I never noticed this before.  I use ccache.  Since the preprocessed file
doesn't change, it doesn't really recompile.  This would be an issue for
anyone not using ccache, though.

>> ---
>>  bin/extract_git_sha1 |    8 ++++++--
>>  1 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/bin/extract_git_sha1 b/bin/extract_git_sha1
>> index e6e6731..fc7bf85 100755
>> --- a/bin/extract_git_sha1
>> +++ b/bin/extract_git_sha1
>> @@ -1,10 +1,14 @@
>>  #!/bin/sh
>> -touch src/mesa/main/git_sha1.h
> 
> Instead of moving the touch out to when there's no git, perhaps it
> would be better to just touch the file when it doesn't exist.
> 
> [ -f src/mesa/main/git_sha1.h ] || touch src/mesa/main/git_sha1.h

Right.  If git_sha1.h doesn't exist, there will be problems when
version.c tries to #include it.

> That way your later diff command won't complain on stdout that one of
> the files is missing on a fresh checkout.
> 
>>  if which git > /dev/null; then
>>     # Extract the 7-digit "short" SHA1 for the current HEAD, convert
>>     # it to a string, and wrap it in a #define.  This is used in
>>     # src/mesa/main/version.c to put the GIT SHA1 in the GL_VERSION string.
>>     git log -n 1 --oneline |\
>>        sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
>> -       > src/mesa/main/git_sha1.h
>> +       > src/mesa/main/git_sha1.h.tmp
>> +    if ! diff src/mesa/main/git_sha1.h.tmp src/mesa/main/git_sha1.h >/dev/null; then
>> +       mv src/mesa/main/git_sha1.h.tmp src/mesa/main/git_sha1.h
>> +    fi
> 
> I might suggest using "cmp -s" here since it's more suited to what we
> want: just says if the files are the same without having to figure out
> what's different.

I always forget about cmp (and use 'diff > /dev/null').  Good catch.

>> +else
>> +    touch src/mesa/main/git_sha1.h
>>  fi
> 
> --
> Dan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2+3YQACgkQX1gOwKyEAw/jHgCdHGiIcwgtYWLOOScepwgNvnkX
9RwAoJUdYKqCmu5/C0zWVfXTeu1oMXKt
=6nz4
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list