Update pymake snapshot to pull Bug 755828 and remove incorrectly added MPL 2 headers.
authorKyle Huey <khuey@kylehuey.com>
Fri, 25 May 2012 12:14:16 -0700
changeset 95077 e5e7f60fe0bed65a97963e5d5c9adc0d379a8f3e
parent 95076 45a8b9f1a4119da0602b96344ac55ba7245f742a
child 95078 70ac2f02dc7576c2aab868c61f9885442ecf5d18
push id22779
push userkhuey@mozilla.com
push dateMon, 28 May 2012 07:55:31 +0000
treeherdermozilla-central@823f773dd7eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs755828
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Update pymake snapshot to pull Bug 755828 and remove incorrectly added MPL 2 headers.
build/pymake/make.py
build/pymake/mkparse.py
build/pymake/pymake/builtins.py
build/pymake/pymake/data.py
build/pymake/pymake/functions.py
build/pymake/pymake/globrelative.py
build/pymake/pymake/implicit.py
build/pymake/pymake/parser.py
build/pymake/pymake/parserdata.py
build/pymake/pymake/process.py
build/pymake/pymake/util.py
build/pymake/pymake/win32process.py
build/pymake/tests/pycmd.py
--- a/build/pymake/make.py
+++ b/build/pymake/make.py
@@ -1,13 +1,9 @@
 #!/usr/bin/env python
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 
 """
 make.py
 
 A drop-in or mostly drop-in replacement for GNU make.
 """
 
 import sys, os
--- a/build/pymake/mkparse.py
+++ b/build/pymake/mkparse.py
@@ -1,13 +1,9 @@
 #!/usr/bin/env python
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 
 import sys
 import pymake.parser
 
 for f in sys.argv[1:]:
     print "Parsing %s" % f
     fd = open(f, 'rU')
     s = fd.read()
--- a/build/pymake/pymake/builtins.py
+++ b/build/pymake/pymake/builtins.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 # Basic commands implemented in Python
 import errno, sys, os, shutil, time
 from getopt import getopt, GetoptError
 
 from process import PythonException
 
 __all__ = ["mkdir", "rm", "sleep", "touch"]
 
--- a/build/pymake/pymake/data.py
+++ b/build/pymake/pymake/data.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 """
 A representation of makefile data structures.
 """
 
 import logging, re, os, sys
 import parserdata, parser, functions, process, util, implicit
 from cStringIO import StringIO
 
@@ -100,32 +96,31 @@ class StringExpansion(object):
 
     def __len__(self):
         return 1
 
     def __getitem__(self, i):
         assert i == 0
         return self.s, False
 
-    def __str__(self):
+    def __repr__(self):
         return "Exp<%s>(%r)" % (self.loc, self.s)
 
 class Expansion(list):
     """
     A representation of expanded data, such as that for a recursively-expanded variable, a command, etc.
     """
 
-    __slots__ = ('loc', 'hasfunc')
+    __slots__ = ('loc',)
     simple = False
 
     def __init__(self, loc=None):
         # A list of (element, isfunc) tuples
         # element is either a string or a function
         self.loc = loc
-        self.hasfunc = False
 
     @staticmethod
     def fromstring(s, path):
         return StringExpansion(s, parserdata.Location(path, 1, 0))
 
     def clone(self):
         e = Expansion()
         e.extend(self)
@@ -136,25 +131,23 @@ class Expansion(list):
         if s == '':
             return
 
         self.append((s, False))
 
     def appendfunc(self, func):
         assert isinstance(func, functions.Function)
         self.append((func, True))
-        self.hasfunc = True
 
     def concat(self, o):
         """Concatenate the other expansion on to this one."""
         if o.simple:
             self.appendstr(o.s)
         else:
             self.extend(o)
-            self.hasfunc = self.hasfunc or o.hasfunc
 
     def isempty(self):
         return (not len(self)) or self[0] == ('', False)
 
     def lstrip(self):
         """Strip leading literal whitespace from this expansion."""
         while True:
             i, isfunc = self[0]
