# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# This module produces a JSON file that provides basic build info and # configuration metadata.
import json import os import re
import six
def build_dict(config, env=os.environ): """
Build a dict containing data about the build configuration from
the environment. """
substs = config.substs
# Check that all required variables are present first.
required = ["TARGET_CPU", "OS_TARGET"]
missing = [r for r in required if r notin substs] if missing: raise Exception( "Missing required environment variables: %s" % ", ".join(missing)
)
d = {}
d["topsrcdir"] = config.topsrcdir
d["topobjdir"] = config.topobjdir
if config.mozconfig:
d["mozconfig"] = config.mozconfig
# os
o = substs["OS_TARGET"]
known_os = {"Linux": "linux", "WINNT": "win", "Darwin": "mac", "Android": "android"} if o in known_os:
d["os"] = known_os[o] else: # Allow unknown values, just lowercase them.
d["os"] = o.lower()
# Widget toolkit, just pass the value directly through.
d["toolkit"] = substs.get("MOZ_WIDGET_TOOLKIT")
# Application name if"MOZ_APP_NAME"in substs:
d["appname"] = substs["MOZ_APP_NAME"]
# Build app name if"MOZ_BUILD_APP"in substs:
d["buildapp"] = substs["MOZ_BUILD_APP"]
# processor
p = substs["TARGET_CPU"] # do some slight massaging for some values # TODO: retain specific values in case someone wants them? if p.startswith("arm"):
p = "arm" elif re.match("i[3-9]86", p):
p = "x86"
d["processor"] = p # hardcoded list of 64-bit CPUs if p in ["x86_64", "ppc64", "aarch64"]:
d["bits"] = 64 # hardcoded list of known 32-bit CPUs elif p in ["x86", "arm", "ppc"]:
d["bits"] = 32 # other CPUs will wind up with unknown bits
d["opt"] = not d["debug"] andnot d["asan"] andnot d["tsan"] andnot d["ccov"]
def guess_platform(): if d["buildapp"] == "browser":
p = d["os"] if p == "mac":
p = "macosx64" elif d["bits"] == 64:
p = "{}64".format(p) elif p in ("win",):
p = "{}32".format(p)
if d["asan"]:
p = "{}-asan".format(p)
return p
if d["buildapp"] == "mobile/android": if d["processor"] == "x86": return"android-x86" if d["processor"] == "x86_64": return"android-x86_64" if d["processor"] == "aarch64": return"android-aarch64" return"android-arm"
def guess_buildtype(): if d["asan"]: return"asan" if d["tsan"]: return"tsan" if d["ccov"]: return"ccov" if d["debug"]: return"debug" if d["pgo"]: return"pgo" return"opt"
# if buildapp or bits are unknown, we don't have a configuration similar to # any in automation and the guesses are useless. if"buildapp"in d and (d["os"] == "mac"or"bits"in d):
d["platform_guess"] = guess_platform()
d["buildtype_guess"] = guess_buildtype()
d["buildtype"] = guess_buildtype()
def write_mozinfo(file, config, env=os.environ): """Write JSON data about the configuration specified in config and an
environment variable dict to ``|file|``, which may be a filename or file-like
object.
See build_dict for information about what environment variables are used, and what keys are produced. """
build_conf = build_dict(config, env) if isinstance(file, six.text_type):
file = open(file, "wt")
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.