Mesa (master): scons: Populate top_srcdir and top_builddir variables when reading Makefiles. sources.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Aug 14 11:21:21 UTC 2012


Module: Mesa
Branch: master
Commit: ea8dcfc90d5abbf699cd64be4dccd1e69fe82d75
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea8dcfc90d5abbf699cd64be4dccd1e69fe82d75

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Aug 14 12:18:45 2012 +0100

scons: Populate top_srcdir and top_builddir variables when reading Makefiles.sources.

This is not entirely correct, as scons doesn't put binaries in a
"src" subdirectory, but doesn't seem to be a problem for now.

---

 scons/custom.py      |    4 ++++
 scons/source_list.py |    5 ++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/scons/custom.py b/scons/custom.py
index cc953bd..43e7727 100644
--- a/scons/custom.py
+++ b/scons/custom.py
@@ -235,6 +235,10 @@ def parse_source_list(env, filename, names=None):
     # parse the source list file
     parser = source_list.SourceListParser()
     src = env.File(filename).srcnode()
+
+    parser.add_symbol('top_srcdir', env.Dir('#').abspath)
+    parser.add_symbol('top_builddir', env['build_dir'])
+
     sym_table = parser.parse(src.abspath)
 
     if names:
diff --git a/scons/source_list.py b/scons/source_list.py
index 8111f43..e16d1f9 100644
--- a/scons/source_list.py
+++ b/scons/source_list.py
@@ -13,6 +13,7 @@ The goal is to allow Makefile's and SConscript's to share source listing.
 
 class SourceListParser(object):
     def __init__(self):
+        self.symbol_table = {}
         self._reset()
 
     def _reset(self, filename=None):
@@ -20,7 +21,6 @@ class SourceListParser(object):
 
         self.line_no = 1
         self.line_cont = ''
-        self.symbol_table = {}
 
     def _error(self, msg):
         raise RuntimeError('%s:%d: %s' % (self.filename, self.line_no, msg))
@@ -125,3 +125,6 @@ class SourceListParser(object):
                 raise
 
         return self.symbol_table
+
+    def add_symbol(self, name, value):
+        self.symbol_table[name] = value




More information about the mesa-commit mailing list