mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1297718 - Add config.status to sys.modules for dependency detection; r=glandium
MozReview-Commit-ID: J5WaTPYc0vJ
This commit is contained in:
parent
37ce88ab1c
commit
42ab09bca2
@ -61,18 +61,34 @@ 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:
|
||||
ret |= set(iter_modules_in_path(buildconfig.topsrcdir,
|
||||
buildconfig.topobjdir))
|
||||
mk = Makefile()
|
||||
mk.create_rule([args.output_file]).add_dependencies(ret)
|
||||
with FileAvoidWrite(args.dep_file) as dep_file:
|
||||
mk.dump(dep_file)
|
||||
# The following values indicate a statement of success:
|
||||
# - a set() (see below)
|
||||
# - 0
|
||||
# - False
|
||||
# - None
|
||||
#
|
||||
# Everything else is an error (so scripts can conveniently |return
|
||||
# 1| or similar). If a set is returned, the elements of the set
|
||||
# indicate additional dependencies that will be listed in the deps
|
||||
# file. Python module imports are automatically included as
|
||||
# dependencies.
|
||||
if isinstance(ret, set):
|
||||
deps = ret
|
||||
# The script succeeded, so reset |ret| to indicate that.
|
||||
ret = None
|
||||
else:
|
||||
deps = set()
|
||||
|
||||
# Only write out the dependencies if the script was successful
|
||||
if not ret:
|
||||
# Add dependencies on any python modules that were imported by
|
||||
# the script.
|
||||
deps |= set(iter_modules_in_path(buildconfig.topsrcdir,
|
||||
buildconfig.topobjdir))
|
||||
mk = Makefile()
|
||||
mk.create_rule([args.output_file]).add_dependencies(deps)
|
||||
with FileAvoidWrite(args.dep_file) as dep_file:
|
||||
mk.dump(dep_file)
|
||||
# Even when our file's contents haven't changed, we want to update
|
||||
# the file's mtime so make knows this target isn't still older than
|
||||
# whatever prerequisite caused it to be built this time around.
|
||||
|
@ -8,7 +8,7 @@ import os
|
||||
import sys
|
||||
|
||||
from collections import Iterable
|
||||
from types import StringTypes
|
||||
from types import StringTypes, ModuleType
|
||||
|
||||
import mozpack.path as mozpath
|
||||
|
||||
@ -45,6 +45,12 @@ class BuildConfig(object):
|
||||
# cache the compiled code as it can be reused
|
||||
# we cache it the first time, or if the file changed
|
||||
if not path in code_cache or code_cache[path][0] != mtime:
|
||||
# Add config.status manually to sys.modules so it gets picked up by
|
||||
# iter_modules_in_path() for automatic dependencies.
|
||||
mod = ModuleType('config.status')
|
||||
mod.__file__ = path
|
||||
sys.modules['config.status'] = mod
|
||||
|
||||
with open(path, 'rt') as fh:
|
||||
source = fh.read()
|
||||
code_cache[path] = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user