scons: split out check_header() helper
authorEric Engestrom <eric.engestrom@imgtec.com>
Mon, 10 Jul 2017 12:27:25 +0000 (13:27 +0100)
committerEric Engestrom <eric.engestrom@imgtec.com>
Fri, 14 Jul 2017 12:23:54 +0000 (13:23 +0100)
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
scons/gallium.py

index 61643a6d4fc627ef9573928cf7767a4857b35385..c8e47a39db1dbb43baa9bb382c3941b50c783167 100755 (executable)
@@ -145,6 +145,17 @@ def check_cc(env, cc, expr, cpp_opt = '-E'):
     sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))])
     return result
 
+def check_header(env, header):
+    '''Check if the header exist'''
+
+    conf = SCons.Script.Configure(env)
+    have_header = False
+
+    if conf.CheckHeader(header):
+        have_header = True
+
+    env = conf.Finish()
+    return have_header
 
 def check_prog(env, prog):
     """Check whether this program exists."""
@@ -325,10 +336,8 @@ def generate(env):
                 'GLX_INDIRECT_RENDERING',
             ]
 
-        conf = SCons.Script.Configure(env)
-        if conf.CheckHeader('xlocale.h'):
+        if check_header(env, 'xlocale.h'):
             cppdefines += ['HAVE_XLOCALE_H']
-        env = conf.Finish()
 
     if platform == 'windows':
         cppdefines += [