本文整理汇总了Python中mozbuild.base.MozbuildObject.from_environment方法的典型用法代码示例。如果您正苦于以下问题:Python MozbuildObject.from_environment方法的具体用法?Python MozbuildObject.from_environment怎么用?Python MozbuildObject.from_environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozbuild.base.MozbuildObject
的用法示例。
在下文中一共展示了MozbuildObject.from_environment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_symlink_objdir
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def test_symlink_objdir(self):
"""Objdir that is a symlink is loaded properly."""
d = os.path.realpath(tempfile.mkdtemp())
try:
topobjdir_real = os.path.join(d, 'objdir')
topobjdir_link = os.path.join(d, 'objlink')
os.mkdir(topobjdir_real)
os.symlink(topobjdir_real, topobjdir_link)
mozconfig = os.path.join(d, 'mozconfig')
with open(mozconfig, 'wt') as fh:
fh.write('mk_add_options MOZ_OBJDIR=%s' % topobjdir_link)
mozinfo = os.path.join(topobjdir_real, 'mozinfo.json')
with open(mozinfo, 'wt') as fh:
json.dump(dict(
topsrcdir=d,
mozconfig=mozconfig,
), fh)
os.chdir(topobjdir_link)
obj = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False)
self.assertEqual(obj.topobjdir, topobjdir_real)
os.chdir(topobjdir_real)
obj = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False)
self.assertEqual(obj.topobjdir, topobjdir_real)
finally:
os.chdir(self._old_cwd)
shutil.rmtree(d)
示例2: test_objdir_mismatch
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def test_objdir_mismatch(self):
"""Ensure MachCommandBase throwing on objdir mismatch."""
d = os.path.realpath(tempfile.mkdtemp())
try:
real_topobjdir = os.path.join(d, 'real-objdir')
os.makedirs(real_topobjdir)
topobjdir = os.path.join(d, 'objdir')
os.makedirs(topobjdir)
topsrcdir = os.path.join(d, 'srcdir')
os.makedirs(topsrcdir)
mozconfig = os.path.join(d, 'mozconfig')
with open(mozconfig, 'wt') as fh:
fh.write('mk_add_options MOZ_OBJDIR=%s' % real_topobjdir)
mozinfo = os.path.join(topobjdir, 'mozinfo.json')
with open(mozinfo, 'wt') as fh:
json.dump(dict(
topsrcdir=topsrcdir,
mozconfig=mozconfig,
), fh)
os.chdir(topobjdir)
with self.assertRaises(ObjdirMismatchException):
MozbuildObject.from_environment(detect_virtualenv_mozinfo=False)
finally:
os.chdir(self._old_cwd)
shutil.rmtree(d)
示例3: get_properties_db_from_xpcshell
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def get_properties_db_from_xpcshell(self):
"""Generate the static css properties db for devtools from an xpcshell script."""
build = MozbuildObject.from_environment()
# Get the paths
script_path = resolve_path(self.topsrcdir,
'devtools/shared/css/generated/generate-properties-db.js')
gre_path = resolve_path(self.topobjdir, 'dist/bin')
browser_path = resolve_path(self.topobjdir, 'dist/bin/browser')
xpcshell_path = build.get_binary_path(what='xpcshell')
print(browser_path)
sub_env = dict(os.environ)
if sys.platform.startswith('linux'):
sub_env["LD_LIBRARY_PATH"] = gre_path
# Run the xcpshell script, and set the appdir flag to the browser path so that
# we have the proper dependencies for requiring the loader.
contents = subprocess.check_output([xpcshell_path, '-g', gre_path,
'-a', browser_path, script_path],
env = sub_env)
# Extract just the output between the delimiters as the xpcshell output can
# have extra output that we don't want.
contents = contents.split('DEVTOOLS_CSS_DB_DELIMITER')[1]
return json.loads(contents)
示例4: get_parser
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def get_parser():
here = os.path.abspath(os.path.dirname(__file__))
build_obj = MozbuildObject.from_environment(cwd=here)
if conditions.is_android(build_obj):
return reftestcommandline.RemoteArgumentsParser()
else:
return reftestcommandline.DesktopArgumentsParser()
示例5: mozregression_create_parser
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def mozregression_create_parser():
# Create the mozregression command line parser.
# if mozregression is not installed, or not up to date, it will
# first be installed.
cmd = MozbuildObject.from_environment()
cmd._activate_virtualenv()
mozregression = mozregression_import()
if not mozregression:
# mozregression is not here at all, install it
cmd.virtualenv_manager.install_pip_package('mozregression')
print("mozregression was installed. please re-run your"
" command. If you keep getting this message please "
" manually run: 'pip install -U mozregression'.")
else:
# check if there is a new release available
release = mozregression.new_release_on_pypi()
if release:
print(release)
# there is one, so install it. Note that install_pip_package
# does not work here, so just run pip directly.
cmd.virtualenv_manager._run_pip([
'install',
'mozregression==%s' % release
])
print("mozregression was updated to version %s. please"
" re-run your command." % release)
else:
# mozregression is up to date, return the parser.
return mozregression.parser()
# exit if we updated or installed mozregression because
# we may have already imported mozregression and running it
# as this may cause issues.
sys.exit(0)
示例6: main
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def main(platform):
build = MozbuildObject.from_environment()
topsrcdir = build.topsrcdir
distdir = build.distdir
srcdir = os.path.join(topsrcdir, "b2g", "simulator")
app_buildid = open(os.path.join(build.topobjdir, "config", "buildid")).read().strip()
# The simulator uses a shorter version string,
# it only keeps the major version digits A.B
# whereas MOZ_B2G_VERSION is A.B.C.D
b2g_version = build.config_environment.defines["MOZ_B2G_VERSION"].replace('"', '')
version = ".".join(str(n) for n in LooseVersion(b2g_version).version[0:2])
# Build a gaia profile specific to the simulator in order to:
# - disable the FTU
# - set custom prefs to enable devtools debugger server
# - set custom settings to disable lockscreen and screen timeout
# - only ship production apps
gaia_path = build.config_environment.substs["GAIADIR"]
builder = GaiaBuilder(build, gaia_path)
builder.clean()
env = {
"NOFTU": "1",
"GAIA_APP_TARGET": "production",
"SETTINGS_PATH": os.path.join(srcdir, "custom-settings.json")
}
builder.profile(env)
builder.override_prefs(os.path.join(srcdir, "custom-prefs.js"))
# Substitute version strings in the package manifest overload file
manifest_overload = os.path.join(build.topobjdir, "b2g", "simulator", "package-overload.json")
process_package_overload(os.path.join(srcdir, "package-overload.json.in"),
manifest_overload,
version,
app_buildid)
# Build the simulator addon xpi
xpi_name = XPI_NAME % {"version": version, "platform": platform}
xpi_path = os.path.join(distdir, xpi_name)
update_path = "%s/%s" % (version, platform)
update_link = UPDATE_LINK % {"update_path": update_path, "xpi_name": xpi_name}
update_url = UPDATE_URL % {"update_path": update_path}
subprocess.check_call([
build.virtualenv_manager.python_path, os.path.join(topsrcdir, "addon-sdk", "source", "bin", "cfx"), "xpi", \
"--pkgdir", srcdir, \
"--manifest-overload", manifest_overload, \
"--strip-sdk", \
"--update-link", update_link, \
"--update-url", update_url, \
"--static-args", "{\"label\": \"Firefox OS %s\"}" % version, \
"--output-file", xpi_path \
])
# Ship b2g-desktop, but prevent its gaia profile to be shipped in the xpi
add_dir_to_zip(xpi_path, os.path.join(distdir, "b2g"), "b2g", ("gaia", "B2G.app/Contents/MacOS/gaia"))
# Then ship our own gaia profile
add_dir_to_zip(xpi_path, os.path.join(gaia_path, "profile"), "profile")
示例7: test_relative_objdir
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def test_relative_objdir(self):
"""Relative defined objdirs are loaded properly."""
d = os.path.realpath(tempfile.mkdtemp())
try:
mozconfig = os.path.join(d, 'mozconfig')
with open(mozconfig, 'wt') as fh:
fh.write('mk_add_options MOZ_OBJDIR=./objdir')
topobjdir = mozpath.join(d, 'objdir')
os.mkdir(topobjdir)
mozinfo = os.path.join(topobjdir, 'mozinfo.json')
with open(mozinfo, 'wt') as fh:
json.dump(dict(
topsrcdir=d,
mozconfig=mozconfig,
), fh)
os.environ[b'MOZCONFIG'] = mozconfig.encode('utf-8')
child = os.path.join(topobjdir, 'foo', 'bar')
os.makedirs(child)
os.chdir(child)
obj = MozbuildObject.from_environment(
detect_virtualenv_mozinfo=False)
self.assertEqual(obj.topobjdir, topobjdir)
finally:
os.chdir(self._old_cwd)
shutil.rmtree(d)
示例8: find_and_update_from_json
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def find_and_update_from_json(*dirs):
"""
Find a mozinfo.json file, load it, and update the info with the
contents.
:param dirs: Directories in which to look for the file. They will be
searched after first looking in the root of the objdir
if the current script is being run from a Mozilla objdir.
Returns the full path to mozinfo.json if it was found, or None otherwise.
"""
# First, see if we're in an objdir
try:
from mozbuild.base import MozbuildObject, BuildEnvironmentNotFoundException
from mozbuild.mozconfig import MozconfigFindException
build = MozbuildObject.from_environment()
json_path = _os.path.join(build.topobjdir, "mozinfo.json")
if _os.path.isfile(json_path):
update(json_path)
return json_path
except ImportError:
pass
except (BuildEnvironmentNotFoundException, MozconfigFindException):
pass
for d in dirs:
d = _os.path.abspath(d)
json_path = _os.path.join(d, "mozinfo.json")
if _os.path.isfile(json_path):
update(json_path)
return json_path
return None
示例9: get_parser
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def get_parser():
build_obj = MozbuildObject.from_environment(cwd=here)
if conditions.is_android(build_obj):
return parser_remote()
elif conditions.is_b2g(build_obj):
return parser_b2g()
else:
return parser_desktop()
示例10: test_objdir_is_srcdir_rejected
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def test_objdir_is_srcdir_rejected(self):
"""Ensure the srcdir configurations are rejected."""
d = os.path.realpath(tempfile.mkdtemp())
try:
# The easiest way to do this is to create a mozinfo.json with data
# that will never happen.
mozinfo = os.path.join(d, 'mozinfo.json')
with open(mozinfo, 'wt') as fh:
json.dump({'topsrcdir': d}, fh)
os.chdir(d)
with self.assertRaises(BadEnvironmentException):
MozbuildObject.from_environment(detect_virtualenv_mozinfo=False)
finally:
shutil.rmtree(d)
示例11: _init
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def _init(self):
CommonBackend._init(self)
self._backend_files = {}
self._cmd = MozbuildObject.from_environment()
# This is a 'group' dependency - All rules that list this as an output
# will be built before any rules that list this as an input.
self._installed_files = '$(MOZ_OBJ_ROOT)/<installed-files>'
示例12: test_info
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def test_info(self, **params):
import which
from mozbuild.base import MozbuildObject
self.branches = params['branches']
self.start = params['start']
self.end = params['end']
self.show_info = params['show_info']
self.show_results = params['show_results']
self.show_durations = params['show_durations']
self.show_bugs = params['show_bugs']
self.verbose = params['verbose']
if (not self.show_info and
not self.show_results and
not self.show_durations and
not self.show_bugs):
# by default, show everything
self.show_info = True
self.show_results = True
self.show_durations = True
self.show_bugs = True
here = os.path.abspath(os.path.dirname(__file__))
build_obj = MozbuildObject.from_environment(cwd=here)
self._hg = None
if conditions.is_hg(build_obj):
if self._is_windows():
self._hg = which.which('hg.exe')
else:
self._hg = which.which('hg')
self._git = None
if conditions.is_git(build_obj):
if self._is_windows():
self._git = which.which('git.exe')
else:
self._git = which.which('git')
for test_name in params['test_names']:
print("===== %s =====" % test_name)
self.test_name = test_name
if len(self.test_name) < 6:
print("'%s' is too short for a test name!" % self.test_name)
continue
if self.show_info:
self.set_test_name()
if self.show_results:
self.report_test_results()
if self.show_durations:
self.report_test_durations()
if self.show_bugs:
self.report_bugs()
示例13: main
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def main(platform):
build = MozbuildObject.from_environment()
topsrcdir = build.topsrcdir
distdir = build.distdir
srcdir = os.path.join(topsrcdir, "b2g", "simulator")
app_buildid = open(os.path.join(build.topobjdir, "config", "buildid")).read().strip()
# The simulator uses a shorter version string,
# it only keeps the major version digits A.B
# whereas MOZ_B2G_VERSION is A.B.C.D
b2g_version = build.config_environment.defines["MOZ_B2G_VERSION"].replace('"', "")
version = ".".join(str(n) for n in LooseVersion(b2g_version).version[0:2])
# Build a gaia profile specific to the simulator in order to:
# - disable the FTU
# - set custom prefs to enable devtools debugger server
# - set custom settings to disable lockscreen and screen timeout
# - only ship production apps
gaia_path = build.config_environment.substs["GAIADIR"]
builder = GaiaBuilder(build, gaia_path)
builder.clean()
env = {"NOFTU": "1", "GAIA_APP_TARGET": "production", "SETTINGS_PATH": os.path.join(srcdir, "custom-settings.json")}
builder.profile(env)
builder.override_prefs(os.path.join(srcdir, "custom-prefs.js"))
# Build the simulator addon xpi
xpi_name = XPI_NAME % {"version": version, "platform": platform}
xpi_path = os.path.join(distdir, xpi_name)
update_path = "%s/%s" % (version, platform)
update_url = UPDATE_URL % {"update_path": update_path}
# Preprocess some files...
manifest = os.path.join(build.topobjdir, "b2g", "simulator", "install.rdf")
preprocess_file(os.path.join(srcdir, "install.rdf.in"), manifest, version, app_buildid, update_url)
with JarWriter(xpi_path, optimize=False) as zip:
# Ship addon files into the .xpi
add_file_to_zip(zip, manifest, "install.rdf")
add_file_to_zip(zip, os.path.join(srcdir, "bootstrap.js"), "bootstrap.js")
add_file_to_zip(zip, os.path.join(srcdir, "icon.png"), "icon.png")
add_file_to_zip(zip, os.path.join(srcdir, "icon64.png"), "icon64.png")
# Ship b2g-desktop, but prevent its gaia profile to be shipped in the xpi
add_dir_to_zip(
zip,
os.path.join(distdir, "b2g"),
"b2g",
("gaia", "B2G.app/Contents/MacOS/gaia", "B2G.app/Contents/Resources/gaia"),
)
# Then ship our own gaia profile
add_dir_to_zip(zip, os.path.join(gaia_path, "profile"), "profile")
示例14: make_dmg
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
def make_dmg(source_directory, output_dmg):
build = MozbuildObject.from_environment()
extra_files = [
(os.path.join(build.distdir, 'branding', 'dsstore'), '.DS_Store'),
(os.path.join(build.distdir, 'branding', 'background.png'),
'.background/background.png'),
(os.path.join(build.distdir, 'branding', 'disk.icns'),
'.VolumeIcon.icns'),
]
volume_name = build.substs['MOZ_APP_DISPLAYNAME']
dmg.create_dmg(source_directory, output_dmg, volume_name, extra_files)
示例15: test_filesystem_traversal_reading
# 需要导入模块: from mozbuild.base import MozbuildObject [as 别名]
# 或者: from mozbuild.base.MozbuildObject import from_environment [as 别名]
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))