本文整理汇总了Python中mozbuild.frontend.reader.BuildReader类的典型用法代码示例。如果您正苦于以下问题:Python BuildReader类的具体用法?Python BuildReader怎么用?Python BuildReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BuildReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_build_config
def read_build_config(self):
"""Read the active build config and add docs to this instance."""
# Reading the Sphinx variables doesn't require a full build context.
# Only define the parts we need.
class fakeconfig(object):
def __init__(self, topsrcdir):
self.topsrcdir = topsrcdir
config = fakeconfig(self._topsrcdir)
reader = BuildReader(config)
for path, name, key, value in reader.find_sphinx_variables():
reldir = os.path.dirname(path)
if name == 'SPHINX_TREES':
assert key
if key.startswith('/'):
key = key[1:]
else:
key = os.path.join(reldir, key)
self.add_tree(os.path.join(reldir, value), key)
if name == 'SPHINX_PYTHON_PACKAGE_DIRS':
self.add_python_package_dir(os.path.join(reldir, value))
示例2: find_paths_and_tags
def find_paths_and_tags(self, verbose):
paths, tags = set(), set()
changed_files = self.find_changed_files()
if changed_files:
if verbose:
print("Pushing tests based on modifications to the "
"following files:\n\t%s" % "\n\t".join(changed_files))
from mozbuild.frontend.reader import (
BuildReader,
EmptyConfig,
)
config = EmptyConfig(self.topsrcdir)
reader = BuildReader(config)
files_info = reader.files_info(changed_files)
for path, info in files_info.items():
paths |= info.test_files
tags |= info.test_tags
if verbose:
if paths:
print("Pushing tests based on the following patterns:\n\t%s" %
"\n\t".join(paths))
if tags:
print("Pushing tests based on the following tags:\n\t%s" %
"\n\t".join(tags))
return paths, tags
示例3: build_docs
def build_docs(self, format=None, outdir=None):
self._activate_virtualenv()
self.virtualenv_manager.install_pip_package('mdn-sphinx-theme==0.4')
from moztreedocs import SphinxManager
if outdir == '<DEFAULT>':
outdir = os.path.join(self.topobjdir, 'docs')
manager = SphinxManager(self.topsrcdir, os.path.join(self.topsrcdir,
'tools', 'docs'), outdir)
# We don't care about GYP projects, so don't process them. This makes
# scanning faster and may even prevent an exception.
def remove_gyp_dirs(context):
context['GYP_DIRS'][:] = []
reader = BuildReader(self.config_environment,
sandbox_post_eval_cb=remove_gyp_dirs)
for path, name, key, value in reader.find_sphinx_variables():
reldir = os.path.dirname(path)
if name == 'SPHINX_TREES':
assert key
manager.add_tree(os.path.join(reldir, value),
os.path.join(reldir, key))
if name == 'SPHINX_PYTHON_PACKAGE_DIRS':
manager.add_python_package_dir(os.path.join(reldir, value))
return manager.generate_docs(format)
示例4: build_docs
def build_docs(self, format=None, outdir=None):
self._activate_virtualenv()
self.virtualenv_manager.install_pip_package('mdn-sphinx-theme==0.4')
from moztreedocs import SphinxManager
if outdir == '<DEFAULT>':
outdir = os.path.join(self.topobjdir, 'docs')
manager = SphinxManager(self.topsrcdir, os.path.join(self.topsrcdir,
'tools', 'docs'), outdir)
# We don't care about GYP projects, so don't process them. This makes
# scanning faster and may even prevent an exception.
def remove_gyp_dirs(context):
context['GYP_DIRS'][:] = []
reader = BuildReader(self.config_environment,
sandbox_post_eval_cb=remove_gyp_dirs)
for context in reader.walk_topsrcdir():
for dest_dir, source_dir in context['SPHINX_TREES'].items():
manager.add_tree(os.path.join(context.relsrcdir,
source_dir), dest_dir)
for entry in context['SPHINX_PYTHON_PACKAGE_DIRS']:
manager.add_python_package_dir(os.path.join(context.relsrcdir,
entry))
return manager.generate_docs(format)
示例5: _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())
示例6: file_info_schedules
def file_info_schedules(self, paths):
"""Show what is scheduled by the given files.
Given a requested set of files (which can be specified using
wildcards), print the total set of scheduled components.
"""
from mozbuild.frontend.reader import EmptyConfig, BuildReader
config = EmptyConfig(TOPSRCDIR)
reader = BuildReader(config)
schedules = set()
for p, m in reader.files_info(paths).items():
schedules |= set(m['SCHEDULES'].components)
print(", ".join(schedules))
示例7: test_filesystem_traversal_reading
def test_filesystem_traversal_reading(self):
"""Reading moz.build according to filesystem traversal works.
We attempt to read every known moz.build file via filesystem traversal.
If this test fails, it means that metadata extraction will fail.
"""
mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False)
config = mb.config_environment
reader = BuildReader(config)
all_paths = self._mozbuilds(reader)
paths, contexts = reader.read_relevant_mozbuilds(all_paths)
self.assertEqual(set(paths), all_paths)
self.assertGreaterEqual(len(contexts), len(paths))
示例8: test_filesystem_traversal_no_config
def test_filesystem_traversal_no_config(self):
"""Reading moz.build files via filesystem traversal mode with no build config.
This is similar to the above test except no build config is applied.
This will likely fail in more scenarios than the above test because a
lot of moz.build files assumes certain variables are present.
"""
here = os.path.abspath(os.path.dirname(__file__))
root = os.path.normpath(os.path.join(here, '..', '..'))
config = EmptyConfig(root)
reader = BuildReader(config)
all_paths = self._mozbuilds(reader)
paths, contexts = reader.read_relevant_mozbuilds(all_paths)
self.assertEqual(set(paths.keys()), all_paths)
self.assertGreaterEqual(len(contexts), len(paths))
示例9: 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)
示例10: 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)
示例11: get_outgoing_metadata
def get_outgoing_metadata(self):
paths, tags, flavors = set(), set(), set()
changed_files = self.vcs.get_outgoing_files('AM')
if changed_files:
config = EmptyConfig(self.topsrcdir)
reader = BuildReader(config)
files_info = reader.files_info(changed_files)
for path, info in files_info.items():
paths |= info.test_files
tags |= info.test_tags
flavors |= info.test_flavors
return {
'paths': paths,
'tags': tags,
'flavors': flavors,
}
示例12: 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)
示例13: test_orphan_file_patterns
def test_orphan_file_patterns(self):
if sys.platform == 'win32':
raise unittest.SkipTest('failing on windows builds')
mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False)
try:
config = mb.config_environment
except Exception as e:
if e.message == 'config.status not available. Run configure.':
raise unittest.SkipTest('failing without config.status')
raise
if config.substs['MOZ_BUILD_APP'] == 'js':
raise unittest.SkipTest('failing in Spidermonkey builds')
reader = BuildReader(config)
all_paths = self._mozbuilds(reader)
_, contexts = reader.read_relevant_mozbuilds(all_paths)
finder = FileFinder(config.topsrcdir, find_executables=False,
ignore=['obj*'])
def pattern_exists(pat):
return [p for p in finder.find(pat)] != []
for ctx in contexts:
if not isinstance(ctx, Files):
continue
relsrcdir = ctx.relsrcdir
if not pattern_exists(os.path.join(relsrcdir, ctx.pattern)):
self.fail("The pattern '%s' in a Files() entry in "
"'%s' corresponds to no files in the tree.\n"
"Please update this entry." %
(ctx.pattern, ctx.main_path))
test_files = ctx['IMPACTED_TESTS'].files
for p in test_files:
if not pattern_exists(os.path.relpath(p.full_path, config.topsrcdir)):
self.fail("The pattern '%s' in a dependent tests entry "
"in '%s' corresponds to no files in the tree.\n"
"Please update this entry." %
(p, ctx.main_path))
示例14: build_docs
def build_docs(self, format=None, outdir=None):
self._activate_virtualenv()
self.virtualenv_manager.install_pip_package('sphinx_rtd_theme==0.1.6')
from moztreedocs import SphinxManager
if outdir == '<DEFAULT>':
outdir = os.path.join(self.topobjdir, 'docs')
manager = SphinxManager(self.topsrcdir, os.path.join(self.topsrcdir,
'tools', 'docs'), outdir)
# We don't care about GYP projects, so don't process them. This makes
# scanning faster and may even prevent an exception.
def remove_gyp_dirs(context):
context['GYP_DIRS'][:] = []
# Reading the Sphinx variables doesn't require a full build context.
# Only define the parts we need.
class fakeconfig(object):
def __init__(self, topsrcdir):
self.topsrcdir = topsrcdir
config = fakeconfig(self.topsrcdir)
reader = BuildReader(config)
for path, name, key, value in reader.find_sphinx_variables():
reldir = os.path.dirname(path)
if name == 'SPHINX_TREES':
assert key
manager.add_tree(os.path.join(reldir, value),
os.path.join(reldir, key))
if name == 'SPHINX_PYTHON_PACKAGE_DIRS':
manager.add_python_package_dir(os.path.join(reldir, value))
return manager.generate_docs(format)
示例15: 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)