@ -155,9 +155,47 @@ function prefix_match() {
done
}
#
# prefix_match_file:
#
# $1: the prefix to match on
# $2: the file to match the prefix for
#
# Internal function which returns true if a filename contains the
# specified prefix.
#
function prefix_match_file( ) {
local PREFIX = " $1 "
local FILE = " $2 "
if [ [ " $FILE " = ~ ^" $PREFIX " ] ] ; then
return 0
else
return 1
fi
}
#
# truncate_file
#
# $1: the filename to truncate
# $2: the argument to output the truncated filename to
#
# Internal function which truncates a filename by removing the first dir
# in the path. ex. vendor/lib/libsdmextension.so -> lib/libsdmextension.so
#
function truncate_file( ) {
local FILE = " $1 "
RETURN_FILE = " $2 "
local FIND = " ${ FILE %%/* } "
local LOCATION = " ${# FIND } +1 "
echo ${ FILE : $LOCATION }
}
#
# write_product_copy_files:
#
# $1: make treble compatible makefile - optional, default to false
#
# Creates the PRODUCT_COPY_FILES section in the product makefile for all
# items in the list which do not start with a dash (-).
#
@ -166,6 +204,7 @@ function write_product_copy_files() {
local TARGET =
local FILE =
local LINEEND =
local TREBLE_COMPAT = $1
if [ " $COUNT " -eq "0" ] ; then
return 0
@ -180,8 +219,19 @@ function write_product_copy_files() {
fi
TARGET = $( target_file " $FILE " )
printf ' %s/proprietary/%s:system/%s%s\n' \
" $OUTDIR " " $TARGET " " $TARGET " " $LINEEND " >> " $PRODUCTMK "
if [ " $TREBLE_COMPAT " = = "true" ] || [ " $TREBLE_COMPAT " = = "1" ] ; then
if prefix_match_file "vendor/" $TARGET ; then
local OUTTARGET = $( truncate_file $TARGET )
printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_VENDOR)/%s%s\n' \
" $OUTDIR " " $TARGET " " $OUTTARGET " " $LINEEND " >> " $PRODUCTMK "
else
printf ' %s/proprietary/%s:system/%s%s\n' \
" $OUTDIR " " $TARGET " " $TARGET " " $LINEEND " >> " $PRODUCTMK "
fi
else
printf ' %s/proprietary/%s:system/%s%s\n' \
" $OUTDIR " " $TARGET " " $TARGET " " $LINEEND " >> " $PRODUCTMK "
fi
done
return 0
}
@ -616,6 +666,7 @@ function parse_file_list() {
# write_makefiles:
#
# $1: file containing the list of items to extract
# $2: make treble compatible makefile - optional
#
# Calls write_product_copy_files and write_product_packages on
# the given file and appends to the Android.mk as well as
@ -623,7 +674,7 @@ function parse_file_list() {
#
function write_makefiles( ) {
parse_file_list " $1 "
write_product_copy_files
write_product_copy_files " $2 "
write_product_packages
}