Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e351d2f authored by Dimitry Ivanov's avatar Dimitry Ivanov Committed by android-build-merger
Browse files

Merge "Add public libs from an environment variable"

am: c6160d2a

* commit 'c6160d2a':
  Add public libs from an environment variable

Change-Id: I2be47c2e9fc02860e7ddd79b97f666c9ea6e881b
parents 2f67f468 c6160d2a
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
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
+19 −0
Original line number Diff line number Diff line
@@ -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);