@ -317,7 +317,7 @@ function write_product_copy_files() {
}
#
# write_ packages:
# write_ blueprint_ packages:
#
# $1: The LOCAL_MODULE_CLASS for the given module list
# $2: /system, /odm, /product, or /vendor partition
@ -328,7 +328,169 @@ function write_product_copy_files() {
# for all modules in the list. This is called by write_product_packages
# after the modules are categorized.
#
function write_packages( ) {
function write_blueprint_packages( ) {
local CLASS = " $1 "
local PARTITION = " $2 "
local EXTRA = " $3 "
# Yes, this is a horrible hack - we create a new array using indirection
local ARR_NAME = " $4 [@] "
local FILELIST = ( " ${ !ARR_NAME } " )
local FILE =
local ARGS =
local BASENAME =
local EXTENSION =
local PKGNAME =
local SRC =
for P in " ${ FILELIST [@] } " ; do
FILE = $( target_file " $P " )
ARGS = $( target_args " $P " )
BASENAME = $( basename " $FILE " )
DIRNAME = $( dirname " $FILE " )
EXTENSION = ${ BASENAME ##*. }
PKGNAME = ${ BASENAME %.* }
# Add to final package list
PACKAGE_LIST += ( " $PKGNAME " )
SRC = "proprietary"
if [ " $PARTITION " = "system" ] ; then
SRC += "/system"
elif [ " $PARTITION " = "vendor" ] ; then
SRC += "/vendor"
elif [ " $PARTITION " = "product" ] ; then
SRC += "/product"
elif [ " $PARTITION " = "odm" ] ; then
SRC += "/odm"
fi
if [ " $CLASS " = "SHARED_LIBRARIES" ] ; then
printf 'cc_prebuilt_library_shared {\n'
printf '\tname: "%s",\n' " $PKGNAME "
printf '\towner: "%s",\n' " $VENDOR "
printf '\tstrip: {\n'
printf '\t\tnone: true,\n'
printf '\t},\n'
printf '\ttarget: {\n'
if [ " $EXTRA " = "both" ] ; then
printf '\t\tandroid_arm: {\n'
printf '\t\t\tsrcs: ["%s/lib/%s"],\n' " $SRC " " $FILE "
printf '\t\t},\n'
printf '\t\tandroid_arm64: {\n'
printf '\t\t\tsrcs: ["%s/lib64/%s"],\n' " $SRC " " $FILE "
printf '\t\t},\n'
elif [ " $EXTRA " = "64" ] ; then
printf '\t\tandroid_arm64: {\n'
printf '\t\t\tsrcs: ["%s/lib64/%s"],\n' " $SRC " " $FILE "
printf '\t\t},\n'
else
printf '\t\tandroid_arm: {\n'
printf '\t\t\tsrcs: ["%s/lib/%s"],\n' " $SRC " " $FILE "
printf '\t\t},\n'
fi
printf '\t},\n'
if [ " $EXTRA " != "none" ] ; then
printf '\tcompile_multilib: "%s",\n' " $EXTRA "
fi
elif [ " $CLASS " = "APPS" ] ; then
printf 'android_app_import {\n'
printf '\tname: "%s",\n' " $PKGNAME "
printf '\towner: "%s",\n' " $VENDOR "
if [ " $EXTRA " = "priv-app" ] ; then
SRC = " $SRC /priv-app "
else
SRC = " $SRC /app "
fi
printf '\tapk: "%s/%s",\n' " $SRC " " $FILE "
if [ " $ARGS " = "PRESIGNED" ] ; then
printf '\tpresigned: true,\n'
elif [ ! -z " $ARGS " ] ; then
printf '\tcertificate: "%s",\n' " $ARGS "
else
printf '\tcertificate: "platform",\n'
fi
elif [ " $CLASS " = "JAVA_LIBRARIES" ] ; then
printf 'dex_import {\n'
printf '\tname: "%s",\n' " $PKGNAME "
printf '\towner: "%s",\n' " $VENDOR "
printf '\tjars: ["%s/framework/%s"],\n' " $SRC " " $FILE "
elif [ " $CLASS " = "ETC" ] ; then
if [ " $EXTENSION " = "xml" ] ; then
printf 'prebuilt_etc_xml {\n'
else
printf 'prebuilt_etc {\n'
fi
printf '\tname: "%s",\n' " $PKGNAME "
printf '\towner: "%s",\n' " $VENDOR "
printf '\tsrc: "%s/etc/%s",\n' " $SRC " " $FILE "
elif [ " $CLASS " = "EXECUTABLES" ] ; then
if [ " $EXTENSION " = "sh" ] ; then
printf 'sh_binary {\n'
else
printf 'cc_prebuilt_binary {\n'
fi
printf '\tname: "%s",\n' " $PKGNAME "
printf '\towner: "%s",\n' " $VENDOR "
if [ " $ARGS " = "rootfs" ] ; then
SRC = " $SRC /rootfs "
if [ " $EXTRA " = "sbin" ] ; then
SRC = " $SRC /sbin "
printf '\tdist {\n'
printf '\t\tdest: "%s",\n' "root/sbin"
printf '\t},'
fi
else
SRC = " $SRC /bin "
fi
printf '\tsrcs: ["%s/%s"],\n' " $SRC " " $FILE "
unset EXTENSION
else
printf '\tsrcs: ["%s/%s"],\n' " $SRC " " $FILE "
fi
if [ " $CLASS " = "APPS" ] ; then
printf '\tdex_preopt: {\n'
printf '\t\tenabled: false,\n'
printf '\t},\n'
fi
if [ " $CLASS " = "SHARED_LIBRARIES" ] || [ " $CLASS " = "EXECUTABLES" ] || [ " $CLASS " = "ETC" ] ; then
if [ " $DIRNAME " != "." ] ; then
printf '\tsub_dir: "%s",\n' " $DIRNAME "
fi
fi
if [ " $CLASS " = "SHARED_LIBRARIES" ] || [ " $CLASS " = "EXECUTABLES" ] ; then
printf '\tprefer: true,\n'
fi
if [ " $EXTRA " = "priv-app" ] ; then
printf '\tprivileged: true,\n'
fi
if [ " $PARTITION " = "vendor" ] ; then
printf '\tsoc_specific: true,\n'
elif [ " $PARTITION " = "product" ] ; then
printf '\tproduct_specific: true,\n'
elif [ " $PARTITION " = "odm" ] ; then
printf '\tdevice_specific: true,\n'
fi
printf '}\n\n'
done
}
#
# write_makefile_packages:
#
# $1: The LOCAL_MODULE_CLASS for the given module list
# $2: /odm, /product, or /vendor partition
# $3: type-specific extra flags
# $4: Name of the array holding the target list
#
# Internal function which writes out the BUILD_PREBUILT stanzas
# for all modules in the list. This is called by write_product_packages
# after the modules are categorized.
#
function write_makefile_packages( ) {
local CLASS = " $1 "
local PARTITION = " $2 "
@ -480,13 +642,13 @@ function write_product_packages() {
local LIB64 = ( $( comm -23 <( printf '%s\n' " ${ T_LIB64 [@] } " ) <( printf '%s\n' " ${ MULTILIBS [@] } " ) ) )
if [ " ${# MULTILIBS [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "" "both" "MULTILIBS" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "" "both" "MULTILIBS" >> " $ANDROID BP "
fi
if [ " ${# LIB32 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "" "32" "LIB32" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "" "32" "LIB32" >> " $ANDROID BP "
fi
if [ " ${# LIB64 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "" "64" "LIB64" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "" "64" "LIB64" >> " $ANDROID BP "
fi
local T_S_LIB32 = ( $( prefix_match "system/lib/" ) )
@ -496,13 +658,13 @@ function write_product_packages() {
local S_LIB64 = ( $( comm -23 <( printf '%s\n' " ${ T_S_LIB64 [@] } " ) <( printf '%s\n' " ${ S_MULTILIBS [@] } " ) ) )
if [ " ${# S_MULTILIBS [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "system" "both" "S_MULTILIBS" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "system" "both" "S_MULTILIBS" >> " $ANDROID BP "
fi
if [ " ${# S_LIB32 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "system" "32" "S_LIB32" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "system" "32" "S_LIB32" >> " $ANDROID BP "
fi
if [ " ${# S_LIB64 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "system" "64" "S_LIB64" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "system" "64" "S_LIB64" >> " $ANDROID BP "
fi
local T_V_LIB32 = ( $( prefix_match "vendor/lib/" ) )
@ -512,13 +674,13 @@ function write_product_packages() {
local V_LIB64 = ( $( comm -23 <( printf '%s\n' " ${ T_V_LIB64 [@] } " ) <( printf '%s\n' " ${ V_MULTILIBS [@] } " ) ) )
if [ " ${# V_MULTILIBS [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "vendor" "both" "V_MULTILIBS" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "vendor" "both" "V_MULTILIBS" >> " $ANDROID BP "
fi
if [ " ${# V_LIB32 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "vendor" "32" "V_LIB32" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "vendor" "32" "V_LIB32" >> " $ANDROID BP "
fi
if [ " ${# V_LIB64 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "vendor" "64" "V_LIB64" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "vendor" "64" "V_LIB64" >> " $ANDROID BP "
fi
local T_P_LIB32 = ( $( prefix_match "product/lib/" ) )
@ -528,13 +690,13 @@ function write_product_packages() {
local P_LIB64 = ( $( comm -23 <( printf '%s\n' " ${ T_P_LIB64 [@] } " ) <( printf '%s\n' " ${ P_MULTILIBS [@] } " ) ) )
if [ " ${# P_MULTILIBS [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "product" "both" "P_MULTILIBS" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "product" "both" "P_MULTILIBS" >> " $ANDROID BP "
fi
if [ " ${# P_LIB32 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "product" "32" "P_LIB32" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "product" "32" "P_LIB32" >> " $ANDROID BP "
fi
if [ " ${# P_LIB64 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "product" "64" "P_LIB64" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "product" "64" "P_LIB64" >> " $ANDROID BP "
fi
local T_O_LIB32 = ( $( prefix_match "odm/lib/" ) )
@ -544,125 +706,125 @@ function write_product_packages() {
local O_LIB64 = ( $( comm -23 <( printf '%s\n' " ${ T_O_LIB64 [@] } " ) <( printf '%s\n' " ${ O_MULTILIBS [@] } " ) ) )
if [ " ${# O_MULTILIBS [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "odm" "both" "O_MULTILIBS" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "odm" "both" "O_MULTILIBS" >> " $ANDROID BP "
fi
if [ " ${# O_LIB32 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "odm" "32" "O_LIB32" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "odm" "32" "O_LIB32" >> " $ANDROID BP "
fi
if [ " ${# O_LIB64 [@] } " -gt "0" ] ; then
write_packages "SHARED_LIBRARIES" "odm" "64" "O_LIB64" >> " $ANDROID MK "
write_blueprint_ packages "SHARED_LIBRARIES" "odm" "64" "O_LIB64" >> " $ANDROID BP "
fi
# Apps
local APPS = ( $( prefix_match "app/" ) )
if [ " ${# APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "" "" "APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "" "" "APPS" >> " $ANDROID BP "
fi
local PRIV_APPS = ( $( prefix_match "priv-app/" ) )
if [ " ${# PRIV_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "" "priv-app" "PRIV_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "" "priv-app" "PRIV_APPS" >> " $ANDROID BP "
fi
local S_APPS = ( $( prefix_match "system/app/" ) )
if [ " ${# S_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "system" "" "S_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "system" "" "S_APPS" >> " $ANDROID BP "
fi
local S_PRIV_APPS = ( $( prefix_match "system/priv-app/" ) )
if [ " ${# S_PRIV_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "system" "priv-app" "S_PRIV_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "system" "priv-app" "S_PRIV_APPS" >> " $ANDROID BP "
fi
local V_APPS = ( $( prefix_match "vendor/app/" ) )
if [ " ${# V_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "vendor" "" "V_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "vendor" "" "V_APPS" >> " $ANDROID BP "
fi
local V_PRIV_APPS = ( $( prefix_match "vendor/priv-app/" ) )
if [ " ${# V_PRIV_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "vendor" "priv-app" "V_PRIV_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "vendor" "priv-app" "V_PRIV_APPS" >> " $ANDROID BP "
fi
local P_APPS = ( $( prefix_match "product/app/" ) )
if [ " ${# P_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "product" "" "P_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "product" "" "P_APPS" >> " $ANDROID BP "
fi
local P_PRIV_APPS = ( $( prefix_match "product/priv-app/" ) )
if [ " ${# P_PRIV_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "product" "priv-app" "P_PRIV_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "product" "priv-app" "P_PRIV_APPS" >> " $ANDROID BP "
fi
local O_APPS = ( $( prefix_match "odm/app/" ) )
if [ " ${# O_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "odm" "" "O_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "odm" "" "O_APPS" >> " $ANDROID BP "
fi
local O_PRIV_APPS = ( $( prefix_match "odm/priv-app/" ) )
if [ " ${# O_PRIV_APPS [@] } " -gt "0" ] ; then
write_packages "APPS" "odm" "priv-app" "O_PRIV_APPS" >> " $ANDROID MK "
write_blueprint_ packages "APPS" "odm" "priv-app" "O_PRIV_APPS" >> " $ANDROID BP "
fi
# Framework
local FRAMEWORK = ( $( prefix_match "framework/" ) )
if [ " ${# FRAMEWORK [@] } " -gt "0" ] ; then
write_packages "JAVA_LIBRARIES" "" "" "FRAMEWORK" >> " $ANDROID MK "
write_blueprint_ packages "JAVA_LIBRARIES" "" "" "FRAMEWORK" >> " $ANDROID BP "
fi
local S_FRAMEWORK = ( $( prefix_match "system/framework/" ) )
if [ " ${# S_FRAMEWORK [@] } " -gt "0" ] ; then
write_packages "JAVA_LIBRARIES" "system" "" "S_FRAMEWORK" >> " $ANDROID MK "
write_blueprint_ packages "JAVA_LIBRARIES" "system" "" "S_FRAMEWORK" >> " $ANDROID BP "
fi
local V_FRAMEWORK = ( $( prefix_match "vendor/framework/" ) )
if [ " ${# V_FRAMEWORK [@] } " -gt "0" ] ; then
write_packages "JAVA_LIBRARIES" "vendor" "" "V_FRAMEWORK" >> " $ANDROID MK "
write_blueprint_ packages "JAVA_LIBRARIES" "vendor" "" "V_FRAMEWORK" >> " $ANDROID BP "
fi
local P_FRAMEWORK = ( $( prefix_match "product/framework/" ) )
if [ " ${# P_FRAMEWORK [@] } " -gt "0" ] ; then
write_packages "JAVA_LIBRARIES" "product" "" "P_FRAMEWORK" >> " $ANDROID MK "
write_blueprint_ packages "JAVA_LIBRARIES" "product" "" "P_FRAMEWORK" >> " $ANDROID BP "
fi
local O_FRAMEWORK = ( $( prefix_match "odm/framework/" ) )
if [ " ${# O_FRAMEWORK [@] } " -gt "0" ] ; then
write_packages "JAVA_LIBRARIES" "odm" "" "O_FRAMEWORK" >> " $ANDROID MK "
write_blueprint_ packages "JAVA_LIBRARIES" "odm" "" "O_FRAMEWORK" >> " $ANDROID BP "
fi
# Etc
local ETC = ( $( prefix_match "etc/" ) )
if [ " ${# ETC [@] } " -gt "0" ] ; then
write_packages "ETC" "" "" "ETC" >> " $ANDROID MK "
write_blueprint_ packages "ETC" "" "" "ETC" >> " $ANDROID BP "
fi
local S_ETC = ( $( prefix_match "system/etc/" ) )
if [ " ${# ETC [@] } " -gt "0" ] ; then
write_packages "ETC" "system" "" "S_ETC" >> " $ANDROID MK "
write_blueprint_ packages "ETC" "system" "" "S_ETC" >> " $ANDROID BP "
fi
local V_ETC = ( $( prefix_match "vendor/etc/" ) )
if [ " ${# V_ETC [@] } " -gt "0" ] ; then
write_packages "ETC" "vendor" "" "V_ETC" >> " $ANDROID MK "
write_blueprint_ packages "ETC" "vendor" "" "V_ETC" >> " $ANDROID BP "
fi
local P_ETC = ( $( prefix_match "product/etc/" ) )
if [ " ${# P_ETC [@] } " -gt "0" ] ; then
write_packages "ETC" "product" "" "P_ETC" >> " $ANDROID MK "
write_blueprint_ packages "ETC" "product" "" "P_ETC" >> " $ANDROID BP "
fi
local O_ETC = ( $( prefix_match "odm/etc/" ) )
if [ " ${# O_ETC [@] } " -gt "0" ] ; then
write_packages "ETC" "odm" "" "O_ETC" >> " $ANDROID MK "
write_blueprint_ packages "ETC" "odm" "" "O_ETC" >> " $ANDROID BP "
fi
# Executables
local BIN = ( $( prefix_match "bin/" ) )
if [ " ${# BIN [@] } " -gt "0" ] ; then
write_packages "EXECUTABLES" "" "" "BIN" >> " $ANDROID MK "
write_blueprint_ packages "EXECUTABLES" "" "" "BIN" >> " $ANDROID BP "
fi
local S_BIN = ( $( prefix_match "system/bin/" ) )
if [ " ${# BIN [@] } " -gt "0" ] ; then
write_packages "EXECUTABLES" "system" "" "S_BIN" >> " $ANDROID MK "
write_blueprint_ packages "EXECUTABLES" "system" "" "S_BIN" >> " $ANDROID BP "
fi
local V_BIN = ( $( prefix_match "vendor/bin/" ) )
if [ " ${# V_BIN [@] } " -gt "0" ] ; then
write_packages "EXECUTABLES" "vendor" "" "V_BIN" >> " $ANDROID MK "
write_blueprint_ packages "EXECUTABLES" "vendor" "" "V_BIN" >> " $ANDROID BP "
fi
local P_BIN = ( $( prefix_match "product/bin/" ) )
if [ " ${# P_BIN [@] } " -gt "0" ] ; then
write_packages "EXECUTABLES" "product" "" "P_BIN" >> " $ANDROID MK "
write_blueprint_ packages "EXECUTABLES" "product" "" "P_BIN" >> " $ANDROID BP "
fi
local O_BIN = ( $( prefix_match "odm/bin/" ) )
if [ " ${# O_BIN [@] } " -gt "0" ] ; then
write_packages "EXECUTABLES" "odm" "" "O_BIN" >> " $ANDROID MK "
write_blueprint_ packages "EXECUTABLES" "odm" "" "O_BIN" >> " $ANDROID BP "
fi
local SBIN = ( $( prefix_match "sbin/" ) )
if [ " ${# SBIN [@] } " -gt "0" ] ; then
write_packages "EXECUTABLES" "" "sbin" "SBIN" >> " $ANDROIDMK "
write_makefile_ packages "EXECUTABLES" "" "sbin" "SBIN" >> " $ANDROIDMK "
fi