common.py \
docs \
doxygen \
- bin/git_sha1_gen.sh \
+ bin/git_sha1_gen.py \
scons \
SConstruct
--- /dev/null
+#!/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())
+++ /dev/null
-#!/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"
.PHONY: git_sha1.h.tmp
git_sha1.h.tmp:
- @sh $(top_srcdir)/bin/git_sha1_gen.sh > $@
+ @python $(top_srcdir)/bin/git_sha1_gen.py > $@
git_sha1.h: git_sha1.h.tmp
@echo "updating git_sha1.h"
import filecmp
import os
import subprocess
+from sys import executable as python_cmd
Import('*')
tempfile = "git_sha1.h.tmp"
with open(tempfile, "w") as f:
- args = [ 'sh', Dir('#').abspath + '/bin/git_sha1_gen.sh' ]
+ args = [ python_cmd, Dir('#').abspath + '/bin/git_sha1_gen.py' ]
try:
subprocess.Popen(args, stdout=f).wait()
except:
$(intermediates)/git_sha1.h: $(wildcard $(MESA_TOP)/.git/logs/HEAD)
@mkdir -p $(dir $@)
@echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
- $(hide) sh $(MESA_TOP)/bin/git_sha1_gen.sh > $@
+ $(hide) python $(MESA_TOP)/bin/git_sha1_gen.py > $@
LOCAL_EXPORT_C_INCLUDE_DIRS := $(intermediates)