diff options
-rw-r--r-- | extract_utils.sh | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/extract_utils.sh b/extract_utils.sh index 9e04377..55eb22c 100644 --- a/extract_utils.sh +++ b/extract_utils.sh @@ -2,6 +2,7 @@ # # Copyright (C) 2016 The CyanogenMod Project # Copyright (C) 2017-2020 The LineageOS Project +# Copyright (C) 2017-2020 Paranoid Android # # SPDX-License-Identifier: Apache-2.0 # @@ -36,21 +37,31 @@ trap cleanup 0 # # setup_vendor # -# $1: device name +# $1: device/component name # $2: vendor name # $3: Android root directory # $4: is common device - optional, default to false # $5: cleanup - optional, default to true # $6: custom vendor makefile name - optional, default to false +# $7: is qti common component - optional, default to false # # Must be called before any other functions can be used. This # sets up the internal state for a new vendor configuration. # function setup_vendor() { - local DEVICE="$1" - if [ -z "$DEVICE" ]; then - echo "\$DEVICE must be set before including this script!" - exit 1 + export IS_QTI_COMPONENT="$7" + if [ -z "$IS_QTI_COMPONENT" ]; then + local DEVICE="$1" + if [ -z "$DEVICE" ]; then + echo "\$DEVICE must be set before including this script!" + exit 1 + fi + else + local COMPONENT="$1" + if [ -z "$COMPONENT" ]; then + echo "\$COMPONENT must be set before including this script!" + exit 1 + fi fi export VENDOR="$2" @@ -65,14 +76,23 @@ function setup_vendor() { exit 1 fi - export OUTDIR=vendor/"$VENDOR"/"$DEVICE" + if [ -z "$IS_QTI_COMPONENT" ]; then + export OUTDIR=vendor/"$VENDOR"/"$DEVICE" + else + export OUTDIR=vendor/"$VENDOR"/"$COMPONENT" + fi if [ ! -d "$ANDROID_ROOT/$OUTDIR" ]; then mkdir -p "$ANDROID_ROOT/$OUTDIR" fi + VNDNAME="$6" if [ -z "$VNDNAME" ]; then - VNDNAME="$DEVICE" + if [ -z "$IS_QTI_COMPONENT" ]; then + VNDNAME="$DEVICE" + else + VNDNAME="$COMPONENT" + fi fi export PRODUCTMK="$ANDROID_ROOT"/"$OUTDIR"/"$VNDNAME"-vendor.mk @@ -411,7 +431,7 @@ function write_blueprint_packages() { if [ ! -z "$STEM" ]; then printf '\tstem: "%s",\n' "$STEM" fi - printf '\towner: "%s",\n' "$VENDOR" + printf '\towner: "%s",\n' "${VENDOR%\/*}" printf '\tstrip: {\n' printf '\t\tnone: true,\n' printf '\t},\n' @@ -447,7 +467,7 @@ function write_blueprint_packages() { elif [ "$CLASS" = "APPS" ]; then printf 'android_app_import {\n' printf '\tname: "%s",\n' "$PKGNAME" - printf '\towner: "%s",\n' "$VENDOR" + printf '\towner: "%s",\n' "${VENDOR%\/*}" if [ "$EXTRA" = "priv-app" ]; then SRC="$SRC/priv-app" else @@ -474,7 +494,7 @@ function write_blueprint_packages() { elif [ "$CLASS" = "JAVA_LIBRARIES" ]; then printf 'dex_import {\n' printf '\tname: "%s",\n' "$PKGNAME" - printf '\towner: "%s",\n' "$VENDOR" + printf '\towner: "%s",\n' "${VENDOR%\/*}" printf '\tjars: ["%s/framework/%s"],\n' "$SRC" "$FILE" elif [ "$CLASS" = "ETC" ]; then if [ "$EXTENSION" = "xml" ]; then @@ -483,7 +503,7 @@ function write_blueprint_packages() { printf 'prebuilt_etc {\n' fi printf '\tname: "%s",\n' "$PKGNAME" - printf '\towner: "%s",\n' "$VENDOR" + printf '\towner: "%s",\n' "${VENDOR%\/*}" printf '\tsrc: "%s/etc/%s",\n' "$SRC" "$FILE" printf '\tfilename_from_src: true,\n' elif [ "$CLASS" = "EXECUTABLES" ]; then @@ -493,7 +513,7 @@ function write_blueprint_packages() { printf 'cc_prebuilt_binary {\n' fi printf '\tname: "%s",\n' "$PKGNAME" - printf '\towner: "%s",\n' "$VENDOR" + printf '\towner: "%s",\n' "${VENDOR%\/*}" printf '\tsrcs: ["%s/bin/%s"],\n' "$SRC" "$FILE" if [ "$EXTENSION" != "sh" ]; then printf '\tcheck_elf_files: false,\n' @@ -839,7 +859,7 @@ function write_blueprint_header() { cat << EOF >> $1 // Automatically generated file. DO NOT MODIFY // -// This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh +// This file is generated by device/$VENDOR/$([ -z "$IS_QTI_COMPONENT" ] && echo ${DEVICE} || echo ${COMPONENT})/setup-makefiles.sh EOF } @@ -863,7 +883,7 @@ function write_makefile_header() { cat << EOF >> $1 # Automatically generated file. DO NOT MODIFY # -# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh +# This file is generated by device/$VENDOR/$([ -z "$IS_QTI_COMPONENT" ] && echo ${DEVICE} || echo ${COMPONENT})/setup-makefiles.sh EOF } @@ -881,20 +901,28 @@ EOF function write_headers() { write_makefile_header "$ANDROIDMK" + cat << EOF >> "$ANDROIDMK" +LOCAL_PATH := \$(call my-dir) + +EOF + GUARD="$2" if [ -z "$GUARD" ]; then GUARD="TARGET_DEVICE" fi - cat << EOF >> "$ANDROIDMK" -LOCAL_PATH := \$(call my-dir) - -EOF if [ "$COMMON" -ne 1 ]; then - cat << EOF >> "$ANDROIDMK" + if [ -z "$IS_QTI_COMPONENT" ]; then + cat << EOF >> "$ANDROIDMK" ifeq (\$($GUARD),$DEVICE) EOF + else + cat << EOF >> "$ANDROIDMK" +ifneq (,\$(filter $COMPONENT,\$(TARGET_COMMON_QTI_COMPONENTS))) + +EOF + fi else if [ -z "$1" ]; then echo "Argument with devices to be added to guard must be set!" @@ -919,7 +947,7 @@ EOF [ "$COMMON" -eq 1 ] && local DEVICE="$DEVICE_COMMON" cat << EOF >> "$PRODUCTMK" PRODUCT_SOONG_NAMESPACES += \\ - vendor/$VENDOR/$DEVICE + vendor/$VENDOR/$([ -z "$IS_QTI_COMPONENT" ] && echo ${DEVICE} || echo ${COMPONENT}) EOF } |