@@ -178,20 +171,43 @@ class Expansion(list):
             i = i.rstrip()
             if i != '':
                 self[-1] = i, False
                 return
 
             del self[-1]
 
     def finish(self):
-        if self.hasfunc:
-            return self
+        # Merge any adjacent literal strings:
+        strings = []
+        elements = []
+        for (e, isfunc) in self:
+            if isfunc:
+                if strings:
+                    s = ''.join(strings)
+                    if s:
+                        elements.append((s, False))
+                    strings = []
+                elements.append((e, True))
+            else:
+                strings.append(e)
 
-        return StringExpansion(''.join([i for i, isfunc in self]), self.loc)
+        if not elements:
+            # This can only happen if there were no function elements.
+            return StringExpansion(''.join(strings), self.loc)
+
+        if strings:
+            s = ''.join(strings)
+            if s:
+                elements.append((s, False))
+
+        if len(elements) < len(self):
+            self[:] = elements
+
+        return self
 
     def resolve(self, makefile, variables, fd, setting=[]):
         """
         Resolve this variable into a value, by interpolating the value
         of other variables.
 
         @param setting (Variable instance) the variable currently
                being set, if any. Setting variables must avoid self-referential
@@ -693,17 +709,20 @@ class RemakeRuleContext(object):
         self.runcb = cb
 
         if self.rule is None or not len(self.rule.commands):
             if self.target.mtime is None:
                 self.target.beingremade()
             else:
                 for d, weak in self.deps:
                     if mtimeislater(d.mtime, self.target.mtime):
-                        self.target.beingremade()
+                        if d.mtime is None:
+                            self.target.beingremade()
+                        else:
+                            _log.info("%sNot remaking %s ubecause it would have no effect, even though %s is newer.", indent, self.target.target, d.target)
                         break
             cb(error=False)
             return
 
         if self.rule.doublecolon:
             if len(self.deps) == 0:
                 if self.avoidremakeloop:
                     _log.info("%sNot remaking %s using rule at %s because it would introduce an infinite loop.", indent, self.target.target, self.rule.loc)
--- a/build/pymake/pymake/functions.py
+++ b/build/pymake/pymake/functions.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 """
 Makefile functions.
 """
 
 import parser, util
 import subprocess, os, logging
 from globrelative import glob
 from cStringIO import StringIO
@@ -46,16 +42,22 @@ class Function(object):
 
     def append(self, arg):
         assert isinstance(arg, (data.Expansion, data.StringExpansion))
         self._arguments.append(arg)
 
     def __len__(self):
         return len(self._arguments)
 
+    def __repr__(self):
+        return "%s<%s>(%r)" % (
+            self.__class__.__name__, self.loc,
+            ','.join([repr(a) for a in self._arguments]),
+            )
+
 class VariableRef(Function):
     __slots__ = ('vname', 'loc')
 
     def __init__(self, loc, vname):
         self.loc = loc
         assert isinstance(vname, (data.Expansion, data.StringExpansion))
         self.vname = vname
         
@@ -69,16 +71,19 @@ class VariableRef(Function):
 
         flavor, source, value = variables.get(vname)
         if value is None:
             log.debug("%s: variable '%s' was not set" % (self.loc, vname))
             return
 
         value.resolve(makefile, variables, fd, setting + [vname])
 
+    def __repr__(self):
+        return "VariableRef<%s>(%r)" % (self.loc, self.vname)
+
 class SubstitutionRef(Function):
     """$(VARNAME:.c=.o) and $(VARNAME:%.c=%.o)"""
 
     __slots__ = ('loc', 'vname', 'substfrom', 'substto')
 
     def __init__(self, loc, varname, substfrom, substto):
         self.loc = loc
         self.vname = varname
@@ -104,16 +109,20 @@ class SubstitutionRef(Function):
         f = data.Pattern(substfrom)
         if not f.ispattern():
             f = data.Pattern('%' + substfrom)
             substto = '%' + substto
 
         fd.write(' '.join([f.subst(substto, word, False)
                            for word in value.resolvesplit(makefile, variables, setting + [vname])]))
 
+    def __repr__(self):
+        return "SubstitutionRef<%s>(%r:%r=%r)" % (
+            self.loc, self.vname, self.substfrom, selfsubstto,)
+
 class SubstFunction(Function):
     name = 'subst'
     minargs = 3
     maxargs = 3
 
     __slots__ = Function.__slots__
 
     def resolve(self, makefile, variables, fd, setting):
--- a/build/pymake/pymake/globrelative.py
+++ b/build/pymake/pymake/globrelative.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 """
 Filename globbing like the python glob module with minor differences:
 
 * glob relative to an arbitrary directory
 * include . and ..
 * check that link targets exist, not just links
 """
 
--- a/build/pymake/pymake/implicit.py
+++ b/build/pymake/pymake/implicit.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 """
 Implicit variables; perhaps in the future this will also include some implicit
 rules, at least match-anything cancellation rules.
 """
 
 variables = {
     'MKDIR': '%pymake.builtins mkdir',
     'RM': '%pymake.builtins rm -f',
--- a/build/pymake/pymake/parser.py
+++ b/build/pymake/pymake/parser.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 """
 Module for parsing Makefile syntax.
 
 Makefiles use a line-based parsing system. Continuations and substitutions are handled differently based on the
 type of line being parsed:
 
 Lines with makefile syntax condense continuations to a single space, no matter the actual trailing whitespace
 of the first line or the leading whitespace of the continuation. In other situations, trailing whitespace is
