// // Copyright 2018 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //
// system_utils.cpp: Implementation of common functions
#ifdefined(ANGLE_PLATFORM_ANDROID) # include <sys/system_properties.h> #endif
#ifdefined(ANGLE_PLATFORM_APPLE) # include <dispatch/dispatch.h> # include <pthread.h> #endif
namespace angle
{
std::string GetExecutableName()
{ #ifdefined(ANGLE_PLATFORM_ANDROID) && __ANDROID_API__ >= 21 // Support for "getprogname" function in bionic was introduced in L (API level 21) constchar *executableName = getprogname(); return (executableName) ? std::string(executableName) : "ANGLE"; #else
std::string executableName = GetExecutablePath();
size_t lastPathSepLoc = executableName.find_last_of(GetPathSeparator()); return (lastPathSepLoc > 0 ? executableName.substr(lastPathSepLoc + 1, executableName.length())
: "ANGLE"); #endif// ANGLE_PLATFORM_ANDROID
}
// On Android return value cached in the process environment, if none, call // GetEnvironmentVarOrUnCachedAndroidProperty if not in environment.
std::string GetEnvironmentVarOrAndroidProperty(constchar *variableName, constchar *propertyName)
{ #ifdefined(ANGLE_PLATFORM_ANDROID) && __ANDROID_API__ >= 21 // Can't use GetEnvironmentVar here because that won't allow us to distinguish between the // environment being set to an empty string vs. not set at all. constchar *variableValue = getenv(variableName); if (variableValue != nullptr)
{
std::string value(variableValue); return value;
} #endif return GetEnvironmentVarOrUnCachedAndroidProperty(variableName, propertyName);
}
// On Android call out to 'getprop' on a shell to get an Android property. On desktop, return // the value of the environment variable.
std::string GetEnvironmentVarOrUnCachedAndroidProperty(constchar *variableName, constchar *propertyName)
{ #ifdefined(ANGLE_PLATFORM_ANDROID) && __ANDROID_API__ >= 26
std::string propertyValue;
// Look up a property and add it to the application's environment. // Adding to the env is a performance optimization, as getting properties is expensive. // This should only be used in non-Release paths, i.e. when using FrameCapture or DebugUtils. // It can cause race conditions in stress testing. See http://anglebug.com/6822
std::string GetAndSetEnvironmentVarOrUnCachedAndroidProperty(constchar *variableName, constchar *propertyName)
{
std::string value = GetEnvironmentVarOrUnCachedAndroidProperty(variableName, propertyName);
#ifdefined(ANGLE_PLATFORM_ANDROID) if (!value.empty())
{ // Set the environment variable with the value to improve future lookups (avoids
SetEnvironmentVar(variableName, value.c_str());
} #endif
void *OpenSystemLibraryAndGetError(constchar *libraryName,
SearchType searchType,
std::string *errorOut)
{
std::string libraryWithExtension = std::string(libraryName) + "." + GetSharedLibraryExtension(); #if ANGLE_PLATFORM_IOS // On iOS, libraryWithExtension is a directory in which the library resides. // The actual library name doesn't have an extension at all. // E.g. "libEGL.framework/libEGL"
libraryWithExtension = libraryWithExtension + "/" + libraryName; #endif return OpenSystemLibraryWithExtensionAndGetError(libraryWithExtension.c_str(), searchType,
errorOut);
}
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.