Merge changes I283fe25a,Iabef0b10
* changes: Support new binder32bit property Expand a leading '~' to $HOME in arg for --local
This commit is contained in:
@@ -26,8 +26,6 @@ import xml.etree.ElementTree as xml_tree
|
||||
|
||||
import utils
|
||||
|
||||
logger = utils.logger(__name__)
|
||||
|
||||
|
||||
class GPLChecker(object):
|
||||
"""Checks that all GPL projects in a VNDK snapshot have released sources.
|
||||
@@ -109,24 +107,24 @@ class GPLChecker(object):
|
||||
def _check_rev_list(revision):
|
||||
"""Checks whether revision is reachable from HEAD of git project."""
|
||||
|
||||
logger.info('Checking if revision {rev} exists in {proj}'.format(
|
||||
logging.info('Checking if revision {rev} exists in {proj}'.format(
|
||||
rev=revision, proj=git_project_path))
|
||||
try:
|
||||
cmd = [
|
||||
'git', '-C', path, 'rev-list', 'HEAD..{}'.format(revision)
|
||||
]
|
||||
output = utils.check_output(cmd, logger).strip()
|
||||
output = utils.check_output(cmd).strip()
|
||||
except subprocess.CalledProcessError as error:
|
||||
logger.error('Error: {}'.format(error))
|
||||
logging.error('Error: {}'.format(error))
|
||||
return False
|
||||
else:
|
||||
if output:
|
||||
logger.debug(
|
||||
logging.debug(
|
||||
'{proj} does not have the following revisions: {rev}'.
|
||||
format(proj=git_project_path, rev=output))
|
||||
return False
|
||||
else:
|
||||
logger.info(
|
||||
logging.info(
|
||||
'Found revision {rev} in project {proj}'.format(
|
||||
rev=revision, proj=git_project_path))
|
||||
return True
|
||||
@@ -138,16 +136,16 @@ class GPLChecker(object):
|
||||
# revision relevant to the source of the git_project_path,
|
||||
# we fetch the *-release branch and get the revision of the
|
||||
# parent commit with FETCH_HEAD^2.
|
||||
logger.info(
|
||||
logging.info(
|
||||
'Checking if the parent of revision {rev} exists in {proj}'.
|
||||
format(rev=revision, proj=git_project_path))
|
||||
try:
|
||||
cmd = ['git', '-C', path, 'fetch', 'goog', revision]
|
||||
utils.check_call(cmd, logger)
|
||||
utils.check_call(cmd)
|
||||
cmd = ['git', '-C', path, 'rev-parse', 'FETCH_HEAD^2']
|
||||
parent_revision = utils.check_output(cmd, logger).strip()
|
||||
parent_revision = utils.check_output(cmd).strip()
|
||||
except subprocess.CalledProcessError as error:
|
||||
logger.error(
|
||||
logging.error(
|
||||
'Failed to get parent of revision {rev}: {err}'.format(
|
||||
rev=revision, err=error))
|
||||
raise
|
||||
@@ -163,7 +161,7 @@ class GPLChecker(object):
|
||||
Raises:
|
||||
ValueError: There are GPL projects with unreleased sources.
|
||||
"""
|
||||
logger.info('Starting license check for GPL projects...')
|
||||
logging.info('Starting license check for GPL projects...')
|
||||
|
||||
notice_files = glob.glob('{}/*'.format(self._notice_files_dir))
|
||||
if len(notice_files) == 0:
|
||||
@@ -180,10 +178,10 @@ class GPLChecker(object):
|
||||
gpl_projects.append(lib_name)
|
||||
|
||||
if not gpl_projects:
|
||||
logger.info('No GPL projects found.')
|
||||
logging.info('No GPL projects found.')
|
||||
return
|
||||
|
||||
logger.info('GPL projects found: {}'.format(', '.join(gpl_projects)))
|
||||
logging.info('GPL projects found: {}'.format(', '.join(gpl_projects)))
|
||||
|
||||
module_paths = self._parse_module_paths()
|
||||
manifest_projects = self._parse_manifest()
|
||||
@@ -210,14 +208,14 @@ class GPLChecker(object):
|
||||
format(lib=lib, module_paths=self.MODULE_PATHS_TXT))
|
||||
|
||||
if released_projects:
|
||||
logger.info('Released GPL projects: {}'.format(released_projects))
|
||||
logging.info('Released GPL projects: {}'.format(released_projects))
|
||||
|
||||
if unreleased_projects:
|
||||
raise ValueError(
|
||||
('FAIL: The following GPL projects have NOT been released in '
|
||||
'current tree: {}'.format(unreleased_projects)))
|
||||
|
||||
logger.info('PASS: All GPL projects have source in current tree.')
|
||||
logging.info('PASS: All GPL projects have source in current tree.')
|
||||
|
||||
|
||||
def get_args():
|
||||
@@ -260,7 +258,7 @@ def main():
|
||||
os.chdir(temp_artifact_dir)
|
||||
manifest_pattern = 'manifest_{}.xml'.format(args.build)
|
||||
manifest_dest = os.path.join(temp_artifact_dir, utils.MANIFEST_FILE_NAME)
|
||||
logger.info('Fetching {file} from {branch} (bid: {build})'.format(
|
||||
logging.info('Fetching {file} from {branch} (bid: {build})'.format(
|
||||
file=manifest_pattern, branch=args.branch, build=args.build))
|
||||
utils.fetch_artifact(args.branch, args.build, manifest_pattern,
|
||||
manifest_dest)
|
||||
@@ -270,13 +268,14 @@ def main():
|
||||
try:
|
||||
license_checker.check_gpl_projects()
|
||||
except ValueError as error:
|
||||
logger.error('Error: {}'.format(error))
|
||||
logging.error('Error: {}'.format(error))
|
||||
raise
|
||||
finally:
|
||||
logger.info('Deleting temp_artifact_dir: {}'.format(temp_artifact_dir))
|
||||
logging.info(
|
||||
'Deleting temp_artifact_dir: {}'.format(temp_artifact_dir))
|
||||
shutil.rmtree(temp_artifact_dir)
|
||||
|
||||
logger.info('Done.')
|
||||
logging.info('Done.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -23,14 +23,12 @@ import sys
|
||||
|
||||
import utils
|
||||
|
||||
logger = utils.logger(__name__)
|
||||
|
||||
|
||||
class GenBuildFile(object):
|
||||
"""Generates Android.mk and Android.bp for VNDK snapshot.
|
||||
|
||||
VNDK snapshot directory structure under prebuilts/vndk/v{version}:
|
||||
{SNAPSHOT_VARIANT}/
|
||||
{SNAPSHOT_ARCH}/
|
||||
Android.bp
|
||||
arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
|
||||
shared/
|
||||
@@ -44,9 +42,15 @@ class GenBuildFile(object):
|
||||
(VNDK-core libraries, e.g. libbinder.so)
|
||||
vndk-sp/
|
||||
(VNDK-SP libraries, e.g. libc++.so)
|
||||
binder32/
|
||||
(This directory is newly introduced in v28 (Android P) to hold
|
||||
prebuilts built for 32-bit binder interface.)
|
||||
Android.bp
|
||||
arch-{TARGET_ARCH}-{TARGE_ARCH_VARIANT}/
|
||||
...
|
||||
configs/
|
||||
(various *.txt configuration files, e.g. ld.config.*.txt)
|
||||
... (other {SNAPSHOT_VARIANT}/ directories)
|
||||
... (other {SNAPSHOT_ARCH}/ directories)
|
||||
common/
|
||||
Android.mk
|
||||
NOTICE_FILES/
|
||||
@@ -71,7 +75,7 @@ class GenBuildFile(object):
|
||||
self._install_dir = install_dir
|
||||
self._vndk_version = vndk_version
|
||||
self._etc_paths = self._get_etc_paths()
|
||||
self._snapshot_variants = utils.get_snapshot_variants(install_dir)
|
||||
self._snapshot_archs = utils.get_snapshot_archs(install_dir)
|
||||
self._mkfile = os.path.join(install_dir, utils.ANDROID_MK_PATH)
|
||||
self._vndk_core = self._parse_lib_list('vndkcore.libraries.txt')
|
||||
self._vndk_sp = self._parse_lib_list(
|
||||
@@ -92,7 +96,7 @@ class GenBuildFile(object):
|
||||
return etc_paths
|
||||
|
||||
def _parse_lib_list(self, txt_filename):
|
||||
"""Returns a map of VNDK library lists per VNDK snapshot variant.
|
||||
"""Returns a map of VNDK library lists per VNDK snapshot arch.
|
||||
|
||||
Args:
|
||||
txt_filename: string, name of snapshot config file
|
||||
@@ -102,15 +106,17 @@ class GenBuildFile(object):
|
||||
"""
|
||||
lib_map = dict()
|
||||
for txt_path in utils.find(self._install_dir, [txt_filename]):
|
||||
variant = utils.variant_from_path(txt_path)
|
||||
arch = utils.snapshot_arch_from_path(txt_path)
|
||||
abs_path_of_txt = os.path.join(self._install_dir, txt_path)
|
||||
with open(abs_path_of_txt, 'r') as f:
|
||||
lib_map[variant] = f.read().strip().split('\n')
|
||||
lib_map[arch] = f.read().strip().split('\n')
|
||||
return lib_map
|
||||
|
||||
def generate_android_mk(self):
|
||||
"""Autogenerates Android.mk."""
|
||||
|
||||
logging.info('Generating Android.mk for snapshot v{}'.format(
|
||||
self._vndk_version))
|
||||
etc_buildrules = []
|
||||
for prebuilt in self.ETC_MODULES:
|
||||
etc_buildrules.append(self._gen_etc_prebuilt(prebuilt))
|
||||
@@ -123,49 +129,104 @@ class GenBuildFile(object):
|
||||
mkfile.write('\n\n'.join(etc_buildrules))
|
||||
mkfile.write('\n')
|
||||
|
||||
logging.info('Successfully generated {}'.format(self._mkfile))
|
||||
|
||||
def generate_android_bp(self):
|
||||
"""Autogenerates Android.bp file for each VNDK snapshot variant."""
|
||||
"""Autogenerates Android.bp."""
|
||||
|
||||
def gen_for_variant(arch, is_binder32=False):
|
||||
"""Generates Android.bp file for specified VNDK snapshot variant.
|
||||
|
||||
A VNDK snapshot variant is defined by the TARGET_ARCH and binder
|
||||
bitness. Example snapshot variants:
|
||||
vndk_v{ver}_arm: {arch: arm, binder: 64-bit}
|
||||
vndk_v{ver}_arm_binder32: {arch: arm, binder: 32-bit}
|
||||
|
||||
Args:
|
||||
arch: string, VNDK snapshot arch (e.g. 'arm64')
|
||||
is_binder32: bool, True if binder interface is 32-bit
|
||||
"""
|
||||
binder32_suffix = '_{}'.format(
|
||||
utils.BINDER32) if is_binder32 else ''
|
||||
logging.info('Generating Android.bp for vndk_v{}_{}{}'.format(
|
||||
self._vndk_version, arch, binder32_suffix))
|
||||
|
||||
variant_subpath = arch
|
||||
# For O-MR1 snapshot (v27), 32-bit binder prebuilts are not
|
||||
# isolated in separate 'binder32' subdirectory.
|
||||
if is_binder32 and self._vndk_version >= 28:
|
||||
variant_subpath = os.path.join(arch, utils.BINDER32)
|
||||
bpfile_path = os.path.join(self._install_dir, variant_subpath,
|
||||
'Android.bp')
|
||||
|
||||
for variant in self._snapshot_variants:
|
||||
bpfile = os.path.join(self._install_dir, variant, 'Android.bp')
|
||||
vndk_core_buildrules = self._gen_vndk_shared_prebuilts(
|
||||
self._vndk_core[variant], variant, False)
|
||||
self._vndk_core[arch], arch, is_binder32=is_binder32)
|
||||
vndk_sp_buildrules = self._gen_vndk_shared_prebuilts(
|
||||
self._vndk_sp[variant], variant, True)
|
||||
self._vndk_sp[arch],
|
||||
arch,
|
||||
is_vndk_sp=True,
|
||||
is_binder32=is_binder32)
|
||||
|
||||
with open(bpfile, 'w') as bpfile:
|
||||
with open(bpfile_path, 'w') as bpfile:
|
||||
bpfile.write(self._gen_autogen_msg('/'))
|
||||
bpfile.write('\n')
|
||||
bpfile.write(self._gen_bp_phony(variant))
|
||||
bpfile.write(self._gen_bp_phony(arch, is_binder32))
|
||||
bpfile.write('\n')
|
||||
bpfile.write('\n'.join(vndk_core_buildrules))
|
||||
bpfile.write('\n')
|
||||
bpfile.write('\n'.join(vndk_sp_buildrules))
|
||||
|
||||
logging.info('Successfully generated {}'.format(bpfile_path))
|
||||
|
||||
if self._vndk_version == 27:
|
||||
# For O-MR1 snapshot (v27), 32-bit binder prebuilts are not
|
||||
# isolated in separate 'binder32' subdirectory.
|
||||
for arch in self._snapshot_archs:
|
||||
if arch in ('arm', 'x86'):
|
||||
gen_for_variant(arch, is_binder32=True)
|
||||
else:
|
||||
gen_for_variant(arch)
|
||||
return
|
||||
|
||||
for arch in self._snapshot_archs:
|
||||
if os.path.isdir(
|
||||
os.path.join(self._install_dir, arch, utils.BINDER32)):
|
||||
gen_for_variant(arch, is_binder32=True)
|
||||
gen_for_variant(arch)
|
||||
|
||||
def _gen_autogen_msg(self, comment_char):
|
||||
return ('{0}{0} THIS FILE IS AUTOGENERATED BY '
|
||||
'development/vndk/snapshot/gen_buildfiles.py\n'
|
||||
'{0}{0} DO NOT EDIT\n'.format(comment_char))
|
||||
|
||||
def _get_versioned_name(self, prebuilt, variant, is_etc):
|
||||
def _get_versioned_name(self,
|
||||
prebuilt,
|
||||
arch,
|
||||
is_etc=False,
|
||||
is_binder32=False):
|
||||
"""Returns the VNDK version-specific module name for a given prebuilt.
|
||||
|
||||
The VNDK version-specific module name is defined as follows:
|
||||
For a VNDK shared lib: 'libfoo.so'
|
||||
-> 'libfoo.vndk.{version}.{variant}.vendor'
|
||||
if binder is 32-bit:
|
||||
'libfoo.vndk.{version}.{arch}.binder32.vendor'
|
||||
else:
|
||||
'libfoo.vndk.{version}.{arch}.vendor'
|
||||
For an ETC module: 'foo.txt' -> 'foo.{version}.txt'
|
||||
|
||||
Args:
|
||||
prebuilt: string, name of the prebuilt object
|
||||
variant: string, VNDK snapshot variant (e.g. 'arm64')
|
||||
arch: string, VNDK snapshot arch (e.g. 'arm64')
|
||||
is_etc: bool, True if the LOCAL_MODULE_CLASS of prebuilt is 'ETC'
|
||||
is_binder32: bool, True if binder interface is 32-bit
|
||||
"""
|
||||
name, ext = os.path.splitext(prebuilt)
|
||||
if is_etc:
|
||||
versioned_name = '{}.{}{}'.format(name, self._vndk_version, ext)
|
||||
else:
|
||||
versioned_name = '{}.vndk.{}.{}.vendor'.format(
|
||||
name, self._vndk_version, variant)
|
||||
binder_suffix = '.{}'.format(utils.BINDER32) if is_binder32 else ''
|
||||
versioned_name = '{}.vndk.{}.{}{}.vendor'.format(
|
||||
name, self._vndk_version, arch, binder_suffix)
|
||||
|
||||
return versioned_name
|
||||
|
||||
@@ -189,23 +250,27 @@ class GenBuildFile(object):
|
||||
'include $(BUILD_PREBUILT)\n'.format(
|
||||
prebuilt=prebuilt,
|
||||
versioned_name=self._get_versioned_name(
|
||||
prebuilt, None, True),
|
||||
prebuilt, None, is_etc=True),
|
||||
etc_sub_path=etc_sub_path))
|
||||
|
||||
def _gen_bp_phony(self, variant):
|
||||
"""Generates build rule for phony package 'vndk_v{ver}_{variant}'.
|
||||
def _gen_bp_phony(self, arch, is_binder32=False):
|
||||
"""Generates build rule for phony package 'vndk_v{ver}_{arch}'.
|
||||
|
||||
Args:
|
||||
variant: string, VNDK snapshot variant (e.g. 'arm64')
|
||||
arch: string, VNDK snapshot arch (e.g. 'arm64')
|
||||
is_binder32: bool, True if binder interface is 32-bit
|
||||
"""
|
||||
required = []
|
||||
for prebuilts in (self._vndk_core[variant], self._vndk_sp[variant]):
|
||||
for prebuilts in (self._vndk_core[arch], self._vndk_sp[arch]):
|
||||
for prebuilt in prebuilts:
|
||||
required.append(
|
||||
self._get_versioned_name(prebuilt, variant, False))
|
||||
self._get_versioned_name(
|
||||
prebuilt, arch, is_binder32=is_binder32))
|
||||
|
||||
for prebuilt in self.ETC_MODULES:
|
||||
required.append(self._get_versioned_name(prebuilt, None, True))
|
||||
required.append(
|
||||
self._get_versioned_name(
|
||||
prebuilt, None, is_etc=True, is_binder32=is_binder32))
|
||||
|
||||
required_str = ['"{}",'.format(prebuilt) for prebuilt in required]
|
||||
required_formatted = '\n{ind}{ind}'.format(
|
||||
@@ -215,37 +280,53 @@ class GenBuildFile(object):
|
||||
'{ind}],\n'.format(
|
||||
ind=self.INDENT,
|
||||
required_formatted=required_formatted))
|
||||
binder_suffix = '_{}'.format(utils.BINDER32) if is_binder32 else ''
|
||||
|
||||
return ('phony {{\n'
|
||||
'{ind}name: "vndk_v{ver}_{variant}",\n'
|
||||
'{ind}name: "vndk_v{ver}_{arch}{binder_suffix}",\n'
|
||||
'{required_buildrule}'
|
||||
'}}\n'.format(
|
||||
ind=self.INDENT,
|
||||
ver=self._vndk_version,
|
||||
variant=variant,
|
||||
arch=arch,
|
||||
binder_suffix=binder_suffix,
|
||||
required_buildrule=required_buildrule))
|
||||
|
||||
def _gen_vndk_shared_prebuilts(self, prebuilts, variant, is_vndk_sp):
|
||||
def _gen_vndk_shared_prebuilts(self,
|
||||
prebuilts,
|
||||
arch,
|
||||
is_vndk_sp=False,
|
||||
is_binder32=False):
|
||||
"""Returns list of build rules for given prebuilts.
|
||||
|
||||
Args:
|
||||
prebuilts: list of VNDK shared prebuilts
|
||||
variant: string, VNDK snapshot variant (e.g. 'arm64')
|
||||
arch: string, VNDK snapshot arch (e.g. 'arm64')
|
||||
is_vndk_sp: bool, True if prebuilts are VNDK_SP libs
|
||||
is_binder32: bool, True if binder interface is 32-bit
|
||||
"""
|
||||
build_rules = []
|
||||
for prebuilt in prebuilts:
|
||||
build_rules.append(
|
||||
self._gen_vndk_shared_prebuilt(prebuilt, variant, is_vndk_sp))
|
||||
self._gen_vndk_shared_prebuilt(
|
||||
prebuilt,
|
||||
arch,
|
||||
is_vndk_sp=is_vndk_sp,
|
||||
is_binder32=is_binder32))
|
||||
return build_rules
|
||||
|
||||
def _gen_vndk_shared_prebuilt(self, prebuilt, variant, is_vndk_sp):
|
||||
def _gen_vndk_shared_prebuilt(self,
|
||||
prebuilt,
|
||||
arch,
|
||||
is_vndk_sp=False,
|
||||
is_binder32=False):
|
||||
"""Returns build rule for given prebuilt.
|
||||
|
||||
Args:
|
||||
prebuilt: string, name of prebuilt object
|
||||
variant: string, VNDK snapshot variant (e.g. 'arm64')
|
||||
arch: string, VNDK snapshot arch (e.g. 'arm64')
|
||||
is_vndk_sp: bool, True if prebuilt is a VNDK_SP lib
|
||||
is_binder32: bool, True if binder interface is 32-bit
|
||||
"""
|
||||
|
||||
def get_notice_file(prebuilt):
|
||||
@@ -256,14 +337,16 @@ class GenBuildFile(object):
|
||||
"""
|
||||
notice = ''
|
||||
notice_file_name = '{}.txt'.format(prebuilt)
|
||||
notices_dir = os.path.join(self._install_dir,
|
||||
utils.NOTICE_FILES_DIR_PATH)
|
||||
notice_files = utils.find(notices_dir, [notice_file_name])
|
||||
notice_dir = os.path.join(self._install_dir,
|
||||
utils.NOTICE_FILES_DIR_PATH)
|
||||
notice_files = utils.find(notice_dir, [notice_file_name])
|
||||
if len(notice_files) > 0:
|
||||
notice_dir_relpath = os.path.relpath(
|
||||
os.path.join(notice_dir), src_root)
|
||||
notice = '{ind}notice: "{notice_file_path}",\n'.format(
|
||||
ind=self.INDENT,
|
||||
notice_file_path=os.path.join(
|
||||
'..', utils.NOTICE_FILES_DIR_PATH, notice_files[0]))
|
||||
notice_file_path=os.path.join(notice_dir_relpath,
|
||||
notice_files[0]))
|
||||
return notice
|
||||
|
||||
def get_rel_install_path(prebuilt):
|
||||
@@ -279,7 +362,7 @@ class GenBuildFile(object):
|
||||
.format(ind=self.INDENT, path=path))
|
||||
return rel_install_path
|
||||
|
||||
def get_arch_srcs(prebuilt, variant):
|
||||
def get_arch_srcs(prebuilt, arch):
|
||||
"""Returns build rule for arch specific srcs.
|
||||
|
||||
e.g.,
|
||||
@@ -294,38 +377,53 @@ class GenBuildFile(object):
|
||||
|
||||
Args:
|
||||
prebuilt: string, name of prebuilt object
|
||||
variant: string, VNDK snapshot variant (e.g. 'arm64')
|
||||
arch: string, VNDK snapshot arch (e.g. 'arm64')
|
||||
"""
|
||||
arch_srcs = '{ind}arch: {{\n'.format(ind=self.INDENT)
|
||||
variant_path = os.path.join(self._install_dir, variant)
|
||||
src_paths = utils.find(variant_path, [prebuilt])
|
||||
src_paths = utils.find(src_root, [prebuilt])
|
||||
# filter out paths under 'binder32' subdirectory
|
||||
src_paths = filter(lambda src: not src.startswith(utils.BINDER32),
|
||||
src_paths)
|
||||
|
||||
for src in sorted(src_paths):
|
||||
arch_srcs += ('{ind}{ind}{arch}: {{\n'
|
||||
'{ind}{ind}{ind}srcs: ["{src}"],\n'
|
||||
'{ind}{ind}}},\n'.format(
|
||||
ind=self.INDENT,
|
||||
arch=utils.arch_from_path(
|
||||
os.path.join(variant, src)),
|
||||
arch=utils.prebuilt_arch_from_path(
|
||||
os.path.join(arch, src)),
|
||||
src=src))
|
||||
arch_srcs += '{ind}}},\n'.format(ind=self.INDENT)
|
||||
return arch_srcs
|
||||
|
||||
src_root = os.path.join(self._install_dir, arch)
|
||||
# For O-MR1 snapshot (v27), 32-bit binder prebuilts are not
|
||||
# isolated in separate 'binder32' subdirectory.
|
||||
if is_binder32 and self._vndk_version >= 28:
|
||||
src_root = os.path.join(src_root, utils.BINDER32)
|
||||
|
||||
name = os.path.splitext(prebuilt)[0]
|
||||
vendor_available = str(
|
||||
prebuilt not in self._vndk_private[variant]).lower()
|
||||
prebuilt not in self._vndk_private[arch]).lower()
|
||||
|
||||
vndk_sp = ''
|
||||
if is_vndk_sp:
|
||||
vndk_sp = '{ind}{ind}support_system_process: true,\n'.format(
|
||||
ind=self.INDENT)
|
||||
else:
|
||||
vndk_sp = ''
|
||||
|
||||
notice = get_notice_file(prebuilt)
|
||||
rel_install_path = get_rel_install_path(prebuilt)
|
||||
arch_srcs = get_arch_srcs(prebuilt, variant)
|
||||
arch_srcs = get_arch_srcs(prebuilt, arch)
|
||||
|
||||
binder32bit = ''
|
||||
if is_binder32:
|
||||
binder32bit = '{ind}binder32bit: true,\n'.format(ind=self.INDENT)
|
||||
|
||||
return ('vndk_prebuilt_shared {{\n'
|
||||
'{ind}name: "{name}",\n'
|
||||
'{ind}version: "{ver}",\n'
|
||||
'{ind}target_arch: "{target_arch}",\n'
|
||||
'{binder32bit}'
|
||||
'{ind}vendor_available: {vendor_available},\n'
|
||||
'{ind}vndk: {{\n'
|
||||
'{ind}{ind}enabled: true,\n'
|
||||
@@ -338,8 +436,9 @@ class GenBuildFile(object):
|
||||
ind=self.INDENT,
|
||||
name=name,
|
||||
ver=self._vndk_version,
|
||||
target_arch=arch,
|
||||
binder32bit=binder32bit,
|
||||
vendor_available=vendor_available,
|
||||
target_arch=variant,
|
||||
vndk_sp=vndk_sp,
|
||||
notice=notice,
|
||||
rel_install_path=rel_install_path,
|
||||
@@ -384,7 +483,7 @@ def main():
|
||||
buildfile_generator.generate_android_mk()
|
||||
buildfile_generator.generate_android_bp()
|
||||
|
||||
logger.info('Done.')
|
||||
logging.info('Done.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -35,18 +35,16 @@ from gen_buildfiles import GenBuildFile
|
||||
ANDROID_BUILD_TOP = utils.get_android_build_top()
|
||||
PREBUILTS_VNDK_DIR = utils.join_realpath(ANDROID_BUILD_TOP, 'prebuilts/vndk')
|
||||
|
||||
logger = utils.logger(__name__)
|
||||
|
||||
|
||||
def start_branch(build):
|
||||
branch_name = 'update-' + (build or 'local')
|
||||
logger.info('Creating branch {branch} in {dir}'.format(
|
||||
logging.info('Creating branch {branch} in {dir}'.format(
|
||||
branch=branch_name, dir=os.getcwd()))
|
||||
utils.check_call(['repo', 'start', branch_name, '.'], logger)
|
||||
utils.check_call(['repo', 'start', branch_name, '.'])
|
||||
|
||||
|
||||
def remove_old_snapshot(install_dir):
|
||||
logger.info('Removing any old files in {}'.format(install_dir))
|
||||
logging.info('Removing any old files in {}'.format(install_dir))
|
||||
for file in glob.glob('{}/*'.format(install_dir)):
|
||||
try:
|
||||
if os.path.isfile(file):
|
||||
@@ -54,7 +52,7 @@ def remove_old_snapshot(install_dir):
|
||||
elif os.path.isdir(file):
|
||||
shutil.rmtree(file)
|
||||
except Exception as error:
|
||||
logger.error('Error: {}'.format(error))
|
||||
logging.error('Error: {}'.format(error))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -77,45 +75,44 @@ def install_snapshot(branch, build, local_dir, install_dir, temp_artifact_dir):
|
||||
if branch and build:
|
||||
artifact_dir = temp_artifact_dir
|
||||
os.chdir(temp_artifact_dir)
|
||||
logger.info('Fetching {pattern} from {branch} (bid: {build})'.format(
|
||||
logging.info('Fetching {pattern} from {branch} (bid: {build})'.format(
|
||||
pattern=artifact_pattern, branch=branch, build=build))
|
||||
utils.fetch_artifact(branch, build, artifact_pattern)
|
||||
|
||||
manifest_pattern = 'manifest_{}.xml'.format(build)
|
||||
logger.info('Fetching {file} from {branch} (bid: {build})'.format(
|
||||
logging.info('Fetching {file} from {branch} (bid: {build})'.format(
|
||||
file=manifest_pattern, branch=branch, build=build))
|
||||
utils.fetch_artifact(branch, build, manifest_pattern,
|
||||
utils.MANIFEST_FILE_NAME)
|
||||
|
||||
os.chdir(install_dir)
|
||||
elif local_dir:
|
||||
logger.info('Fetching local VNDK snapshot from {}'.format(local_dir))
|
||||
logging.info('Fetching local VNDK snapshot from {}'.format(local_dir))
|
||||
artifact_dir = local_dir
|
||||
|
||||
artifacts = glob.glob(os.path.join(artifact_dir, artifact_pattern))
|
||||
for artifact in artifacts:
|
||||
logger.info('Unzipping VNDK snapshot: {}'.format(artifact))
|
||||
utils.check_call(['unzip', '-qn', artifact, '-d', install_dir], logger)
|
||||
logging.info('Unzipping VNDK snapshot: {}'.format(artifact))
|
||||
utils.check_call(['unzip', '-qn', artifact, '-d', install_dir])
|
||||
|
||||
|
||||
def gather_notice_files(install_dir):
|
||||
"""Gathers all NOTICE files to a common NOTICE_FILES directory."""
|
||||
|
||||
common_notices_dir = utils.NOTICE_FILES_DIR_PATH
|
||||
logger.info('Creating {} directory to gather all NOTICE files...'.format(
|
||||
logging.info('Creating {} directory to gather all NOTICE files...'.format(
|
||||
common_notices_dir))
|
||||
os.makedirs(common_notices_dir)
|
||||
for variant in utils.get_snapshot_variants(install_dir):
|
||||
notices_dir_per_variant = os.path.join(variant,
|
||||
utils.NOTICE_FILES_DIR_NAME)
|
||||
if os.path.isdir(notices_dir_per_variant):
|
||||
for arch in utils.get_snapshot_archs(install_dir):
|
||||
notices_dir_per_arch = os.path.join(arch, utils.NOTICE_FILES_DIR_NAME)
|
||||
if os.path.isdir(notices_dir_per_arch):
|
||||
for notice_file in glob.glob(
|
||||
'{}/*.txt'.format(notices_dir_per_variant)):
|
||||
'{}/*.txt'.format(notices_dir_per_arch)):
|
||||
if not os.path.isfile(
|
||||
os.path.join(common_notices_dir,
|
||||
os.path.basename(notice_file))):
|
||||
shutil.copy(notice_file, common_notices_dir)
|
||||
shutil.rmtree(notices_dir_per_variant)
|
||||
shutil.rmtree(notices_dir_per_arch)
|
||||
|
||||
|
||||
def revise_ld_config_txt_if_needed(vndk_version):
|
||||
@@ -125,10 +122,10 @@ def revise_ld_config_txt_if_needed(vndk_version):
|
||||
Versioned VNDK directories: /system/${LIB}/vndk[-sp]-27
|
||||
|
||||
Args:
|
||||
vndk_version: string, version of VNDK snapshot
|
||||
vndk_version: int, version of VNDK snapshot
|
||||
"""
|
||||
logger.info('Revising ld.config.txt for O-MR1...')
|
||||
if vndk_version == '27':
|
||||
if vndk_version == 27:
|
||||
logging.info('Revising ld.config.txt for O-MR1...')
|
||||
re_pattern = '(system\/\${LIB}\/vndk(?:-sp)?)([:/]|$)'
|
||||
VNDK_INSTALL_DIR_RE = re.compile(re_pattern, flags=re.MULTILINE)
|
||||
ld_config_txt_paths = glob.glob(
|
||||
@@ -141,10 +138,10 @@ def revise_ld_config_txt_if_needed(vndk_version):
|
||||
|
||||
|
||||
def update_buildfiles(buildfile_generator):
|
||||
logger.info('Generating Android.mk file...')
|
||||
logging.info('Generating Android.mk file...')
|
||||
buildfile_generator.generate_android_mk()
|
||||
|
||||
logger.info('Generating Android.bp files...')
|
||||
logging.info('Generating Android.bp files...')
|
||||
buildfile_generator.generate_android_bp()
|
||||
|
||||
|
||||
@@ -152,19 +149,19 @@ def check_gpl_license(license_checker):
|
||||
try:
|
||||
license_checker.check_gpl_projects()
|
||||
except ValueError as error:
|
||||
logger.error('***CANNOT INSTALL VNDK SNAPSHOT***: {}'.format(error))
|
||||
logging.error('***CANNOT INSTALL VNDK SNAPSHOT***: {}'.format(error))
|
||||
raise
|
||||
|
||||
|
||||
def commit(branch, build, version):
|
||||
logger.info('Making commit...')
|
||||
utils.check_call(['git', 'add', '.'], logger)
|
||||
logging.info('Making commit...')
|
||||
utils.check_call(['git', 'add', '.'])
|
||||
message = textwrap.dedent("""\
|
||||
Update VNDK snapshot v{version} to build {build}.
|
||||
|
||||
Taken from branch {branch}.""").format(
|
||||
version=version, branch=branch, build=build)
|
||||
utils.check_call(['git', 'commit', '-m', message], logger)
|
||||
utils.check_call(['git', 'commit', '-m', message])
|
||||
|
||||
|
||||
def get_args():
|
||||
@@ -197,22 +194,26 @@ def main():
|
||||
"""Program entry point."""
|
||||
args = get_args()
|
||||
|
||||
local = None
|
||||
if args.local:
|
||||
local = os.path.expanduser(args.local)
|
||||
|
||||
if local:
|
||||
if args.build or args.branch:
|
||||
raise ValueError(
|
||||
'When --local option is set, --branch or --build cannot be '
|
||||
'specified.')
|
||||
elif not os.path.isdir(args.local):
|
||||
elif not os.path.isdir(local):
|
||||
raise RuntimeError(
|
||||
'The specified local directory, {}, does not exist.'.format(
|
||||
args.local))
|
||||
local))
|
||||
else:
|
||||
if not (args.build and args.branch):
|
||||
raise ValueError(
|
||||
'Please provide both --branch and --build or set --local '
|
||||
'option.')
|
||||
|
||||
vndk_version = str(args.vndk_version)
|
||||
vndk_version = args.vndk_version
|
||||
|
||||
install_dir = os.path.join(PREBUILTS_VNDK_DIR, 'v{}'.format(vndk_version))
|
||||
if not os.path.isdir(install_dir):
|
||||
@@ -232,11 +233,11 @@ def main():
|
||||
os.makedirs(utils.COMMON_DIR_PATH)
|
||||
|
||||
temp_artifact_dir = None
|
||||
if not args.local:
|
||||
if not local:
|
||||
temp_artifact_dir = tempfile.mkdtemp()
|
||||
|
||||
try:
|
||||
install_snapshot(args.branch, args.build, args.local, install_dir,
|
||||
install_snapshot(args.branch, args.build, local, install_dir,
|
||||
temp_artifact_dir)
|
||||
gather_notice_files(install_dir)
|
||||
revise_ld_config_txt_if_needed(vndk_version)
|
||||
@@ -244,27 +245,28 @@ def main():
|
||||
buildfile_generator = GenBuildFile(install_dir, vndk_version)
|
||||
update_buildfiles(buildfile_generator)
|
||||
|
||||
if not args.local:
|
||||
if not local:
|
||||
license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP,
|
||||
temp_artifact_dir)
|
||||
check_gpl_license(license_checker)
|
||||
logger.info(
|
||||
logging.info(
|
||||
'Successfully updated VNDK snapshot v{}'.format(vndk_version))
|
||||
except Exception as error:
|
||||
logger.error('FAILED TO INSTALL SNAPSHOT: {}'.format(error))
|
||||
logging.error('FAILED TO INSTALL SNAPSHOT: {}'.format(error))
|
||||
raise
|
||||
finally:
|
||||
if temp_artifact_dir:
|
||||
logger.info(
|
||||
logging.info(
|
||||
'Deleting temp_artifact_dir: {}'.format(temp_artifact_dir))
|
||||
shutil.rmtree(temp_artifact_dir)
|
||||
|
||||
if not args.local:
|
||||
if not local:
|
||||
commit(args.branch, args.build, vndk_version)
|
||||
logger.info('Successfully created commit for VNDK snapshot v{}'.format(
|
||||
vndk_version))
|
||||
logging.info(
|
||||
'Successfully created commit for VNDK snapshot v{}'.format(
|
||||
vndk_version))
|
||||
|
||||
logger.info('Done.')
|
||||
logging.info('Done.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -33,10 +33,7 @@ MANIFEST_FILE_NAME = 'manifest.xml'
|
||||
MODULE_PATHS_FILE_NAME = 'module_paths.txt'
|
||||
NOTICE_FILES_DIR_NAME = 'NOTICE_FILES'
|
||||
NOTICE_FILES_DIR_PATH = os.path.join(COMMON_DIR_PATH, NOTICE_FILES_DIR_NAME)
|
||||
|
||||
|
||||
def logger(name):
|
||||
return logging.getLogger(name)
|
||||
BINDER32 = 'binder32'
|
||||
|
||||
|
||||
def set_logging_config(verbose_level):
|
||||
@@ -47,17 +44,15 @@ def set_logging_config(verbose_level):
|
||||
level=verbose_map[verbosity])
|
||||
|
||||
|
||||
def check_call(cmd, logger=None):
|
||||
logger = logger or logging
|
||||
logger.debug('Running `{}`'.format(' '.join(cmd)))
|
||||
def check_call(cmd):
|
||||
logging.debug('Running `{}`'.format(' '.join(cmd)))
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
|
||||
def check_output(cmd, logger=None):
|
||||
logger = logger or logging
|
||||
logger.debug('Running `{}`'.format(' '.join(cmd)))
|
||||
def check_output(cmd):
|
||||
logging.debug('Running `{}`'.format(' '.join(cmd)))
|
||||
output = subprocess.check_output(cmd)
|
||||
logger.debug('Output: `{}`'.format(output))
|
||||
logging.debug('Output: `{}`'.format(output))
|
||||
return output
|
||||
|
||||
|
||||
@@ -87,21 +82,21 @@ def get_dist_dir(out_dir):
|
||||
return _get_dir_from_env('DIST_DIR', join_realpath(out_dir, 'dist'))
|
||||
|
||||
|
||||
def get_snapshot_variants(install_dir):
|
||||
"""Returns a list of VNDK snapshot variants under install_dir.
|
||||
def get_snapshot_archs(install_dir):
|
||||
"""Returns a list of VNDK snapshot arch flavors under install_dir.
|
||||
|
||||
Args:
|
||||
install_dir: string, absolute path of prebuilts/vndk/v{version}
|
||||
"""
|
||||
variants = []
|
||||
archs = []
|
||||
for file in glob.glob('{}/*'.format(install_dir)):
|
||||
basename = os.path.basename(file)
|
||||
if os.path.isdir(file) and basename != COMMON_DIR_NAME:
|
||||
variants.append(basename)
|
||||
return variants
|
||||
archs.append(basename)
|
||||
return archs
|
||||
|
||||
|
||||
def arch_from_path(path):
|
||||
def prebuilt_arch_from_path(path):
|
||||
"""Extracts arch of prebuilts from path relative to install_dir.
|
||||
|
||||
Args:
|
||||
@@ -113,14 +108,14 @@ def arch_from_path(path):
|
||||
return path.split('/')[1].split('-')[1]
|
||||
|
||||
|
||||
def variant_from_path(path):
|
||||
"""Extracts VNDK snapshot variant from path relative to install_dir.
|
||||
def snapshot_arch_from_path(path):
|
||||
"""Extracts VNDK snapshot arch from path relative to install_dir.
|
||||
|
||||
Args:
|
||||
path: string, path relative to prebuilts/vndk/v{version}
|
||||
|
||||
Returns:
|
||||
string, VNDK snapshot variant (e.g. 'arm64')
|
||||
string, VNDK snapshot arch (e.g. 'arm64')
|
||||
"""
|
||||
return path.split('/')[0]
|
||||
|
||||
@@ -156,4 +151,4 @@ def fetch_artifact(branch, build, pattern, destination='.'):
|
||||
fetch_artifact_path, '--branch', branch, '--target=vndk', '--bid',
|
||||
build, pattern, destination
|
||||
]
|
||||
check_call(cmd, logger(__name__))
|
||||
check_call(cmd)
|
||||
|
||||
Reference in New Issue
Block a user