--- a/build/pymake/pymake/parserdata.py
+++ b/build/pymake/pymake/parserdata.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 import logging, re, os
 import data, parser, functions, util
 from cStringIO import StringIO
 from pymake.globrelative import hasglob, glob
 
 _log = logging.getLogger('pymake.data')
 _tabwidth = 4
 
@@ -465,16 +461,19 @@ class UnexportDirective(Statement):
     def __init__(self, exp):
         self.exp = exp
 
     def execute(self, makefile, context):
         vlist = list(self.exp.resolvesplit(makefile, makefile.variables))
         for v in vlist:
             makefile.exportedvars[v] = False
 
+    def dump(self, fd, indent):
+        print >>fd, "%sUnexport %s" % (indent, self.exp)
+
 class EmptyDirective(Statement):
     __slots__ = ('exp',)
 
     def __init__(self, exp):
         assert isinstance(exp, (data.Expansion, data.StringExpansion))
         self.exp = exp
 
     def execute(self, makefile, context):
--- a/build/pymake/pymake/process.py
+++ b/build/pymake/pymake/process.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 """
 Skipping shell invocations is good, when possible. This wrapper around subprocess does dirty work of
 parsing command lines into argv and making sure that no shell magic is being used.
 """
 
 #TODO: ship pyprocessing?
 import multiprocessing, multiprocessing.dummy
 import subprocess, shlex, re, logging, sys, traceback, os, imp, glob
--- a/build/pymake/pymake/util.py
+++ b/build/pymake/pymake/util.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 import os
 
 class MakeError(Exception):
     def __init__(self, message, loc=None):
         self.msg = message
         self.loc = loc
 
     def __str__(self):
--- a/build/pymake/pymake/win32process.py
+++ b/build/pymake/pymake/win32process.py
@@ -1,12 +1,8 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
 from ctypes import windll, POINTER, byref, WinError
 from ctypes.wintypes import WINFUNCTYPE, HANDLE, DWORD, BOOL
 
 INFINITE = -1
 WAIT_FAILED = 0xFFFFFFFF
 
 LPDWORD = POINTER(DWORD)
 _GetExitCodeProcessProto = WINFUNCTYPE(BOOL, HANDLE, LPDWORD)
--- a/build/pymake/tests/pycmd.py
+++ b/build/pymake/tests/pycmd.py
@@ -4,10 +4,10 @@ def writetofile(args):
   with open(args[0], 'w') as f:
     f.write(' '.join(args[1:]))
 
 def writeenvtofile(args):
   with open(args[0], 'w') as f:
     f.write(os.environ[args[1]])
 
 def asplode(args):
-  sys.exit(args[0])
+  sys.exit(0)
   return 0