diff options
author | Jose Fonseca <[email protected]> | 2017-08-01 14:36:16 +0100 |
---|---|---|
committer | Jose Fonseca <[email protected]> | 2017-08-01 15:24:39 +0100 |
commit | b99dcbfeb344390fea9919199b34e5504f7c84e3 (patch) | |
tree | a7ebdd094311f016fb8a8b4f618f540bf647e159 /bin | |
parent | 1bc8b2c0ebbc5f5d930058d5214b724468f981c2 (diff) |
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 <[email protected]>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/git_sha1_gen.py | 20 | ||||
-rwxr-xr-x | bin/git_sha1_gen.sh | 12 |
2 files changed, 20 insertions, 12 deletions
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()) diff --git a/bin/git_sha1_gen.sh b/bin/git_sha1_gen.sh deleted file mode 100755 index 898e5907587..00000000000 --- a/bin/git_sha1_gen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# run git from the sources directory -cd "$(dirname "$0")" - -# don't print anything if git fails -if ! git_sha1=$(git --git-dir=../.git rev-parse --short=10 HEAD 2>/dev/null) -then - exit -fi - -printf '#define MESA_GIT_SHA1 "git-%s"\n' "$git_sha1" |