Bug 1215526 - part 2 - write dependencies to file_generate.py's depfile; r=glandium

This commit is contained in:
Nathan Froyd 2015-10-21 10:36:08 -04:00
Родитель 8bd1afc6a9
Коммит 3a6f416c97
2 изменённых файлов: 14 добавлений и 0 удалений

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

@ -15,6 +15,7 @@ import sys
import traceback
from mozbuild.util import FileAvoidWrite
from mozbuild.makeutil import Makefile
def main(argv):
parser = argparse.ArgumentParser('Generate a file from a Python script',
@ -56,6 +57,16 @@ def main(argv):
try:
with FileAvoidWrite(args.output_file) as output:
ret = module.__dict__[method](output, *args.additional_arguments)
# We treat sets as a statement of success. Everything else
# is an error (so scripts can conveniently |return 1| or
# similar).
if isinstance(ret, set) and ret:
mk = Makefile()
mk.create_rule([args.output_file]).add_dependencies(ret)
with FileAvoidWrite(args.dep_file) as dep_file:
mk.dump(dep_file)
# The script succeeded, so reset |ret| to indicate that.
ret = None
except IOError as e:
print('Error opening file "{0}"'.format(e.filename), file=sys.stderr)
traceback.print_exc()

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

@ -907,6 +907,9 @@ VARIABLES = {
GENERATED_FILES += ['bar.c']
bar = GENERATED_FILES['bar.c']
bar.script = 'generate.py:make_bar'
The chosen script entry point may optionally return a set of strings,
indicating extra files the output depends on.
""", 'export'),
'DEFINES': (OrderedDict, dict,