[Mesa-dev] [PATCH 1/4] scons: move the git_sha1.h rule a level up
Emil Velikov
emil.l.velikov at gmail.com
Mon May 30 12:46:08 UTC 2016
From: Emil Velikov <emil.velikov at collabora.com>
Analogous to the previous commit.
Cc: Brian Paul <brianp at vmware.com>
Cc: Jose Fonseca <jfonseca at vmware.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/SConscript | 39 +++++++++++++++++++++++++++++++++++++++
src/mesa/SConscript | 43 +++----------------------------------------
2 files changed, 42 insertions(+), 40 deletions(-)
diff --git a/src/SConscript b/src/SConscript
index 4ba0a32..d623c51 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -1,5 +1,44 @@
Import('*')
+import filecmp
+import os
+import subprocess
+def write_git_sha1_h_file(filename):
+ """Mesa looks for a git_sha1.h file at compile time in order to display
+ the current git hash id in the GL_VERSION string. This function tries
+ to retrieve the git hashid and write the header file. An empty file
+ will be created if anything goes wrong."""
+
+ args = [ 'git', 'log', '-n', '1', '--oneline' ]
+ try:
+ (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
+ except:
+ # git log command didn't work
+ if not os.path.exists(filename):
+ dirname = os.path.dirname(filename)
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+ # create an empty file if none already exists
+ f = open(filename, "w")
+ f.close()
+ return
+
+ commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
+ tempfile = "git_sha1.h.tmp"
+ f = open(tempfile, "w")
+ f.write(commit)
+ f.close()
+ if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
+ # The filename does not exist or it's different from the new file,
+ # so replace old file with new.
+ if os.path.exists(filename):
+ os.remove(filename)
+ os.rename(tempfile, filename)
+ return
+
+
+# Create the git_sha1.h header file
+write_git_sha1_h_file("git_sha1.h")
if env['platform'] == 'windows':
SConscript('getopt/SConscript')
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 434800e..b9495f0 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -3,9 +3,6 @@
Import('*')
-import filecmp
-import os
-import subprocess
from sys import executable as python_cmd
env = env.Clone()
@@ -119,45 +116,11 @@ if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
env.Append(CPPPATH = [matypes[0].dir])
-def write_git_sha1_h_file(filename):
- """Mesa looks for a git_sha1.h file at compile time in order to display
- the current git hash id in the GL_VERSION string. This function tries
- to retrieve the git hashid and write the header file. An empty file
- will be created if anything goes wrong."""
-
- args = [ 'git', 'log', '-n', '1', '--oneline' ]
- try:
- (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
- except:
- # git log command didn't work
- if not os.path.exists(filename):
- dirname = os.path.dirname(filename)
- if not os.path.exists(dirname):
- os.makedirs(dirname)
- # create an empty file if none already exists
- f = open(filename, "w")
- f.close()
- return
-
- commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
- tempfile = "git_sha1.h.tmp"
- f = open(tempfile, "w")
- f.write(commit)
- f.close()
- if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
- # The filename does not exist or it's different from the new file,
- # so replace old file with new.
- if os.path.exists(filename):
- os.remove(filename)
- os.rename(tempfile, filename)
- return
-
-
-# Create the git_sha1.h header file
-write_git_sha1_h_file("main/git_sha1.h")
-# and update CPPPATH so the git_sha1.h header can be found
+# and update CPPPATH so the generated files can be found
env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
+# ... plus the path for the git_sha1.h header
+env.Append(CPPPATH = ["#" + env['build_dir']])
#
# Libraries
--
2.8.2
More information about the mesa-dev
mailing list