Spracherkennung für: .configure vermutete Sprache: VDM {VDM[64] Python[48] SQL[48]} [Methode: maximale Elemente, drei Dimensionen]
# 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/.
@depends(toolchains_base_dir,
"--help")
@
imports(_
from=
"os.path", _import=
"isdir")
@
imports(_
from=
"mozboot.android", _import=
"NDK_VERSION")
def default_android_ndk_root(toolchains_base_dir, _):
for ndk
in (
"android-ndk-%s" % NDK_VERSION,
"android-ndk"):
path = os.path.join(toolchains_base_dir, ndk)
if isdir(path):
return path
option(
"--with-android-ndk",
nargs=
1,
default=default_android_ndk_root,
help=
"Location where the Android NDK can be found{|}",
)
option(
"--with-android-toolchain", nargs=1, help="Location of the Android toolchain")
option(
"--with-android-lldb-server", nargs=1, help="Location of the Android LLDB server"
)
option(
"--with-android-googlevr-sdk", nargs=1, help="Location of the Android GoogleVR SDK"
)
@dependable
def min_android_version():
#
Sync with android_sdk_version.min_sdk_version
return "26"
option(
"--with-android-version",
nargs=
1,
help=
"Android platform version{|}",
default=min_android_version,
)
@depends(
"--with-android-version", min_android_version)
@
imports(_
from=
"__builtin__", _import=
"ValueError")
def android_version(value, min_version):
if not value:
# Someone has passed
--without-android-version.
die(
"--with-android-version cannot be disabled.")
try:
version =
int(value[
0])
except ValueError:
die(
"--with-android-version expects an integer value")
if version <
int(min_version):
die(
"--with-android-version must be at least %s (got %s)", min_version, value[0]
)
return version
@depends(
"--with-android-ndk", want_bootstrap)
@
imports(_
from=
"os.path", _import=
"isdir")
@
imports(_
from=
"mozboot.android", _import=
"get_os_name_for_android")
@
imports(_
from=
"mozboot.android", _import=
"ensure_android_ndk")
@
imports(_
from=
"mozboot.android", _import=
"NDK_PATH")
def ndk(value, want_bootstrap):
if value:
ndk_path = value[
0]
if not isdir(ndk_path):
die(
"The path you specified with --with-android-ndk (%s) is not "
"a directory" % ndk_path
)
return ndk_path
if not want_bootstrap(
"android-ndk"):
die(
"You must specify --with-android-ndk=/path/to/ndk when targeting Android, "
"or try |mach bootstrap|."
)
os_name = get_os_name_for_android()
ensure_android_ndk(os_name)
return str(NDK_PATH)
set_config(
"ANDROID_NDK", ndk)
@depends(ndk)
@checking(
"for android ndk version")
@
imports(_
from=
"__builtin__", _import=
"open")
@
imports(_
from=
"mozboot.android", _import=
"NDK_VERSION")
@
imports(_
from=
"mozboot.android", _import=
"get_ndk_version")
@
imports(_
from=
"mozboot.android", _import=
"GetNdkVersionError")
def ndk_version(ndk):
if not ndk:
# Building
'js/src' for non-Android.
return
try:
major, minor, human = get_ndk_version(ndk)
except GetNdkVersionError
as e:
die(str(e))
if NDK_VERSION != human:
die(
"The only supported version of the NDK is %s (have %s)\n"
"Please run |mach bootstrap| "
"to install the correct NDK." % (NDK_VERSION, human)
)
return namespace(
major=major,
minor=minor,
)
set_config(
"ANDROID_NDK_MAJOR_VERSION", ndk_version.major)
set_config(
"ANDROID_NDK_MINOR_VERSION", ndk_version.minor)
@
imports(_
from=
"os.path", _import=
"isdir")
@
imports(_
from=
"mozshellutil", _import=
"quote")
def host_dir(host, base_dir):
dir_format =
"%s/%s-%s"
host_kernel =
"windows" if host.kernel ==
"WINNT" else host.kernel.lower()
dir = dir_format % (base_dir, host_kernel, host.cpu)
log.debug(
"Trying %s" % quote(dir))
if not isdir(dir)
and host.cpu ==
"x86_64":
dir = dir_format % (base_dir, host_kernel,
"x86")
log.debug(
"Trying %s" % quote(dir))
if not isdir(dir)
and host.kernel ==
"Darwin" and host.cpu ==
"aarch64":
dir = dir_format % (base_dir, host_kernel,
"x86_64")
log.debug(
"Trying %s" % quote(dir))
if isdir(dir):
return dir
@depends(host, ndk,
"--with-android-toolchain")
@checking(
"for the Android toolchain directory",
lambda x: x
or "not found")
def android_toolchain(host, ndk, toolchain):
if not ndk:
return
if toolchain:
return toolchain[
0]
toolchain = host_dir(host, os.path.join(ndk,
"toolchains",
"llvm",
"prebuilt"))
if toolchain:
return toolchain
die(
"You have to specify --with-android-toolchain=" "/path/to/ndk/toolchain.")
@depends(target, android_toolchain)
@checking(
"for android sysroot directory")
@
imports(_
from=
"os.path", _import=
"isdir")
def android_sysroot(target, android_toolchain):
if target.os !=
"Android":
return
search_dirs = [
os.path.join(android_toolchain,
"sysroot"),
]
for sysroot_dir
in search_dirs:
if isdir(sysroot_dir):
return sysroot_dir
die(
"Android sysroot directory not found in %s."
% str([sysroot_dir
for sysroot_dir
in search_dirs])
)
@depends(target, host, ndk,
"--with-android-lldb-server")
@checking(
"for the Android LLDB server",
lambda x: x
or "not found")
@
imports(_
from=
"os", _import=
"listdir")
@
imports(_
from=
"os.path", _import=
"isdir")
@
imports(_
from=
"os.path", _import=
"isfile")
@
imports(_
from=
"mozshellutil", _import=
"quote")
def android_lldb_server(target, host, ndk, lldb):
if not ndk:
return
if lldb:
return lldb[
0]
else:
clang_format =
"toolchains/llvm/prebuilt/%s-%s/lib/clang"
llvm_lib =
"lib/linux"
host_kernel =
"windows" if host.kernel ==
"WINNT" else host.kernel.lower()
clang_path = os.path.join(ndk, clang_format % (host_kernel, host.cpu))
if not isdir(clang_path)
and host.kernel ==
"Darwin" and host.cpu ==
"aarch64":
clang_path = os.path.join(ndk, clang_format % (host_kernel,
"x86_64"))
log.debug(
"Listing subdirectories of %s" % quote(clang_path))
clang_subdirs = [
x
for x
in listdir(clang_path)
if isdir(os.path.join(clang_path, x))
]
log.debug(
"Got %r" % clang_subdirs)
if len(clang_subdirs) ==
0:
die(
"Could not resolve lldb-server in %s. Please specify --with-android-lldb-server=/path/to/android/lldb-server"
% quote(clang_path)
)
sorted_versions = sorted(clang_subdirs, key=Version)
highest_version = sorted_versions[-
1]
if len(sorted_versions) >
1:
log.warning(
"Using highest version available: %s" % quote(highest_version))
log.warning(
" Available versions: "
+
", ".join(str(version)
for version
in sorted_versions)
)
log.warning(
"(To use an older version, please specify --with-android-lldb-server=/path/to/desired/android/lldb-server)"
)
if target.cpu ==
"x86":
target_cpu =
"i386"
else:
target_cpu = target.cpu
full_path = os.path.join(
clang_path, highest_version, llvm_lib, target_cpu,
"lldb-server"
)
log.debug(
"Trying %s" % quote(full_path))
if isfile(full_path):
return full_path
die(
"Please specify --with-android-lldb-server=/path/to/android/lldb-server")
set_config(
"ANDROID_LLDB_SERVER", android_lldb_server)
option(
env=
"STLPORT_LIBS",
nargs=
1,
help=
"Options linker should pass for standard C++ library",
)
@depends(
"STLPORT_LIBS", ndk)
@
imports(_
from=
"os.path", _import=
"isfile")
def stlport_libs(value, ndk):
if value
and len(value):
return value.split()
if not ndk:
return
return [
"-static-libstdc++"]
set_config(
"STLPORT_LIBS", stlport_libs)
@depends(android_sysroot, android_toolchain)
def android_toolchain_flags(android_sysroot, toolchain_dir):
if not android_sysroot:
return []
flags = [
"--sysroot={}".format(android_sysroot),
"--gcc-toolchain={}".format(toolchain_dir),
]
return flags
@depends(android_toolchain_flags)
def android_flags(android_toolchain_flags):
wead_symbols_defines = [
"-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__",
]
weak_symbols_flags = wead_symbols_defines + [
"-Werror=unguarded-availability",
]
return namespace(
cflags=android_toolchain_flags
+ [
"-fno-short-enums",
]
+ weak_symbols_flags,
cxxflags=android_toolchain_flags
+ [
"-fno-short-enums",
]
+ weak_symbols_flags,
ldflags=android_toolchain_flags,
asflags=android_toolchain_flags
+ [
"-DANDROID",
]
+ wead_symbols_defines,
)
@depends(host, ndk)
@
imports(_
from=
"os", _import=
"listdir")
@
imports(_
from=
"os.path", _import=
"isfile")
@
imports(_
from=
"os.path", _import=
"isdir")
def android_system_headers(host, ndk):
if not ndk:
return
host_kernel =
"windows" if host.kernel ==
"WINNT" else host.kernel.lower()
android_fmt =
"toolchains/llvm/prebuilt/{}-{}/sysroot/usr/include/android"
android_includes = os.path.join(ndk, android_fmt.format(host_kernel, host.cpu))
if (
not isdir(android_includes)
and host.kernel ==
"Darwin"
and host.cpu ==
"aarch64"
):
android_includes = os.path.join(ndk, android_fmt.format(host_kernel,
"x86_64"))
return [
f
"android/{header}"
for header
in listdir(android_includes)
if isfile(os.path.join(android_includes, header))
]
set_config(
"ANDROID_SYSTEM_HEADERS", android_system_headers)
@depends(android_toolchain_flags)
def bindgen_cflags_android(toolchain_flags):
return toolchain_flags
@depends(
"--with-android-googlevr-sdk", target)
@checking(
"for GoogleVR SDK",
lambda x: x.
result)
@
imports(_
from=
"os.path", _import=
"exists")
@
imports(_
from=
"os.path", _import=
"abspath")
def googlevr_sdk(value, target):
if not value:
return namespace(
result=
"Not specified")
path = abspath(value[
0])
if not exists(path):
die(
"Could not find GoogleVR SDK %s", path)
include =
"%s/libraries/headers/" % path
if "arm" == target.cpu:
arch =
"armeabi-v7a"
elif
"aarch64" == target.cpu:
arch =
"arm64-v8a"
elif
"x86" == target.cpu:
arch =
"x86"
else:
die(
"Unsupported GoogleVR cpu architecture %s" % target.cpu)
libs =
"{0}/libraries/jni/{1}/".format(path, arch)
if not exists(libs):
die(
"Could not find GoogleVR NDK at %s. Did you try running "
"'./gradlew :extractNdk' in %s?",
libs,
path,
)
return namespace(
result=path,
include=include,
libs=libs,
enabled=
True,
)
set_define(
"MOZ_ANDROID_GOOGLE_VR", googlevr_sdk.enabled)
set_config(
"MOZ_ANDROID_GOOGLE_VR", googlevr_sdk.enabled)
set_config(
"MOZ_ANDROID_GOOGLE_VR_LIBS", googlevr_sdk.libs)