Bug 869613 - Make mach build some/deeper/path do dependencies for some and
☠☠ backed out by 583e9f08aeeb ☠ ☠
authorTareq Khandaker <tareqakhandaker@gmail.com>
Wed, 25 Sep 2013 09:48:20 -0400
changeset 148666 0d924e17bba428895d796075c2689048be0ea3cf
parent 148662 3408740409b3855818e68fee460bbb71415e6c55
child 148667 eb18a564629a5060160345f2b7bbe583fd083ac7
push id25352
push userkwierso@gmail.com
push dateThu, 26 Sep 2013 03:27:24 +0000
treeherdermozilla-central@94548c13fd47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs869613
milestone27.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
Bug 869613 - Make mach build some/deeper/path do dependencies for some and some/deeper. r=jdm
python/mozbuild/dumbmake/dumbmake.py
--- a/python/mozbuild/dumbmake/dumbmake.py
+++ b/python/mozbuild/dumbmake/dumbmake.py
@@ -2,16 +2,17 @@
 # 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 __future__ import unicode_literals
 
 from collections import OrderedDict
 from itertools import groupby
 from operator import itemgetter
+from os.path import dirname
 
 WHITESPACE_CHARACTERS = ' \t'
 
 def indentation(line):
     """Number of whitespace (tab and space) characters at start of |line|."""
     i = 0
     while i < len(line):
         if line[i] not in WHITESPACE_CHARACTERS:
@@ -56,38 +57,66 @@ def all_dependencies(*targets, **kwargs)
     """
     dm = kwargs.pop('dependency_map', None)
     if dm is None:
         dm = dependency_map(targets)
 
     all_targets = OrderedDict() # Used as an ordered set.
 
     for target in targets:
-        all_targets[target] = True
         if target in dm:
             for dependency in dm[target]:
                 # Move element back in the ordered set.
                 if dependency in all_targets:
                     del all_targets[dependency]
                 all_targets[dependency] = True
 
     return all_targets.keys()
 
+def get_components(path):
+    """Take a path and return all the components of the path."""
+    paths = [path]
+    while True:
+        parent = dirname(paths[-1])
+        if parent == "":
+            break
+        paths.append(parent)
+
+    paths.reverse()
+    return paths
+
 def add_extra_dependencies(target_pairs, dependency_map):
     """Take a list [(make_dir, make_target)] and expand (make_dir, None)
     entries with extra make dependencies from |dependency_map|.
 
     Returns an iterator of pairs (make_dir, make_target).
 
     """
+    all_targets = OrderedDict() # Used as an ordered set.
+    make_dirs = OrderedDict() # Used as an ordered set.
+
     for make_target, group in groupby(target_pairs, itemgetter(1)):
         # Return non-simple directory targets untouched.
         if make_target is not None:
             for pair in group:
-                yield pair
+                # Generate dependencies for all components of a path.
+                # Given path a/b/c, examine a, a/b, and a/b/c in that order.
+                paths = get_components(pair[1])
+                # For each component of a path, find and add all dependencies
+                # to the final target list.
+                for target in paths:
+                    if target not in all_targets:
+                        yield pair[0], target
+                        all_targets[target] = True
             continue
 
         # Add extra dumbmake dependencies to simple directory targets.
-        make_dirs = [make_dir for make_dir, _ in group]
-        new_make_dirs = all_dependencies(*make_dirs, dependency_map=dependency_map)
+        for make_dir, _ in group:
+            make_dirs[make_dir] = True
 
-        for make_dir in new_make_dirs:
-            yield make_dir, None
+    all_components = []
+    for make_dir in make_dirs.iterkeys():
+        all_components.extend(get_components(make_dir))
+        yield make_dir, None
+
+    for i in all_dependencies(*all_components, dependency_map=dependency_map):
+        if i not in make_dirs:
+            yield i, None