本文整理汇总了Python中mozbuild.frontend.emitter.TreeMetadataEmitter类的典型用法代码示例。如果您正苦于以下问题:Python TreeMetadataEmitter类的具体用法?Python TreeMetadataEmitter怎么用?Python TreeMetadataEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeMetadataEmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_traversal_all_vars
def test_traversal_all_vars(self):
reader = self.reader('traversal-all-vars')
emitter = TreeMetadataEmitter(reader.config)
objs = list(emitter.emit(reader.read_topsrcdir()))
self.assertEqual(len(objs), 6)
for o in objs:
self.assertIsInstance(o, DirectoryTraversal)
reldirs = set([o.relativedir for o in objs])
self.assertEqual(reldirs, set(['', 'parallel', 'regular', 'test',
'test_tool', 'tool']))
for o in objs:
reldir = o.relativedir
if reldir == '':
self.assertEqual(o.dirs, ['regular'])
self.assertEqual(o.parallel_dirs, ['parallel'])
self.assertEqual(o.test_dirs, ['test'])
self.assertEqual(o.test_tool_dirs, ['test_tool'])
self.assertEqual(o.tool_dirs, ['tool'])
self.assertEqual(o.external_make_dirs, ['external_make'])
self.assertEqual(o.parallel_external_make_dirs,
['parallel_external_make'])
示例2: _emit
def _emit(self, name, env=None):
if not env:
env = self._get_environment(name)
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
return env, emitter.emit(reader.read_topsrcdir())
示例3: test_tier_simple
def test_tier_simple(self):
reader = self.reader('traversal-tier-simple')
emitter = TreeMetadataEmitter(reader.config)
objs = list(emitter.emit(reader.read_topsrcdir()))
self.assertEqual(len(objs), 4)
reldirs = [o.relativedir for o in objs]
self.assertEqual(reldirs, ['', 'foo', 'foo/biz', 'bar'])
示例4: read_topsrcdir
def read_topsrcdir(self, reader, filter_common=True):
emitter = TreeMetadataEmitter(reader.config)
objs = list(emitter.emit(reader.read_topsrcdir()))
self.assertGreater(len(objs), 0)
filtered = []
for obj in objs:
if filter_common and isinstance(obj, DirectoryTraversal):
continue
filtered.append(obj)
return filtered
示例5: test_config_file_substitution
def test_config_file_substitution(self):
reader = self.reader('config-file-substitution')
emitter = TreeMetadataEmitter(reader.config)
objs = list(emitter.emit(reader.read_topsrcdir()))
self.assertEqual(len(objs), 3)
self.assertIsInstance(objs[0], DirectoryTraversal)
self.assertIsInstance(objs[1], ConfigFileSubstitution)
self.assertIsInstance(objs[2], ConfigFileSubstitution)
topobjdir = os.path.abspath(reader.config.topobjdir)
self.assertEqual(os.path.normpath(objs[1].output_path),
os.path.normpath(os.path.join(topobjdir, 'foo')))
self.assertEqual(os.path.normpath(objs[2].output_path),
os.path.normpath(os.path.join(topobjdir, 'bar')))
示例6: gen_test_backend
def gen_test_backend():
build_obj = MozbuildObject.from_environment()
try:
config = build_obj.config_environment
except BuildEnvironmentNotFoundException:
print("No build detected, test metadata may be incomplete.")
config = EmptyConfig(build_obj.topsrcdir)
config.topobjdir = build_obj.topobjdir
reader = BuildReader(config)
emitter = TreeMetadataEmitter(config)
backend = TestManifestBackend(config)
context = reader.read_topsrcdir()
data = emitter.emit(context, emitfn=emitter._process_test_manifests)
backend.consume(data)
示例7: test_mtime_no_change
def test_mtime_no_change(self):
"""Ensure mtime is not updated if file content does not change."""
env = self._consume('stub0', RecursiveMakeBackend)
makefile_path = mozpath.join(env.topobjdir, 'Makefile')
backend_path = mozpath.join(env.topobjdir, 'backend.mk')
makefile_mtime = os.path.getmtime(makefile_path)
backend_mtime = os.path.getmtime(backend_path)
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
backend = RecursiveMakeBackend(env)
backend.consume(emitter.emit(reader.read_topsrcdir()))
self.assertEqual(os.path.getmtime(makefile_path), makefile_mtime)
self.assertEqual(os.path.getmtime(backend_path), backend_mtime)
示例8: do_test_backend
def do_test_backend(self, *backends, **kwargs):
topobjdir = mkdtemp()
try:
config = ConfigEnvironment(buildconfig.topsrcdir, topobjdir,
**kwargs)
reader = BuildReader(config)
emitter = TreeMetadataEmitter(config)
moz_build = mozpath.join(config.topsrcdir, 'test.mozbuild')
definitions = list(emitter.emit(
reader.read_mozbuild(moz_build, config)))
for backend in backends:
backend(config).consume(definitions)
yield config
except:
raise
finally:
if not os.environ.get('MOZ_NO_CLEANUP'):
shutil.rmtree(topobjdir)
示例9: read_topsrcdir
def read_topsrcdir(self, reader, filter_common=True):
emitter = TreeMetadataEmitter(reader.config)
def ack(obj):
obj.ack()
return obj
objs = list(ack(o) for o in emitter.emit(reader.read_topsrcdir()))
self.assertGreater(len(objs), 0)
self.assertIsInstance(objs[-1], ReaderSummary)
filtered = []
for obj in objs:
if filter_common and isinstance(obj, DirectoryTraversal):
continue
# Always filter ReaderSummary because it's asserted above.
if isinstance(obj, ReaderSummary):
continue
filtered.append(obj)
return filtered
示例10: gen_test_backend
def gen_test_backend():
build_obj = MozbuildObject.from_environment()
try:
config = build_obj.config_environment
except BuildEnvironmentNotFoundException:
print("No build detected, test metadata may be incomplete.")
# If 'JS_STANDALONE' is set, tests that don't require an objdir won't
# be picked up due to bug 1345209.
substs = EmptyConfig.default_substs
if 'JS_STANDALONE' in substs:
del substs['JS_STANDALONE']
config = EmptyConfig(build_obj.topsrcdir, substs)
config.topobjdir = build_obj.topobjdir
reader = BuildReader(config)
emitter = TreeMetadataEmitter(config)
backend = TestManifestBackend(config)
context = reader.read_topsrcdir()
data = emitter.emit(context, emitfn=emitter._process_test_manifests)
backend.consume(data)
示例11: config_status
def config_status(topobjdir='.', topsrcdir='.', defines=None,
non_global_defines=None, substs=None, source=None,
mozconfig=None):
'''Main function, providing config.status functionality.
Contrary to config.status, it doesn't use CONFIG_FILES or CONFIG_HEADERS
variables.
Without the -n option, this program acts as config.status and considers
the current directory as the top object directory, even when config.status
is in a different directory. It will, however, treat the directory
containing config.status as the top object directory with the -n option.
The options to this function are passed when creating the
ConfigEnvironment. These lists, as well as the actual wrapper script
around this function, are meant to be generated by configure.
See build/autoconf/config.status.m4.
'''
if 'CONFIG_FILES' in os.environ:
raise Exception('Using the CONFIG_FILES environment variable is not '
'supported.')
if 'CONFIG_HEADERS' in os.environ:
raise Exception('Using the CONFIG_HEADERS environment variable is not '
'supported.')
if not os.path.isabs(topsrcdir):
raise Exception('topsrcdir must be defined as an absolute directory: '
'%s' % topsrcdir)
default_backends = ['RecursiveMake']
default_backends = (substs or {}).get('BUILD_BACKENDS', ['RecursiveMake'])
parser = ArgumentParser()
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
help='display verbose output')
parser.add_argument('-n', dest='not_topobjdir', action='store_true',
help='do not consider current directory as top object directory')
parser.add_argument('-d', '--diff', action='store_true',
help='print diffs of changed files.')
parser.add_argument('-b', '--backend', nargs='+', choices=sorted(backends),
default=default_backends,
help='what backend to build (default: %s).' %
' '.join(default_backends))
parser.add_argument('--dry-run', action='store_true',
help='do everything except writing files out.')
options = parser.parse_args()
# Without -n, the current directory is meant to be the top object directory
if not options.not_topobjdir:
topobjdir = os.path.abspath('.')
env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
non_global_defines=non_global_defines, substs=substs,
source=source, mozconfig=mozconfig)
# mozinfo.json only needs written if configure changes and configure always
# passes this environment variable.
if 'WRITE_MOZINFO' in os.environ:
write_mozinfo(os.path.join(topobjdir, 'mozinfo.json'), env, os.environ)
cpu_start = time.clock()
time_start = time.time()
# Make appropriate backend instances, defaulting to RecursiveMakeBackend,
# or what is in BUILD_BACKENDS.
selected_backends = [get_backend_class(b)(env) for b in options.backend]
if options.dry_run:
for b in selected_backends:
b.dry_run = True
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
# This won't actually do anything because of the magic of generators.
definitions = emitter.emit(reader.read_topsrcdir())
log_level = logging.DEBUG if options.verbose else logging.INFO
log_manager.add_terminal_logging(level=log_level)
log_manager.enable_unstructured()
print('Reticulating splines...', file=sys.stderr)
if len(selected_backends) > 1:
definitions = list(definitions)
for the_backend in selected_backends:
the_backend.consume(definitions)
execution_time = 0.0
for obj in chain((reader, emitter), selected_backends):
summary = obj.summary()
print(summary, file=sys.stderr)
execution_time += summary.execution_time
cpu_time = time.clock() - cpu_start
wall_time = time.time() - time_start
efficiency = cpu_time / wall_time if wall_time else 100
untracked = wall_time - execution_time
print(
#.........这里部分代码省略.........
示例12: config_status
#.........这里部分代码省略.........
# Without -n, the current directory is meant to be the top object directory
if not options.not_topobjdir:
topobjdir = os.path.abspath('.')
env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
non_global_defines=non_global_defines, substs=substs, source=source)
# mozinfo.json only needs written if configure changes and configure always
# passes this environment variable.
if 'WRITE_MOZINFO' in os.environ:
write_mozinfo(os.path.join(topobjdir, 'mozinfo.json'), env, os.environ)
# Make an appropriate backend instance, defaulting to RecursiveMakeBackend.
backends_cls = []
for backend in options.backend:
if backend == 'AndroidEclipse':
from mozbuild.backend.android_eclipse import AndroidEclipseBackend
if not MachCommandConditions.is_android(env):
raise Exception('The Android Eclipse backend is not available with this configuration.')
backends_cls.append(AndroidEclipseBackend)
elif backend == 'CppEclipse':
from mozbuild.backend.cpp_eclipse import CppEclipseBackend
backends_cls.append(CppEclipseBackend)
if os.name == 'nt':
raise Exception('Eclipse is not supported on Windows. Consider using Visual Studio instead.')
elif backend == 'VisualStudio':
from mozbuild.backend.visualstudio import VisualStudioBackend
backends_cls.append(VisualStudioBackend)
elif backend == 'FasterMake':
from mozbuild.backend.fastermake import FasterMakeBackend
backends_cls.append(FasterMakeBackend)
elif backend == 'CompileDB':
from mozbuild.compilation.database import CompileDBBackend
backends_cls.append(CompileDBBackend)
else:
backends_cls.append(RecursiveMakeBackend)
cpu_start = time.clock()
time_start = time.time()
backends = [cls(env) for cls in backends_cls]
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
# This won't actually do anything because of the magic of generators.
definitions = emitter.emit(reader.read_topsrcdir())
if options.recheck:
# Execute configure from the top object directory
os.chdir(topobjdir)
os.execlp('sh', 'sh', '-c', ' '.join([os.path.join(topsrcdir, 'configure'), env.substs['ac_configure_args'], '--no-create', '--no-recursion']))
log_level = logging.DEBUG if options.verbose else logging.INFO
log_manager.add_terminal_logging(level=log_level)
log_manager.enable_unstructured()
print('Reticulating splines...', file=sys.stderr)
if len(backends) > 1:
definitions = list(definitions)
for the_backend in backends:
the_backend.consume(definitions)
execution_time = 0.0
for obj in chain((reader, emitter), backends):
summary = obj.summary()
print(summary, file=sys.stderr)
execution_time += summary.execution_time
cpu_time = time.clock() - cpu_start
wall_time = time.time() - time_start
efficiency = cpu_time / wall_time if wall_time else 100
untracked = wall_time - execution_time
print(
'Total wall time: {:.2f}s; CPU time: {:.2f}s; Efficiency: '
'{:.0%}; Untracked: {:.2f}s'.format(
wall_time, cpu_time, efficiency, untracked),
file=sys.stderr
)
if options.diff:
for the_backend in backends:
for path, diff in sorted(the_backend.file_diffs.items()):
print('\n'.join(diff))
# Advertise Visual Studio if appropriate.
if os.name == 'nt' and 'VisualStudio' not in options.backend:
print(VISUAL_STUDIO_ADVERTISEMENT)
# Advertise Eclipse if it is appropriate.
if MachCommandConditions.is_android(env):
if 'AndroidEclipse' not in options.backend:
print(ANDROID_IDE_ADVERTISEMENT)
if env.substs.get('MOZ_ARTIFACT_BUILDS', False):
# Execute |mach artifact install| from the top source directory.
os.chdir(topsrcdir)
return subprocess.check_call([sys.executable, os.path.join(topsrcdir, 'mach'), 'artifact', 'install'])
示例13: config_status
def config_status(topobjdir = '.', topsrcdir = '.',
defines = [], non_global_defines = [], substs = [],
files = [], headers = []):
'''Main function, providing config.status functionality.
Contrary to config.status, it doesn't use CONFIG_FILES or CONFIG_HEADERS
variables, but like config.status from autoconf 2.6, single files may be
generated with the --file and --header options. Several such options can
be given to generate several files at the same time.
Without the -n option, this program acts as config.status and considers
the current directory as the top object directory, even when config.status
is in a different directory. It will, however, treat the directory
containing config.status as the top object directory with the -n option,
while files given to the --file and --header arguments are considered
relative to the current directory.
The --recheck option, like with the original config.status, runs configure
again, with the options given in the "ac_configure_args" subst.
The options to this function are passed when creating the
ConfigEnvironment, except for files and headers, which contain the list
of files and headers to be generated by default. These lists, as well as
the actual wrapper script around this function, are meant to be generated
by configure. See build/autoconf/config.status.m4.
Unlike config.status behaviour with CONFIG_FILES and CONFIG_HEADERS,
but like config.status behaviour with --file and --header, providing
files or headers on the command line inhibits the default generation of
files when given headers and headers when given files.
Unlike config.status, the FILE:TEMPLATE syntax is not supported for
files and headers. The template is always the filename suffixed with
'.in', in the corresponding directory under the top source directory.
'''
if 'CONFIG_FILES' in os.environ:
raise Exception, 'Using the CONFIG_FILES environment variable is not supported. Use --file instead.'
if 'CONFIG_HEADERS' in os.environ:
raise Exception, 'Using the CONFIG_HEADERS environment variable is not supported. Use --header instead.'
parser = OptionParser()
parser.add_option('--recheck', dest='recheck', action='store_true',
help='update config.status by reconfiguring in the same conditions')
parser.add_option('--file', dest='files', metavar='FILE', action='append',
help='instantiate the configuration file FILE')
parser.add_option('--header', dest='headers', metavar='FILE', action='append',
help='instantiate the configuration header FILE')
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
help='display verbose output')
parser.add_option('-n', dest='not_topobjdir', action='store_true',
help='do not consider current directory as top object directory')
(options, args) = parser.parse_args()
# Without -n, the current directory is meant to be the top object directory
if not options.not_topobjdir:
topobjdir = '.'
env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
non_global_defines=non_global_defines, substs=substs)
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
backend = RecursiveMakeBackend(env)
# This won't actually do anything because of the magic of generators.
definitions = emitter.emit(reader.read_topsrcdir())
if options.recheck:
# Execute configure from the top object directory
if not os.path.isabs(topsrcdir):
topsrcdir = relpath(topsrcdir, topobjdir)
os.chdir(topobjdir)
os.execlp('sh', 'sh', '-c', ' '.join([os.path.join(topsrcdir, 'configure'), env.substs['ac_configure_args'], '--no-create', '--no-recursion']))
if options.files:
files = options.files
headers = []
if options.headers:
headers = options.headers
if not options.files:
files = []
# Default to display messages when giving --file or --headers on the
# command line.
log_level = logging.INFO
if options.files or options.headers or options.verbose:
log_level = logging.DEBUG
log_manager.add_terminal_logging(level=log_level)
log_manager.enable_unstructured()
if not options.files and not options.headers:
print('Reticulating splines...', file=sys.stderr)
summary = backend.consume(definitions)
for line in summary.summaries():
print(line, file=sys.stderr)
files = [os.path.join(topobjdir, f) for f in files]
headers = [os.path.join(topobjdir, f) for f in headers]
#.........这里部分代码省略.........
示例14: config_status
def config_status(topobjdir='.', topsrcdir='.',
defines=[], non_global_defines=[], substs=[], source=None):
'''Main function, providing config.status functionality.
Contrary to config.status, it doesn't use CONFIG_FILES or CONFIG_HEADERS
variables.
Without the -n option, this program acts as config.status and considers
the current directory as the top object directory, even when config.status
is in a different directory. It will, however, treat the directory
containing config.status as the top object directory with the -n option.
The --recheck option, like with the original config.status, runs configure
again, with the options given in the "ac_configure_args" subst.
The options to this function are passed when creating the
ConfigEnvironment. These lists, as well as the actual wrapper script
around this function, are meant to be generated by configure.
See build/autoconf/config.status.m4.
'''
if 'CONFIG_FILES' in os.environ:
raise Exception('Using the CONFIG_FILES environment variable is not '
'supported.')
if 'CONFIG_HEADERS' in os.environ:
raise Exception('Using the CONFIG_HEADERS environment variable is not '
'supported.')
if not os.path.isabs(topsrcdir):
raise Exception('topsrcdir must be defined as an absolute directory: '
'%s' % topsrcdir)
parser = OptionParser()
parser.add_option('--recheck', dest='recheck', action='store_true',
help='update config.status by reconfiguring in the same conditions')
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
help='display verbose output')
parser.add_option('-n', dest='not_topobjdir', action='store_true',
help='do not consider current directory as top object directory')
parser.add_option('-d', '--diff', action='store_true',
help='print diffs of changed files.')
options, args = parser.parse_args()
# Without -n, the current directory is meant to be the top object directory
if not options.not_topobjdir:
topobjdir = os.path.abspath('.')
env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
non_global_defines=non_global_defines, substs=substs, source=source)
# mozinfo.json only needs written if configure changes and configure always
# passes this environment variable.
if 'WRITE_MOZINFO' in os.environ:
write_mozinfo(os.path.join(topobjdir, 'mozinfo.json'), env, os.environ)
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
backend = RecursiveMakeBackend(env)
# This won't actually do anything because of the magic of generators.
definitions = emitter.emit(reader.read_topsrcdir())
if options.recheck:
# Execute configure from the top object directory
os.chdir(topobjdir)
os.execlp('sh', 'sh', '-c', ' '.join([os.path.join(topsrcdir, 'configure'), env.substs['ac_configure_args'], '--no-create', '--no-recursion']))
log_level = logging.DEBUG if options.verbose else logging.INFO
log_manager.add_terminal_logging(level=log_level)
log_manager.enable_unstructured()
print('Reticulating splines...', file=sys.stderr)
summary = backend.consume(definitions)
for line in summary.summaries():
print(line, file=sys.stderr)
if options.diff:
for path, diff in sorted(summary.file_diffs.items()):
print(diff)
示例15: config_status
#.........这里部分代码省略.........
dest="not_topobjdir",
action="store_true",
help="do not consider current directory as top object directory",
)
parser.add_option("-d", "--diff", action="store_true", help="print diffs of changed files.")
parser.add_option(
"-b",
"--backend",
choices=["RecursiveMake", "AndroidEclipse", "CppEclipse", "VisualStudio", "Build", "ForceBuild"],
default="Build",
help="what backend to build (default: RecursiveMake).",
)
options, args = parser.parse_args()
# Without -n, the current directory is meant to be the top object directory
if not options.not_topobjdir:
topobjdir = os.path.abspath(".")
env = ConfigEnvironment(
topsrcdir, topobjdir, defines=defines, non_global_defines=non_global_defines, substs=substs, source=source
)
# mozinfo.json only needs written if configure changes and configure always
# passes this environment variable.
if "WRITE_MOZINFO" in os.environ:
write_mozinfo(os.path.join(topobjdir, "mozinfo.json"), env, os.environ)
# Make an appropriate backend instance, defaulting to RecursiveMakeBackend.
backend_cls = RecursiveMakeBackend
if options.backend == "AndroidEclipse":
from mozbuild.backend.android_eclipse import AndroidEclipseBackend
if not MachCommandConditions.is_android(env):
raise Exception("The Android Eclipse backend is not available with this configuration.")
backend_cls = AndroidEclipseBackend
elif options.backend == "CppEclipse":
from mozbuild.backend.cpp_eclipse import CppEclipseBackend
backend_cls = CppEclipseBackend
if os.name == "nt":
raise Exception("Eclipse is not supported on Windows. Consider using Visual Studio instead.")
elif options.backend == "VisualStudio":
from mozbuild.backend.visualstudio import VisualStudioBackend
backend_cls = VisualStudioBackend
elif options.backend == "Build":
from mozbuild.backend.visualstudio import VisualStudioBackend
backend_cls = VisualStudioBackend
elif options.backend == "ForceBuild":
from mozbuild.backend.visualstudio import VisualStudioBackend
backend_cls = VisualStudioBackend
the_backend = backend_cls(env)
if options.backend == "Build":
if the_backend.try_build():
return
elif options.backend == "ForceBuild":
the_backend.full_build()
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
# This won't actually do anything because of the magic of generators.
definitions = emitter.emit(reader.read_topsrcdir())
if options.recheck:
# Execute configure from the top object directory
os.chdir(topobjdir)
os.execlp(
"sh",
"sh",
"-c",
" ".join(
[os.path.join(topsrcdir, "configure"), env.substs["ac_configure_args"], "--no-create", "--no-recursion"]
),
)
log_level = logging.DEBUG if options.verbose else logging.INFO
log_manager.add_terminal_logging(level=log_level)
log_manager.enable_unstructured()
print("Reticulating splines...", file=sys.stderr)
summary = the_backend.consume(definitions)
for line in summary.summaries():
print(line, file=sys.stderr)
if options.diff:
for path, diff in sorted(summary.file_diffs.items()):
print("\n".join(diff))
# Advertise Visual Studio if appropriate.
if os.name == "nt" and options.backend == "RecursiveMake":
print(VISUAL_STUDIO_ADVERTISEMENT)
# Advertise Eclipse if it is appropriate.
if MachCommandConditions.is_android(env):
if options.backend == "RecursiveMake":
print(ANDROID_IDE_ADVERTISEMENT)