From b99dcbfeb344390fea9919199b34e5504f7c84e3 Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Tue, 1 Aug 2017 14:36:16 +0100 Subject: build: Convert git_sha1_gen script to Python. Python is the scripting language we've been using for scripts that need to run across all supported platforms. Shell is *not* a portable language for scripts. Reviewed-by: Eric Engestrom --- bin/git_sha1_gen.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 bin/git_sha1_gen.py (limited to 'bin/git_sha1_gen.py') diff --git a/bin/git_sha1_gen.py b/bin/git_sha1_gen.py new file mode 100755 index 00000000000..6d13db1e16f --- /dev/null +++ b/bin/git_sha1_gen.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import os.path +import subprocess +import sys + +git_dir = os.path.join(os.path.dirname(sys.argv[0]), '..', '.git') +try: + git_sha1 = subprocess.check_output([ + 'git', + '--git-dir=' + git_dir, + 'rev-parse', + '--short=10', + 'HEAD', + ], stderr=open(os.devnull, 'w')) +except subprocess.CalledProcessError as e: + # don't print anything if git fails + pass +else: + sys.stdout.write('#define MESA_GIT_SHA1 "git-%s"\n' % git_sha1.rstrip()) -- cgit v1.2.3