Merge "Add public libs from an environment variable"
This commit is contained in:
commit
c6160d2a0e
libnativeloader
|
@ -1,19 +1,21 @@
|
|||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
NATIVE_LOADER_COMMON_SRC_FILES := \
|
||||
native_loader_common_src_files := \
|
||||
native_loader.cpp
|
||||
|
||||
native_loader_common_cflags := -Werror -Wall
|
||||
|
||||
# Shared library for target
|
||||
# ========================================================
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE:= libnativeloader
|
||||
|
||||
LOCAL_SRC_FILES:= $(NATIVE_LOADER_COMMON_SRC_FILES)
|
||||
LOCAL_SRC_FILES:= $(native_loader_common_src_files)
|
||||
LOCAL_SHARED_LIBRARIES := libnativehelper liblog libcutils
|
||||
LOCAL_STATIC_LIBRARIES := libbase
|
||||
LOCAL_CLANG := true
|
||||
LOCAL_CFLAGS += -Werror -Wall
|
||||
LOCAL_CFLAGS := $(native_loader_common_cflags)
|
||||
LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden
|
||||
LOCAL_LDFLAGS := -ldl
|
||||
LOCAL_MULTILIB := both
|
||||
|
@ -27,11 +29,11 @@ include $(CLEAR_VARS)
|
|||
|
||||
LOCAL_MODULE:= libnativeloader
|
||||
|
||||
LOCAL_SRC_FILES:= $(NATIVE_LOADER_COMMON_SRC_FILES)
|
||||
LOCAL_SRC_FILES:= $(native_loader_common_src_files)
|
||||
LOCAL_SHARED_LIBRARIES := libnativehelper liblog libcutils
|
||||
LOCAL_STATIC_LIBRARIES := libbase
|
||||
LOCAL_CLANG := true
|
||||
LOCAL_CFLAGS += -Werror -Wall
|
||||
LOCAL_CFLAGS := $(native_loader_common_cflags)
|
||||
LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden
|
||||
LOCAL_LDFLAGS := -ldl
|
||||
LOCAL_MULTILIB := both
|
||||
|
@ -45,10 +47,10 @@ include $(CLEAR_VARS)
|
|||
|
||||
LOCAL_MODULE:= libnativeloader
|
||||
|
||||
LOCAL_SRC_FILES:= $(NATIVE_LOADER_COMMON_SRC_FILES)
|
||||
LOCAL_SRC_FILES:= $(native_loader_common_src_files)
|
||||
LOCAL_STATIC_LIBRARIES := libnativehelper libcutils liblog libbase
|
||||
LOCAL_CLANG := true
|
||||
LOCAL_CFLAGS += -Werror -Wall
|
||||
LOCAL_CFLAGS := $(native_loader_common_cflags)
|
||||
LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden
|
||||
LOCAL_LDFLAGS := -ldl
|
||||
LOCAL_MULTILIB := both
|
||||
|
|
|
@ -39,6 +39,12 @@ namespace android {
|
|||
static constexpr const char* kPublicNativeLibrariesSystemConfigPathFromRoot = "/etc/public.libraries.txt";
|
||||
static constexpr const char* kPublicNativeLibrariesVendorConfig = "/vendor/etc/public.libraries.txt";
|
||||
|
||||
static bool is_debuggable() {
|
||||
char debuggable[PROP_VALUE_MAX];
|
||||
property_get("ro.debuggable", debuggable, "0");
|
||||
return std::string(debuggable) == "1";
|
||||
}
|
||||
|
||||
class LibraryNamespaces {
|
||||
public:
|
||||
LibraryNamespaces() : initialized_(false) { }
|
||||
|
@ -103,6 +109,19 @@ class LibraryNamespaces {
|
|||
LOG_ALWAYS_FATAL_IF(!ReadConfig(public_native_libraries_system_config, &sonames),
|
||||
"Error reading public native library list from \"%s\": %s",
|
||||
public_native_libraries_system_config.c_str(), strerror(errno));
|
||||
|
||||
// For debuggable platform builds use ANDROID_ADDITIONAL_PUBLIC_LIBRARIES environment
|
||||
// variable to add libraries to the list. This is intended for platform tests only.
|
||||
if (is_debuggable()) {
|
||||
const char* additional_libs = getenv("ANDROID_ADDITIONAL_PUBLIC_LIBRARIES");
|
||||
if (additional_libs != nullptr && additional_libs[0] != '\0') {
|
||||
std::vector<std::string> additional_libs_vector = base::Split(additional_libs, ":");
|
||||
std::copy(additional_libs_vector.begin(),
|
||||
additional_libs_vector.end(),
|
||||
std::back_inserter(sonames));
|
||||
}
|
||||
}
|
||||
|
||||
// This file is optional, quietly ignore if the file does not exist.
|
||||
ReadConfig(kPublicNativeLibrariesVendorConfig, &sonames);
|
||||
|
||||
|
|
Loading…
Reference in New Issue