author | Mike Hommey <mh+mozilla@glandium.org> |
Tue, 01 Dec 2015 21:13:24 +0900 | |
changeset 275410 | 917c97129ea879c0e79a93d8d97d421d79ceb210 |
parent 275409 | 249b4d65a3516df20804599267e934c3c7c8bdc8 |
child 275411 | 93f0e6c2b2fdbe74bf955d0c8f71d73daabb537f |
push id | 29752 |
push user | cbook@mozilla.com |
push date | Thu, 03 Dec 2015 11:03:31 +0000 |
treeherder | mozilla-central@85cf2e720a84 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gps |
bugs | 1229341 |
milestone | 45.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
|
--- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -930,46 +930,44 @@ class RecursiveMakeBackend(CommonBackend self._may_skip[tier].add(backend_file.relobjdir) for tier in set(self._no_skip.keys()) & affected_tiers: self._no_skip[tier].add(backend_file.relobjdir) def _walk_hierarchy(self, obj, element, namespace=''): """Walks the ``HierarchicalStringList`` ``element`` in the context of the mozbuild object ``obj`` as though by ``element.walk()``, but yield - three-tuple containing the following: + tuple containing the following: - ``source`` - The path to the source file named by the current string - ``dest`` - The relative path, including the namespace, of the destination file. - - ``flags`` - A dictionary of flags associated with the current string, - or None if there is no such dictionary. """ for path, strings in element.walk(): for s in strings: source = mozpath.normpath(mozpath.join(obj.srcdir, s)) dest = mozpath.join(namespace, path, mozpath.basename(s)) - yield source, dest, strings.flags_for(s) + yield source, dest def _process_defines(self, obj, backend_file, which='DEFINES'): """Output the DEFINES rules to the given backend file.""" defines = list(obj.get_defines()) if defines: backend_file.write(which + ' +=') for define in defines: backend_file.write(' %s' % define) backend_file.write('\n') def _process_exports(self, obj, exports, backend_file): # This may not be needed, but is present for backwards compatibility # with the old make rules, just in case. if not obj.dist_install: return - for source, dest, _ in self._walk_hierarchy(obj, exports): + for source, dest in self._walk_hierarchy(obj, exports): self._install_manifests['dist_include'].add_symlink(source, dest) if not os.path.exists(source): raise Exception('File listed in EXPORTS does not exist: %s' % source) def _process_test_harness_files(self, obj, backend_file): for path, files in obj.srcdir_files.iteritems(): for source in files: @@ -987,19 +985,17 @@ class RecursiveMakeBackend(CommonBackend %(prefix)s_DEST := %(dest)s INSTALL_TARGETS += %(prefix)s """ % { 'prefix': prefix, 'dest': '$(DEPTH)/_tests/%s' % path, 'files': ' '.join(mozpath.relpath(f, backend_file.objdir) for f in files) }) def _process_branding_files(self, obj, files, backend_file): - for source, dest, flags in self._walk_hierarchy(obj, files): - if flags and flags.source: - source = mozpath.normpath(mozpath.join(obj.srcdir, flags.source)) + for source, dest in self._walk_hierarchy(obj, files): if not os.path.exists(source): raise Exception('File listed in BRANDING_FILES does not exist: %s' % source) self._install_manifests['dist_branding'].add_symlink(source, dest) # Also emit the necessary rules to create $(DIST)/branding during partial # tree builds. The locale makefiles rely on this working. backend_file.write('NONRECURSIVE_TARGETS += export\n')
--- a/python/mozbuild/mozbuild/test/test_util.py +++ b/python/mozbuild/mozbuild/test/test_util.py @@ -25,17 +25,16 @@ from mozbuild.util import ( group_unified_files, hash_file, memoize, memoized_property, pair, resolve_target_to_make, MozbuildDeletionError, HierarchicalStringList, - HierarchicalStringListWithFlagsFactory, StrictOrderingOnAppendList, StrictOrderingOnAppendListWithFlagsFactory, TypedList, TypedNamedTuple, UnsortedError, ) if sys.version_info[0] == 3: @@ -449,75 +448,16 @@ class TestStrictOrderingOnAppendListWith l['b'].update(foo=False, bar=12) self.assertEqual(l['b'].foo, False) self.assertEqual(l['b'].bar, 12) with self.assertRaises(AttributeError): l['b'].update(xyz=1) -class TestHierarchicalStringListWithFlagsFactory(unittest.TestCase): - def test_hierarchical_string_list_with_flags_factory(self): - cls = HierarchicalStringListWithFlagsFactory({ - 'foo': bool, - 'bar': int, - }) - - l = cls() - l += ['a', 'b'] - - with self.assertRaises(Exception): - l['a'] = 'foo' - - with self.assertRaises(Exception): - c = l['c'] - - self.assertEqual(l['a'].foo, False) - l['a'].foo = True - self.assertEqual(l['a'].foo, True) - - with self.assertRaises(TypeError): - l['a'].bar = 'bar' - - self.assertEqual(l['a'].bar, 0) - l['a'].bar = 42 - self.assertEqual(l['a'].bar, 42) - - l['b'].foo = True - self.assertEqual(l['b'].foo, True) - - with self.assertRaises(AttributeError): - l['b'].baz = False - - l.x += ['x', 'y'] - - with self.assertRaises(Exception): - l.x['x'] = 'foo' - - with self.assertRaises(Exception): - c = l.x['c'] - - self.assertEqual(l.x['x'].foo, False) - l.x['x'].foo = True - self.assertEqual(l.x['x'].foo, True) - - with self.assertRaises(TypeError): - l.x['x'].bar = 'bar' - - self.assertEqual(l.x['x'].bar, 0) - l.x['x'].bar = 42 - self.assertEqual(l.x['x'].bar, 42) - - l.x['y'].foo = True - self.assertEqual(l.x['y'].foo, True) - - with self.assertRaises(AttributeError): - l.x['y'].baz = False - - class TestMemoize(unittest.TestCase): def test_memoize(self): self._count = 0 @memoize def wrapped(a, b): self._count += 1 return a + b
--- a/python/mozbuild/mozbuild/util.py +++ b/python/mozbuild/mozbuild/util.py @@ -491,39 +491,24 @@ class HierarchicalStringList(object): self._hsl = hsl def __getitem__(self, index): return self._hsl._strings[index] def __len__(self): return len(self._hsl._strings) - def flags_for(self, value): - try: - # Solely for the side-effect of throwing AttributeError - object.__getattribute__(self._hsl, '__flag_slots__') - # We now know we have a HierarchicalStringListWithFlags. - # Get the flags, but use |get| so we don't create the - # flags if they're not already there. - return self._hsl._flags.get(value, None) - except AttributeError: - return None - def walk(self): """Walk over all HierarchicalStringLists in the hierarchy. This is a generator of (path, sequence). The path is '' for the root level and '/'-delimited strings for any descendants. The sequence is a read-only sequence of the - strings contained at that level. To support accessing the flags - for a given string (e.g. when walking over a - HierarchicalStringListWithFlagsFactory), the sequence supports a - flags_for() method. Given a string, the flags_for() method returns - the flags for the string, if any, or None if there are no flags set. + strings contained at that level. """ if self._strings: path_to_here = '' yield path_to_here, self.StringListAdaptor(self) for k, l in sorted(self._children.items()): for p, v in l.walk(): @@ -594,68 +579,16 @@ class HierarchicalStringList(object): if not isinstance(value, list): raise ValueError('Expected a list of strings, not %s' % type(value)) for v in value: if not isinstance(v, str_type): raise ValueError( 'Expected a list of strings, not an element of %s' % type(v)) -def HierarchicalStringListWithFlagsFactory(flags): - """Returns a HierarchicalStringList-like object, with optional - flags on each item. - - The flags are defined in the dict given as argument, where keys are - the flag names, and values the type used for the value of that flag. - - Example: - FooList = HierarchicalStringListWithFlagsFactory({ - 'foo': bool, 'bar': unicode - }) - foo = FooList(['a', 'b', 'c']) - foo['a'].foo = True - foo['b'].bar = 'bar' - foo.sub = ['x, 'y'] - foo.sub['x'].foo = False - foo.sub['y'].bar = 'baz' - """ - class HierarchicalStringListWithFlags(HierarchicalStringList): - __flag_slots__ = ('_flags_type', '_flags') - - def __init__(self): - HierarchicalStringList.__init__(self) - self._flags_type = FlagsFactory(flags) - self._flags = dict() - - def __setattr__(self, name, value): - if name in self.__flag_slots__: - return object.__setattr__(self, name, value) - HierarchicalStringList.__setattr__(self, name, value) - - def __getattr__(self, name): - if name in self.__flag_slots__: - return object.__getattr__(self, name) - return HierarchicalStringList.__getattr__(self, name) - - def __getitem__(self, name): - if name not in self._flags: - if name not in self._strings: - raise KeyError("'%s'" % name) - self._flags[name] = self._flags_type() - return self._flags[name] - - def __setitem__(self, name, value): - raise TypeError("'%s' object does not support item assignment" % - self.__class__.__name__) - - def _get_exportvariable(self, name): - return self._children.setdefault(name, HierarchicalStringListWithFlags()) - - return HierarchicalStringListWithFlags - class LockFile(object): """LockFile is used by the lock_file method to hold the lock. This object should not be used directly, but only through the lock_file method below. """ def __init__(self, lockfile):