b=899879, pymake don't handle globs in include, r=bsmedberg
authorVladimir Vukicevic <vladimir@pobox.com>
Thu, 08 Aug 2013 23:36:36 -0400
changeset 348 e43aa12317788b69cf13e6ed7e682d42e13fc2cb
parent 347 cd96f5cee0689fe2e922918355d2d9fae17138b1
child 349 2aaad4a880f9b1b21c6f7fe9662dbd1682a7f970
push id221
push uservladimir@pobox.com
push dateFri, 09 Aug 2013 03:36:51 +0000
reviewersbsmedberg
bugs899879
b=899879, pymake don't handle globs in include, r=bsmedberg
pymake/data.py
tests/glob1.inc
tests/glob2.inc
tests/include-glob.mk
--- a/pymake/data.py
+++ b/pymake/data.py
@@ -1,14 +1,15 @@
 """
 A representation of makefile data structures.
 """
 
 import logging, re, os, sys
 import parserdata, parser, functions, process, util, implicit
+import globrelative
 from cStringIO import StringIO
 
 if sys.version_info[0] < 3:
     str_type = basestring
 else:
     str_type = str
 
 _log = logging.getLogger('pymake.data')
@@ -1765,26 +1766,31 @@ class Makefile(object):
             self.defaulttarget = value.resolvestr(self, self.variables, ['.DEFAULT_GOAL']).strip()
 
         self.error = False
 
     def include(self, path, required=True, weak=False, loc=None):
         """
         Include the makefile at `path`.
         """
-        self.included.append((path, required))
-        fspath = util.normaljoin(self.workdir, path)
-        if os.path.exists(fspath):
-            if weak:
-                stmts = parser.parsedepfile(fspath)
-            else:
-                stmts = parser.parsefile(fspath)
-            self.variables.append('MAKEFILE_LIST', Variables.SOURCE_AUTOMATIC, path, None, self)
-            stmts.execute(self, weak=weak)
-            self.gettarget(path).explicit = True
+        if self._globcheck.search(path):
+            paths = globrelative.glob(self.workdir, path)
+        else:
+            paths = [path]
+        for path in paths:
+            self.included.append((path, required))
+            fspath = util.normaljoin(self.workdir, path)
+            if os.path.exists(fspath):
+                if weak:
+                    stmts = parser.parsedepfile(fspath)
+                else:
+                    stmts = parser.parsefile(fspath)
+                self.variables.append('MAKEFILE_LIST', Variables.SOURCE_AUTOMATIC, path, None, self)
+                stmts.execute(self, weak=weak)
+                self.gettarget(path).explicit = True
 
     def addvpath(self, pattern, dirs):
         """
         Add a directory to the vpath search for the given pattern.
         """
         self._patternvpaths.append((pattern, dirs))
 
     def clearvpath(self, pattern):
new file mode 100644
--- /dev/null
+++ b/tests/glob1.inc
@@ -0,0 +1,1 @@
+A=ok
new file mode 100644
--- /dev/null
+++ b/tests/glob2.inc
@@ -0,0 +1,1 @@
+B=ok
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/tests/include-glob.mk
@@ -0,0 +1,9 @@
+include $(TESTPATH)/glob*.inc
+
+ifeq ($A_$B,ok_ok)
+all:
+	@echo TEST-PASS
+else
+all:
+	@echo TEST-FAIL
+endif