[Mesa-dev] [PATCH] scons: Fix dependencies of generated headers.

jfonseca at vmware.com jfonseca at vmware.com
Mon Jan 21 09:57:15 PST 2013


From: José Fonseca <jfonseca at vmware.com>

It appears that scons implicit dependency scanners fail to chain
dependencies of generated headers when these are outside the build tree.

This patch ensures generated source files are _always_ put in the build
tree. I'm not 100% this will fix all depency issues, but from my
experiments it does seem to fix this.

NOTE: For this to be effective it is necessary to clean the source tree
from generated header/source files.
---
 src/gallium/state_trackers/vega/SConscript |    6 ++--
 src/gallium/targets/libgl-xlib/SConscript  |    4 +--
 src/glx/SConscript                         |    9 ++----
 src/mapi/glapi/SConscript                  |    4 +--
 src/mapi/glapi/gen/SConscript              |   46 ++++++++++++----------------
 src/mapi/vgapi/SConscript                  |    5 +--
 src/mesa/SConscript                        |   23 ++------------
 src/mesa/drivers/osmesa/SConscript         |    3 +-
 src/mesa/drivers/x11/SConscript            |    4 +--
 9 files changed, 34 insertions(+), 70 deletions(-)

diff --git a/src/gallium/state_trackers/vega/SConscript b/src/gallium/state_trackers/vega/SConscript
index 3dada10..b68a732 100644
--- a/src/gallium/state_trackers/vega/SConscript
+++ b/src/gallium/state_trackers/vega/SConscript
@@ -9,6 +9,7 @@ env = env.Clone()
 
 env.Append(CPPPATH = [
     '#/src/mapi',
+    Dir('.'),
 ])
 env.Append(CPPDEFINES = [
     'VEGA_VERSION_STRING=',
@@ -47,13 +48,12 @@ vega_sources = [
     'vgu.c'
 ]
 
-api_tmp = env.CodeGenerate(
-        target = '#/src/gallium/state_trackers/vega/api_tmp.h',
+api_tmp, = env.CodeGenerate(
+        target = 'api_tmp.h',
         script = '#src/mapi/mapi/mapi_abi.py',
         source = '#src/mapi/vgapi/vgapi.csv',
         command = python_cmd + ' $SCRIPT --printer vgapi --mode app $SOURCE > $TARGET'
 )
-env.Depends(vega_sources, api_tmp)
 
 st_vega = env.ConvenienceLibrary(
     target = 'st_vega',
diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript
index dc1ce89..58ed6d4 100644
--- a/src/gallium/targets/libgl-xlib/SConscript
+++ b/src/gallium/targets/libgl-xlib/SConscript
@@ -10,6 +10,7 @@ env.Append(CPPPATH = [
     '#/src/mesa',
     '#/src/mesa/main',
     '#src/gallium/state_trackers/glx/xlib',
+    Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers
 ])
 
 env.Append(CPPDEFINES = ['USE_XSHM'])
@@ -36,9 +37,6 @@ sources = [
     'xlib.c',
 ]
 
-# The sources depend on the python-generated GL API files/headers.
-env.Depends(sources, glapi_headers)
-
 if True:
     env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_GALAHAD', 'GALLIUM_SOFTPIPE'])
     env.Prepend(LIBS = [trace, rbug, galahad, softpipe])
diff --git a/src/glx/SConscript b/src/glx/SConscript
index c921eef..09e0e16 100644
--- a/src/glx/SConscript
+++ b/src/glx/SConscript
@@ -114,16 +114,14 @@ env.CodeGenerate(
     command = python_cmd + ' $SCRIPT -f $SOURCE -m init_c > $TARGET'
 )
 
-headers = []
-
-headers += env.CodeGenerate(
+env.CodeGenerate(
     target = 'indirect_size.h',
     script = GLAPI + 'gen/glX_proto_size.py',
     source = GLAPI + 'gen/gl_API.xml',
     command = python_cmd + ' $SCRIPT -f $SOURCE -m size_h --only-set -h _INDIRECT_SIZE_H > $TARGET'
 )
 
-headers += env.CodeGenerate(
+env.CodeGenerate(
     target = 'indirect.h',
     script = GLAPI + 'gen/glX_proto_send.py',
     source = GLAPI + 'gen/gl_API.xml',
@@ -131,9 +129,6 @@ headers += env.CodeGenerate(
     )
 
 
-env.Depends(sources, headers)
-
-
 libgl = env.InstallSharedLibrary(libgl, version=(1, 2))
 
 env.Alias('glx', libgl)
diff --git a/src/mapi/glapi/SConscript b/src/mapi/glapi/SConscript
index 153374c..00cce3e 100644
--- a/src/mapi/glapi/SConscript
+++ b/src/mapi/glapi/SConscript
@@ -26,6 +26,7 @@ if env['platform'] == 'windows':
 env.Append(CPPPATH = [
     '#/src/mapi',
     '#/src/mesa',
+    Dir('..'), # src/mapi build path
 ])
 
 glapi_sources = [
@@ -103,6 +104,3 @@ glapi = env.ConvenienceLibrary(
     source = glapi_sources,
 )
 Export('glapi')
-
-
-env.Depends(glapi_sources, glapi_headers)
diff --git a/src/mapi/glapi/gen/SConscript b/src/mapi/glapi/gen/SConscript
index 353d021..6d36248 100644
--- a/src/mapi/glapi/gen/SConscript
+++ b/src/mapi/glapi/gen/SConscript
@@ -7,43 +7,37 @@ from sys import executable as python_cmd
 # Mesa and GLX tree.  Other .c and .h files are generated elsewhere
 # if they're only used in one place.
 
-GLAPI = '#src/mapi/glapi/'
-
-glapi_headers = []
-
-glapi_headers += env.CodeGenerate(
-    target = '#src/mesa/main/dispatch.h',
-    script = GLAPI + 'gen/gl_table.py',
-    source = GLAPI + 'gen/gl_and_es_API.xml',
+env.CodeGenerate(
+    target = '../../../mesa/main/dispatch.h',
+    script = 'gl_table.py',
+    source = 'gl_and_es_API.xml',
     command = python_cmd + ' $SCRIPT -m remap_table -f $SOURCE > $TARGET',
     )
 
-glapi_headers += env.CodeGenerate(
-    target = '#src/mapi/glapi/glapitable.h',
-    script = GLAPI + 'gen/gl_table.py',
-    source = GLAPI + 'gen/gl_and_es_API.xml',
+env.CodeGenerate(
+    target = '../../../mapi/glapi/glapitable.h',
+    script = 'gl_table.py',
+    source = 'gl_and_es_API.xml',
     command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     )
 
-glapi_headers += env.CodeGenerate(
-    target = '#src/mapi/glapi/glapitemp.h',
-    script = GLAPI + 'gen/gl_apitemp.py',
-    source = GLAPI + 'gen/gl_and_es_API.xml',
+env.CodeGenerate(
+    target = '../../../mapi/glapi/glapitemp.h',
+    script = 'gl_apitemp.py',
+    source = 'gl_and_es_API.xml',
     command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     )
 
-glapi_headers += env.CodeGenerate(
-    target = '#src/mapi/glapi/glprocs.h',
-    script = GLAPI + 'gen/gl_procs.py',
-    source = GLAPI + 'gen/gl_and_es_API.xml',
+env.CodeGenerate(
+    target = '../../../mapi/glapi/glprocs.h',
+    script = 'gl_procs.py',
+    source = 'gl_and_es_API.xml',
     command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     )
 
-glapi_headers += env.CodeGenerate(
-    target = '#src/mesa/main/remap_helper.h',
-    script = GLAPI + 'gen/remap_helper.py',
-    source = GLAPI + 'gen/gl_and_es_API.xml',
+env.CodeGenerate(
+    target = '../../../mesa/main/remap_helper.h',
+    script = 'remap_helper.py',
+    source = 'gl_and_es_API.xml',
     command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     )
-
-env.Export('glapi_headers')
diff --git a/src/mapi/vgapi/SConscript b/src/mapi/vgapi/SConscript
index 10241fd..fd4467b 100644
--- a/src/mapi/vgapi/SConscript
+++ b/src/mapi/vgapi/SConscript
@@ -7,8 +7,8 @@ Import('*')
 
 env = env.Clone()
 
-vgapi_header = env.CodeGenerate(
-    target = '#src/mapi/vgapi/vgapi_tmp.h',
+vgapi_header, = env.CodeGenerate(
+    target = 'vgapi_tmp.h',
     script = '../mapi/mapi_abi.py',
     source = 'vgapi.csv',
     command = python_cmd + ' $SCRIPT --printer vgapi --mode lib $SOURCE > $TARGET'
@@ -23,6 +23,7 @@ env.Append(CPPDEFINES = [
 env.Append(CPPPATH = [
     '#/include',
     '#/src/mapi',
+    Dir('..'), # vgapi/vgapi_tmp.h build path
 ])
 
 mapi_sources = [
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index e03d6a6..ca9b70b 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -14,6 +14,8 @@ env.Append(CPPPATH = [
     '#/src/mapi',
     '#/src/glsl',
     '#/src/mesa',
+    Dir('../mapi'), # src/mapi build path
+    Dir('.'), # src/mesa build path
 ])
 
 enabled_apis = []
@@ -290,9 +292,6 @@ program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
 program_parse = env.CFile('program/program_parse.tab.c',
                           'program/program_parse.y')
 
-# Make program/program_parse.tab.h reacheable from the include path
-env.Append(CPPPATH = [Dir('.').abspath])
-
 program_sources = [
     'program/arbprogparse.c',
     'program/prog_hash_table.c',
@@ -341,19 +340,6 @@ if env['gles']:
 
     enabled_apis += ['ES1', 'ES2']
 
-    # generate GLES sources
-    gles_sources = []
-
-    # generate GLES headers
-    gles_headers = []
-
-    env.Depends(gles_sources, gles_headers)
-
-    # gles_sources #include gles_headers with full path
-    env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
-
-    mesa_sources += gles_sources
-
 env.Append(CPPDEFINES = ["FEATURE_%s=1" % api for api in enabled_apis])
 
 get_hash_gen_opts = ' '.join(["-a %s" % api for api in enabled_apis])
@@ -366,8 +352,6 @@ get_hash_header = env.CodeGenerate(
                 ' -f $SOURCE > $TARGET'
 )
 
-env.Depends(glget_sources, get_hash_header)
-
 #
 # Assembly sources
 #
@@ -453,9 +437,6 @@ env.CodeGenerate(
     command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     )
 
-# We also depend on the auto-generated GL API headers
-env.Depends(mesa_sources, glapi_headers)
-
 
 def write_git_sha1_h_file(filename):
     """Mesa looks for a git_sha1.h file at compile time in order to display
diff --git a/src/mesa/drivers/osmesa/SConscript b/src/mesa/drivers/osmesa/SConscript
index e4f23c2..fb2d98c 100644
--- a/src/mesa/drivers/osmesa/SConscript
+++ b/src/mesa/drivers/osmesa/SConscript
@@ -5,6 +5,7 @@ env = env.Clone()
 env.Prepend(CPPPATH = [
     '#src/mapi',
     '#src/mesa',
+    Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers
 ])
 
 env.Prepend(LIBS = [
@@ -34,5 +35,3 @@ osmesa = env.SharedLibrary(
 )
 
 env.Alias('osmesa', osmesa)
-
-env.Depends(sources, glapi_headers)
diff --git a/src/mesa/drivers/x11/SConscript b/src/mesa/drivers/x11/SConscript
index 984e6ce..b0173be 100644
--- a/src/mesa/drivers/x11/SConscript
+++ b/src/mesa/drivers/x11/SConscript
@@ -6,6 +6,7 @@ env.Append(CPPPATH = [
     '#/src/mapi',
     '#/src/mesa',
     '#/src/mesa/main',
+    Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers
 ])
 
 env.Append(CPPDEFINES = ['USE_XSHM'])
@@ -30,9 +31,6 @@ sources = [
 	'xm_tri.c',
 ]
 
-# The sources depend on the python-generated GL API files/headers.
-env.Depends(sources, glapi_headers)
-
 # libGL.so.1.6
 libgl_1_6 = env.SharedLibrary(
     target ='GL',
-- 
1.7.9.5



More information about the mesa-dev mailing list