summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogan Chien <loganchien@google.com>2017-08-17 20:42:57 +0800
committerLogan Chien <loganchien@google.com>2017-08-23 09:57:17 +0800
commitac404dce8ce14ae498042f0dbc03e6333e171c9a (patch)
treedae8c1415276a1188b623b6b80fc30d593d34f9b
parentfd04ff570957b11a2c07eabb653b4828a4854a6a (diff)
downloadandroid_development-ac404dce8ce14ae498042f0dbc03e6333e171c9a.tar.gz
android_development-ac404dce8ce14ae498042f0dbc03e6333e171c9a.tar.bz2
android_development-ac404dce8ce14ae498042f0dbc03e6333e171c9a.zip
vndk-def: Support Treble VNDK directory layout
This commit adds /system/lib/vndk and /vendor/lib/vndk to the search path for vendor modules. Bug: 64503245 Test: Run `vndk_definition_tool.py vndk` on the device with Treble VNDK directory layout. Test: Run `vndk_definition_tool.py vndk` on sailfish and nothing changes (including warning/error messages). Change-Id: Ifb9dd9b21fb93a3c1f2f6d57c61c7416d6437ddb Merged-In: I7499691c05d66213441371bd18d5b84cf79d6221 (cherry picked from commit 1f01de957bb8e26a0d3ffa919ccf42b267734de2)
-rwxr-xr-xvndk/tools/definition-tool/vndk_definition_tool.py78
1 files changed, 60 insertions, 18 deletions
diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py
index f432a3e7a..7fef3b652 100755
--- a/vndk/tools/definition-tool/vndk_definition_tool.py
+++ b/vndk/tools/definition-tool/vndk_definition_tool.py
@@ -1132,53 +1132,95 @@ class ELFLinker(object):
'/vendor/${LIB}',
'/vendor/${LIB}/vndk-sp',
'/system/${LIB}/vndk-sp',
+ '/vendor/${LIB}/vndk',
+ '/system/${LIB}/vndk',
'/system/${LIB}', # For degenerated VNDK libs.
)
VNDK_SP_SEARCH_PATH = (
'/vendor/${LIB}/vndk-sp',
'/system/${LIB}/vndk-sp',
- '/vendor/${LIB}', # To discover missing vndk-sp dependencies.
- '/system/${LIB}', # To discover missing vndk-sp dependencies.
+ '/vendor/${LIB}', # To discover missing VNDK-SP dependencies.
+ '/system/${LIB}', # To discover missing VNDK-SP dependencies or LL-NDK.
)
+ VNDK_SEARCH_PATH = (
+ '/vendor/${LIB}/vndk-sp',
+ '/system/${LIB}/vndk-sp',
+ '/vendor/${LIB}/vndk',
+ '/system/${LIB}/vndk',
+ '/system/${LIB}', # To discover missing VNDK dependencies or LL-NDK.
+ )
+
+
@staticmethod
def _subst_search_path(search_path, elf_class):
lib_dir_name = 'lib' if elf_class == ELF.ELFCLASS32 else 'lib64'
return [path.replace('${LIB}', lib_dir_name) for path in search_path]
- @staticmethod
- def _is_in_vndk_sp_dir(path):
- return os.path.basename(os.path.dirname(path)).startswith('vndk-sp')
+ @classmethod
+ def _get_dirname(cls, path):
+ return os.path.basename(os.path.dirname(path))
+
+ @classmethod
+ def _is_in_vndk_dir(cls, path):
+ return cls._get_dirname(path) == 'vndk'
+
+ @classmethod
+ def _is_in_vndk_sp_dir(cls, path):
+ return cls._get_dirname(path) == 'vndk-sp'
+
+ @classmethod
+ def _classify_vndk_libs(cls, libs):
+ vndk_libs = set()
+ vndk_sp_libs = set()
+ other_libs = set()
+ for lib in libs:
+ dirname = cls._get_dirname(lib.path)
+ if dirname == 'vndk':
+ vndk_libs.add(lib)
+ elif dirname == 'vndk-sp':
+ vndk_sp_libs.add(lib)
+ else:
+ other_libs.add(lib)
+ return (vndk_libs, vndk_sp_libs, other_libs)
def _resolve_elf_class_deps(self, elf_class, generic_refs):
+ # Classify libs.
+ lib_dict = self._compute_lib_dict(elf_class)
system_lib_dict = self.lib_pt[PT_SYSTEM].get_lib_dict(elf_class)
+ system_vndk_libs, system_vndk_sp_libs, system_libs = \
+ self._classify_vndk_libs(system_lib_dict.values())
+
vendor_lib_dict = self.lib_pt[PT_VENDOR].get_lib_dict(elf_class)
- lib_dict = self._compute_lib_dict(elf_class)
+ vendor_vndk_libs, vendor_vndk_sp_libs, vendor_libs = \
+ self._classify_vndk_libs(vendor_lib_dict.values())
+
+ vndk_libs = system_vndk_libs | vendor_vndk_libs
+ vndk_sp_libs = system_vndk_sp_libs | vendor_vndk_sp_libs
# Resolve system libs.
- system_libs = [lib for lib in system_lib_dict.values()
- if not self._is_in_vndk_sp_dir(lib.path)]
search_path = self._subst_search_path(
self.SYSTEM_SEARCH_PATH, elf_class)
resolver = ELFResolver(lib_dict, search_path)
self._resolve_lib_set_deps(system_libs, resolver, generic_refs)
- # Resolve vendor libs.
- vendor_libs = [lib for lib in vendor_lib_dict.values()
- if not self._is_in_vndk_sp_dir(lib.path)]
+ # Resolve vndk-sp libs
search_path = self._subst_search_path(
- self.VENDOR_SEARCH_PATH, elf_class)
+ self.VNDK_SP_SEARCH_PATH, elf_class)
resolver = ELFResolver(lib_dict, search_path)
- self._resolve_lib_set_deps(vendor_libs, resolver, generic_refs)
+ self._resolve_lib_set_deps(vndk_sp_libs, resolver, generic_refs)
- # Resolve vndk-sp libs
- vndk_sp = [lib for lib in lib_dict.values()
- if self._is_in_vndk_sp_dir(lib.path)]
+ # Resolve vndk libs
+ search_path = self._subst_search_path(self.VNDK_SEARCH_PATH, elf_class)
+ resolver = ELFResolver(lib_dict, search_path)
+ self._resolve_lib_set_deps(vndk_libs, resolver, generic_refs)
+
+ # Resolve vendor libs.
search_path = self._subst_search_path(
- self.VNDK_SP_SEARCH_PATH, elf_class)
+ self.VENDOR_SEARCH_PATH, elf_class)
resolver = ELFResolver(lib_dict, search_path)
- self._resolve_lib_set_deps(vndk_sp, resolver, generic_refs)
+ self._resolve_lib_set_deps(vendor_libs, resolver, generic_refs)
def resolve_deps(self, generic_refs=None):
self._resolve_elf_class_deps(ELF.ELFCLASS32, generic_refs)