<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Sorry for being late to the party - I was on PTO when this review went out. Only now I was trying to diagnose why some of our builds were broken for very long time, and tracked down to this.</p>
<p><br>
</p>
<p>Let me start stating what I think it should be obvious for everybody: using a shell script on Windows is a awful
<i>awful</i> idea. It's not admissible. That's the whole reason we use SCons instead of autotools and stuff.</p>
<p><br>
</p>
<p>The only reason this didn't break things completely for us is that Git for windows often bundles sh.exe and some times it's left in the Path. But that's a coincidence, which in fact creates problems of its own.</p>
<p><br>
</p>
<p>If you truly want to uniformize <span style="font-size: 12pt;">git_sha1.h generation then one must use cross platform scripting language as Python. Like all other scripts we have!</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">Honestly, I don't know how this pass through peer review
</span>unchallenged<span style="font-size: 12pt;">... It should have been stopped before it ever reached master.</span></p>
<p><br>
</p>
<p>Jose</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> mesa-dev <mesa-dev-bounces@lists.freedesktop.org> on behalf of Brian Paul <brianp@vmware.com><br>
<b>Sent:</b> Saturday, July 1, 2017 00:19<br>
<b>To:</b> mesa-dev@lists.freedesktop.org<br>
<b>Subject:</b> Re: [Mesa-dev] Mesa (master): build systems: uniformize git_sha1.h generation</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hi Eric,<br>
<br>
Shouldn't the new script file be put in the bin/ directory with the <br>
other helper scripts?<br>
<br>
-Brian<br>
<br>
On 06/29/2017 09:52 AM, Eric Engeström wrote:<br>
> Module: Mesa<br>
> Branch: master<br>
> Commit: 3fd425aed764fb771f2f49ddb6b30b389a114504<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__cgit.freedesktop.org_mesa_mesa_commit_-3Fid-3D3fd425aed764fb771f2f49ddb6b30b389a114504&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=C2QHFlT8FYNq-A29CoLU1hnnK3jQhP0A-EpQrqbU_GQ&s=ZjxcahOcytLNOgFBZuod2dWN2xvP8Ph32iP3dluOunQ&e=">
https://urldefense.proofpoint.com/v2/url?u=http-3A__cgit.freedesktop.org_mesa_mesa_commit_-3Fid-3D3fd425aed764fb771f2f49ddb6b30b389a114504&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=C2QHFlT8FYNq-A29CoLU1hnnK3jQhP0A-EpQrqbU_GQ&s=ZjxcahOcytLNOgFBZuod2dWN2xvP8Ph32iP3dluOunQ&e=</a><br>
><br>
> Author: Eric Engestrom <eric.engestrom@imgtec.com><br>
> Date: Tue Jun 27 12:08:41 2017 +0100<br>
><br>
> build systems: uniformize git_sha1.h generation<br>
><br>
> Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com><br>
> Reviewed-by: Matt Turner <mattst88@gmail.com><br>
> Reviewed-by: Emil Velikov <emil.velikov@collabora.com><br>
><br>
> ---<br>
><br>
> git_sha1_gen.sh | 12 ++++++++++++<br>
> src/Makefile.am | 13 +------------<br>
> src/SConscript | 28 ++++++++--------------------<br>
> src/mesa/Android.libmesa_git_sha1.mk | 7 +------<br>
> 4 files changed, 22 insertions(+), 38 deletions(-)<br>
><br>
> diff --git a/git_sha1_gen.sh b/git_sha1_gen.sh<br>
> new file mode 100755<br>
> index 0000000000..20ab8df8ea<br>
> --- /dev/null<br>
> +++ b/git_sha1_gen.sh<br>
> @@ -0,0 +1,12 @@<br>
> +#!/bin/sh<br>
> +<br>
> +# run git from the sources directory<br>
> +cd "$(dirname "$0")"<br>
> +<br>
> +# don't print anything if git fails<br>
> +if ! git_sha1=$(git --git-dir=.git rev-parse --short=10 HEAD 2>/dev/null)<br>
> +then<br>
> + exit<br>
> +fi<br>
> +<br>
> +printf '#define MESA_GIT_SHA1 "git-%s"\n' "$git_sha1"<br>
> diff --git a/src/Makefile.am b/src/Makefile.am<br>
> index df912c442a..d8a2ee59fc 100644<br>
> --- a/src/Makefile.am<br>
> +++ b/src/Makefile.am<br>
> @@ -21,18 +21,7 @@<br>
><br>
> .PHONY: git_sha1.h.tmp<br>
> git_sha1.h.tmp:<br>
> - @# Don't assume that $(top_srcdir)/.git is a directory. It may be<br>
> - @# a gitlink file if $(top_srcdir) is a submodule checkout or a linked<br>
> - @# worktree.<br>
> - @# If we are building from a release tarball copy the bundled header.<br>
> - @touch git_sha1.h.tmp<br>
> - @if test -e $(top_srcdir)/.git; then \<br>
> - if which git > /dev/null; then \<br>
> - printf '#define MESA_GIT_SHA1 "git-%s"\n' \<br>
> - `git --git-dir=$(top_srcdir)/.git rev-parse --short=10 HEAD` \<br>
> - > git_sha1.h.tmp ; \<br>
> - fi \<br>
> - fi<br>
> + @sh $(top_srcdir)/git_sha1_gen.sh > $@<br>
><br>
> git_sha1.h: git_sha1.h.tmp<br>
> @echo "updating git_sha1.h"<br>
> diff --git a/src/SConscript b/src/SConscript<br>
> index d861af8e4d..5e1171b524 100644<br>
> --- a/src/SConscript<br>
> +++ b/src/SConscript<br>
> @@ -22,27 +22,15 @@ def write_git_sha1_h_file(filename):<br>
> to retrieve the git hashid and write the header file. An empty file<br>
> will be created if anything goes wrong."""<br>
><br>
> - args = [ 'git', 'rev-parse', '--short=10', 'HEAD' ]<br>
> - try:<br>
> - (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()<br>
> - except:<br>
> - print "Warning: exception in write_git_sha1_h_file()"<br>
> - # git log command didn't work<br>
> - if not os.path.exists(filename):<br>
> - dirname = os.path.dirname(filename)<br>
> - if dirname and not os.path.exists(dirname):<br>
> - os.makedirs(dirname)<br>
> - # create an empty file if none already exists<br>
> - f = open(filename, "w")<br>
> - f.close()<br>
> - return<br>
> -<br>
> - # note that commit[:-1] removes the trailing newline character<br>
> - commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[:-1]<br>
> tempfile = "git_sha1.h.tmp"<br>
> - f = open(tempfile, "w")<br>
> - f.write(commit)<br>
> - f.close()<br>
> + with open(tempfile, "w") as f:<br>
> + args = [ 'sh', Dir('#').abspath + '/git_sha1_gen.sh' ]<br>
> + try:<br>
> + subprocess.Popen(args, stdout=f)<br>
> + except:<br>
> + print "Warning: exception in write_git_sha1_h_file()"<br>
> + return<br>
> +<br>
> if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):<br>
> # The filename does not exist or it's different from the new file,<br>
> # so replace old file with new.<br>
> diff --git a/src/mesa/Android.libmesa_git_sha1.mk b/src/mesa/Android.libmesa_git_sha1.mk<br>
> index 0fd176bf7d..a5a1ebb37f 100644<br>
> --- a/src/mesa/Android.libmesa_git_sha1.mk<br>
> +++ b/src/mesa/Android.libmesa_git_sha1.mk<br>
> @@ -46,12 +46,7 @@ LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, git_sha1.h)<br>
> $(intermediates)/git_sha1.h: $(wildcard $(MESA_TOP)/.git/logs/HEAD)<br>
> @mkdir -p $(dir $@)<br>
> @echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"<br>
> - $(hide) touch $@<br>
> - $(hide) if which git > /dev/null; then \<br>
> - git --git-dir $(MESA_TOP)/.git log -n 1 --oneline | \<br>
> - sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \<br>
> - > $@; \<br>
> - fi<br>
> + $(hide) sh $(MESA_TOP)/git_sha1_gen.sh > $@<br>
><br>
> LOCAL_EXPORT_C_INCLUDE_DIRS := $(intermediates)<br>
><br>
><br>
> _______________________________________________<br>
> mesa-commit mailing list<br>
> mesa-commit@lists.freedesktop.org<br>
> <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Dcommit&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=C2QHFlT8FYNq-A29CoLU1hnnK3jQhP0A-EpQrqbU_GQ&s=W6LuBpaa2ybCgFRk5UR-YrT1lr2rk0XsV8K6c6Ii1AI&e=">
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Dcommit&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=C2QHFlT8FYNq-A29CoLU1hnnK3jQhP0A-EpQrqbU_GQ&s=W6LuBpaa2ybCgFRk5UR-YrT1lr2rk0XsV8K6c6Ii1AI&e=</a><br>
><br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
mesa-dev@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div>
</span></font></div>
</div>
</body>
</html>