Merge "Add 'notice' attribute to prebuilts in Android.bp"
This commit is contained in:
@@ -126,7 +126,6 @@ class GenBuildFile(object):
|
||||
Args:
|
||||
prebuilt: string, name of ETC prebuilt object
|
||||
"""
|
||||
|
||||
etc_path = find(self._install_dir, prebuilt)[0]
|
||||
etc_sub_path = etc_path[etc_path.index('/') + 1:]
|
||||
|
||||
@@ -194,6 +193,36 @@ class GenBuildFile(object):
|
||||
prebuilt: string, name of prebuilt object
|
||||
is_vndk_sp: bool, True if prebuilt is a VNDK_SP lib
|
||||
"""
|
||||
def get_notice_file(prebuilt):
|
||||
"""Returns build rule for notice file (attribute 'notice').
|
||||
|
||||
Args:
|
||||
prebuilt: string, name of prebuilt object
|
||||
"""
|
||||
notice = ''
|
||||
notice_file_name = '{}.txt'.format(prebuilt)
|
||||
notices_dir = os.path.join(self._install_dir, 'NOTICE_FILES')
|
||||
notice_files = find(notices_dir, [notice_file_name])
|
||||
if len(notice_files) > 0:
|
||||
notice = '{ind}notice: "{notice_file_path}",\n'.format(
|
||||
ind=self.INDENT,
|
||||
notice_file_path=os.path.join(
|
||||
'NOTICE_FILES', notice_files[0]))
|
||||
return notice
|
||||
|
||||
def get_rel_install_path(prebuilt):
|
||||
"""Returns build rule for 'relative_install_path'.
|
||||
|
||||
Args:
|
||||
prebuilt: string, name of prebuilt object
|
||||
"""
|
||||
rel_install_path = ''
|
||||
if prebuilt in self.RELATIVE_INSTALL_PATHS:
|
||||
path = self.RELATIVE_INSTALL_PATHS[prebuilt]
|
||||
rel_install_path += ('{ind}relative_install_path: "{path}",\n'
|
||||
.format(ind=self.INDENT, path=path))
|
||||
return rel_install_path
|
||||
|
||||
def get_arch_srcs(prebuilt):
|
||||
"""Returns build rule for arch specific srcs.
|
||||
|
||||
@@ -225,19 +254,6 @@ class GenBuildFile(object):
|
||||
arch_srcs += '{ind}}},\n'.format(ind=self.INDENT)
|
||||
return arch_srcs
|
||||
|
||||
def get_rel_install_path(prebuilt):
|
||||
"""Returns build rule for 'relative_install_path'.
|
||||
|
||||
Args:
|
||||
prebuilt: string, name of prebuilt object
|
||||
"""
|
||||
rel_install_path = ''
|
||||
if prebuilt in self.RELATIVE_INSTALL_PATHS:
|
||||
path = self.RELATIVE_INSTALL_PATHS[prebuilt]
|
||||
rel_install_path += ('{ind}relative_install_path: "{path}",\n'
|
||||
.format(ind=self.INDENT, path=path))
|
||||
return rel_install_path
|
||||
|
||||
name = os.path.splitext(prebuilt)[0]
|
||||
vendor_available = 'false' if prebuilt in self._vndk_private else 'true'
|
||||
if is_vndk_sp:
|
||||
@@ -245,8 +261,9 @@ class GenBuildFile(object):
|
||||
ind=self.INDENT)
|
||||
else:
|
||||
vndk_sp = ''
|
||||
arch_srcs = get_arch_srcs(prebuilt)
|
||||
notice = get_notice_file(prebuilt)
|
||||
rel_install_path = get_rel_install_path(prebuilt)
|
||||
arch_srcs = get_arch_srcs(prebuilt)
|
||||
|
||||
return ('vndk_prebuilt_shared {{\n'
|
||||
'{ind}name: "{name}",\n'
|
||||
@@ -256,6 +273,7 @@ class GenBuildFile(object):
|
||||
'{ind}{ind}enabled: true,\n'
|
||||
'{vndk_sp}'
|
||||
'{ind}}},\n'
|
||||
'{notice}'
|
||||
'{rel_install_path}'
|
||||
'{arch_srcs}'
|
||||
'}}\n'.format(
|
||||
@@ -264,6 +282,7 @@ class GenBuildFile(object):
|
||||
ver=self._vndk_version,
|
||||
vendor_available=vendor_available,
|
||||
vndk_sp=vndk_sp,
|
||||
notice=notice,
|
||||
rel_install_path=rel_install_path,
|
||||
arch_srcs=arch_srcs))
|
||||
|
||||
|
||||
@@ -85,6 +85,16 @@ def remove_old_snapshot(install_dir):
|
||||
|
||||
|
||||
def install_snapshot(branch, build, install_dir):
|
||||
"""Installs VNDK snapshot build artifacts to prebuilts/vndk/v{version}.
|
||||
|
||||
1) Fetch build artifacts from Android Build server or from local DIST_DIR
|
||||
2) Unzip build artifacts
|
||||
|
||||
Args:
|
||||
branch: string or None, branch name of build artifacts
|
||||
build: string or None, build number of build artifacts
|
||||
install_dir: string, directory to install VNDK snapshot
|
||||
"""
|
||||
artifact_pattern = 'android-vndk-*.zip'
|
||||
|
||||
try:
|
||||
@@ -125,16 +135,36 @@ def install_snapshot(branch, build, install_dir):
|
||||
shutil.rmtree(tempdir)
|
||||
|
||||
|
||||
def gather_notice_files():
|
||||
"""Gathers all NOTICE files to a new NOTICE_FILES directory.
|
||||
|
||||
Create a new NOTICE_FILES directory under install_dir and copy to it
|
||||
all NOTICE files in arch-*/NOTICE_FILES.
|
||||
"""
|
||||
notices_dir_name = 'NOTICE_FILES'
|
||||
logger().info('Creating {} directory...'.format(notices_dir_name))
|
||||
os.makedirs(notices_dir_name)
|
||||
for arch_dir in glob.glob('arch-*'):
|
||||
notices_dir_per_arch = os.path.join(arch_dir, notices_dir_name)
|
||||
if os.path.isdir(notices_dir_per_arch):
|
||||
for notice_file in glob.glob(
|
||||
'{}/*.txt'.format(notices_dir_per_arch)):
|
||||
if not os.path.isfile(os.path.join(notices_dir_name,
|
||||
os.path.basename(notice_file))):
|
||||
shutil.copy(notice_file, notices_dir_name)
|
||||
shutil.rmtree(notices_dir_per_arch)
|
||||
|
||||
|
||||
def update_buildfiles(buildfile_generator):
|
||||
logger().info('Updating Android.mk')
|
||||
logger().info('Updating Android.mk...')
|
||||
buildfile_generator.generate_android_mk()
|
||||
|
||||
logger().info('Updating Android.bp')
|
||||
logger().info('Updating Android.bp...')
|
||||
buildfile_generator.generate_android_bp()
|
||||
|
||||
|
||||
def commit(branch, build, version):
|
||||
logger().info('Making commit')
|
||||
logger().info('Making commit...')
|
||||
check_call(['git', 'add', '.'])
|
||||
message = textwrap.dedent("""\
|
||||
Update VNDK snapshot v{version} to build {build}.
|
||||
@@ -203,6 +233,7 @@ def main():
|
||||
|
||||
remove_old_snapshot(install_dir)
|
||||
install_snapshot(args.branch, args.build, install_dir)
|
||||
gather_notice_files()
|
||||
|
||||
buildfile_generator = GenBuildFile(install_dir, vndk_version)
|
||||
update_buildfiles(buildfile_generator)
|
||||
|
||||
Reference in New Issue
Block a user