Bug 1261283 - allow GENERATED_FILES to write to multiple outputs; r=glandium

MozReview-Commit-ID: DbBoZZnasTo
This commit is contained in:
Mike Shal 2016-04-01 10:38:22 -04:00
Родитель 8d5d5a9811
Коммит a1f020d488
7 изменённых файлов: 30 добавлений и 21 удалений

Просмотреть файл

@ -509,16 +509,20 @@ class RecursiveMakeBackend(CommonBackend):
elif isinstance(obj, GeneratedFile):
tier = 'misc' if any(isinstance(f, ObjDirPath) for f in obj.inputs) else 'export'
self._no_skip[tier].add(backend_file.relobjdir)
dep_file = "%s.pp" % obj.output
backend_file.write('%s:: %s\n' % (tier, obj.output))
backend_file.write('GARBAGE += %s\n' % obj.output)
first_output = obj.outputs[0]
dep_file = "%s.pp" % first_output
backend_file.write('%s:: %s\n' % (tier, first_output))
for output in obj.outputs:
if output != first_output:
backend_file.write('%s: %s ;\n' % (output, first_output))
backend_file.write('GARBAGE += %s\n' % output)
backend_file.write('EXTRA_MDDEPEND_FILES += %s\n' % dep_file)
if obj.script:
backend_file.write("""{output}: {script}{inputs}{backend}
\t$(REPORT_BUILD)
\t$(call py_action,file_generate,{script} {method} {output} $(MDDEPDIR)/{dep_file}{inputs}{flags})
""".format(output=obj.output,
""".format(output=first_output,
dep_file=dep_file,
inputs=' ' + ' '.join([f.full_path for f in obj.inputs]) if obj.inputs else '',
flags=' ' + ' '.join(obj.flags) if obj.flags else '',

Просмотреть файл

@ -912,16 +912,16 @@ class GeneratedFile(ContextDerived):
__slots__ = (
'script',
'method',
'output',
'outputs',
'inputs',
'flags',
)
def __init__(self, context, script, method, output, inputs, flags=()):
def __init__(self, context, script, method, outputs, inputs, flags=()):
ContextDerived.__init__(self, context)
self.script = script
self.method = method
self.output = output
self.outputs = outputs if isinstance(outputs, tuple) else (outputs,)
self.inputs = inputs
self.flags = flags

Просмотреть файл

@ -785,7 +785,8 @@ class TreeMetadataEmitter(LoggingMixin):
generated_files = set()
for obj in self._process_generated_files(context):
generated_files.add(obj.output)
for f in obj.outputs:
generated_files.add(f)
yield obj
for path in context['CONFIGURE_SUBST_FILES']:
@ -1005,7 +1006,7 @@ class TreeMetadataEmitter(LoggingMixin):
for f in generated_files:
flags = generated_files[f]
output = f
outputs = f
inputs = []
if flags.script:
method = "main"
@ -1036,7 +1037,7 @@ class TreeMetadataEmitter(LoggingMixin):
else:
script = None
method = None
yield GeneratedFile(context, script, method, output, inputs)
yield GeneratedFile(context, script, method, outputs, inputs)
def _process_test_manifests(self, context):
for prefix, info in TEST_MANIFESTS.items():

Просмотреть файл

@ -2,4 +2,4 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
GENERATED_FILES += [ 'bar.c', 'foo.c' ]
GENERATED_FILES += [ 'bar.c', 'foo.c', ('xpidllex.py', 'xpidlyacc.py'), ]

Просмотреть файл

@ -229,13 +229,14 @@ class TestEmitterBasic(unittest.TestCase):
reader = self.reader('generated-files')
objs = self.read_topsrcdir(reader)
self.assertEqual(len(objs), 2)
self.assertEqual(len(objs), 3)
for o in objs:
self.assertIsInstance(o, GeneratedFile)
expected = ['bar.c', 'foo.c']
for o, expected_filename in zip(objs, expected):
self.assertEqual(o.output, expected_filename)
expected = ['bar.c', 'foo.c', ('xpidllex.py', 'xpidlyacc.py'), ]
for o, f in zip(objs, expected):
expected_filename = f if isinstance(f, tuple) else (f,)
self.assertEqual(o.outputs, expected_filename)
self.assertEqual(o.script, None)
self.assertEqual(o.method, None)
self.assertEqual(o.inputs, [])
@ -251,7 +252,7 @@ class TestEmitterBasic(unittest.TestCase):
expected = ['bar.c', 'foo.c']
expected_method_names = ['make_bar', 'main']
for o, expected_filename, expected_method in zip(objs, expected, expected_method_names):
self.assertEqual(o.output, expected_filename)
self.assertEqual(o.outputs, (expected_filename,))
self.assertEqual(o.method, expected_method)
self.assertEqual(o.inputs, [])
@ -263,7 +264,7 @@ class TestEmitterBasic(unittest.TestCase):
o = objs[0]
self.assertIsInstance(o, GeneratedFile)
self.assertEqual(o.output, 'bar.c')
self.assertEqual(o.outputs, ('bar.c',))
self.assertRegexpMatches(o.script, 'script.py$')
self.assertEqual(o.method, 'make_bar')
self.assertEqual(o.inputs, [])

Просмотреть файл

@ -416,7 +416,11 @@ class StrictOrderingOnAppendListMixin(object):
if isinstance(l, StrictOrderingOnAppendList):
return
srtd = sorted(l, key=lambda x: x.lower())
def _first_element(e):
# If the list entry is a tuple, we sort based on the first element
# in the tuple.
return e[0] if isinstance(e, tuple) else e
srtd = sorted(l, key=lambda x: _first_element(x).lower())
if srtd != l:
raise UnsortedError(srtd, l)

Просмотреть файл

@ -9,11 +9,10 @@ PYTHON_UNIT_TESTS += [
]
GENERATED_FILES += [
'xpidllex.py',
'xpidlyacc.py',
('xpidllex.py', 'xpidlyacc.py'),
]
GENERATED_FILES['xpidllex.py'].script = 'header.py:main'
GENERATED_FILES[('xpidllex.py', 'xpidlyacc.py')].script = 'header.py:main'
SDK_FILES.bin += [
'!xpidllex.py',