From b1bdd1294070a3ffbc51e37e8278dbce37cb54be Mon Sep 17 00:00:00 2001 From: Stylogey Date: Fri, 29 May 2020 15:08:44 +0200 Subject: [PATCH] sdm660: Add wayne-common inherit support for extractor Change-Id: I83ab37d6cd12aef4f6a8dc3822efc1856163e304 --- extract-files.sh | 47 ++++++++++++++++++++++++--------------------- setup-makefiles.sh | 48 +++++++++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/extract-files.sh b/extract-files.sh index 726d2f34..7b915a3e 100755 --- a/extract-files.sh +++ b/extract-files.sh @@ -21,12 +21,16 @@ DEVICE_COMMON=sdm660-common VENDOR=xiaomi # Load extract_utils and do some sanity checks -MY_DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi +COMMON_DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$COMMON_DIR" ]]; then COMMON_DIR="$PWD"; fi -LINEAGE_ROOT="$MY_DIR"/../../.. +if [[ -z "$DEVICE_DIR" ]]; then + DEVICE_DIR="${COMMON_DIR}/../${DEVICE}" +fi -HELPER="$LINEAGE_ROOT"/vendor/carbon/build/tools/extract_utils.sh +ROOT="$COMMON_DIR"/../../.. + +HELPER="$ROOT"/vendor/carbon/build/tools/extract_utils.sh if [ ! -f "$HELPER" ]; then echo "Unable to find helper script at $HELPER" exit 1 @@ -34,27 +38,26 @@ fi . "$HELPER" # Default to sanitizing the vendor folder before extraction -clean_vendor=true -ONLY_COMMON= -ONLY_DEVICE= +CLEAN_VENDOR=true +ONLY_COMMON=false +ONLY_DEVICE=false while [ "${#}" -gt 0 ]; do case "${1}" in -o | --only-common ) - ONLY_COMMON=false + ONLY_COMMON=true ;; -d | --only-device ) - ONLY_DEVICE=false + ONLY_DEVICE=true ;; -n | --no-cleanup ) - CLEAN_VENDOR=false - ;; + CLEAN_VENDOR=false + ;; -k | --kang ) KANG="--kang" ;; -s | --section ) SECTION="${2}"; shift - clean_vendor=false CLEAN_VENDOR=false ;; * ) @@ -91,18 +94,18 @@ function blob_fixup() { } # Initialize the common helper -setup_vendor "$DEVICE_COMMON" "$VENDOR" "$LINEAGE_ROOT" true $clean_vendor +setup_vendor "$DEVICE_COMMON" "$VENDOR" "$ROOT" true $CLEAN_VENDOR -if [ -z "${ONLY_DEVICE}" ] && [ -s "${MY_DIR}/proprietary-files.txt" ]; then -extract "$MY_DIR"/proprietary-files.txt "$SRC" \ - "${KANG}" --section "${SECTION}" +if [[ "$ONLY_DEVICE" = "false" ]] && [[ -s "${COMMON_DIR}"/proprietary-files.txt ]]; then + extract "$COMMON_DIR"/proprietary-files.txt "$SRC" "${KANG}" --section "${SECTION}" fi - -if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../${DEVICE}/proprietary-files.txt" ]; then +if [[ "$ONLY_COMMON" = "false" ]] && [[ -s "${DEVICE_DIR}"/proprietary-files.txt ]]; then + if [[ ! "$IS_COMMON" = "true" ]]; then + IS_COMMON=false + fi # Reinitialize the helper for device - setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT" false "$CLEAN_VENDOR" - extract "$MY_DIR"/../$DEVICE/proprietary-files.txt "$SRC" \ - "${KANG}" --section "${SECTION}" + setup_vendor "$DEVICE" "$VENDOR" "$ROOT" "$IS_COMMON" "$CLEAN_VENDOR" + extract "${DEVICE_DIR}"/proprietary-files.txt "$SRC" "${KANG}" --section "${SECTION}" fi -"$MY_DIR"/setup-makefiles.sh +"$COMMON_DIR"/setup-makefiles.sh diff --git a/setup-makefiles.sh b/setup-makefiles.sh index 8c60e0ee..5dd266c6 100755 --- a/setup-makefiles.sh +++ b/setup-makefiles.sh @@ -18,17 +18,22 @@ set -e DEVICE_COMMON=sdm660-common +GUARDED_DEVICES_COMMON="twolip jasmine_sprout wayne clover lavender platina jason whyred" VENDOR=xiaomi INITIAL_COPYRIGHT_YEAR=2018 # Load extract_utils and do some sanity checks -MY_DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi +COMMON_DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$COMMON_DIR" ]]; then COMMON_DIR="$PWD"; fi -LINEAGE_ROOT="$MY_DIR"/../../.. +if [[ -z "$DEVICE_DIR" ]]; then + DEVICE_DIR="${COMMON_DIR}/../${DEVICE}" +fi -HELPER="$LINEAGE_ROOT"/vendor/carbon/build/tools/extract_utils.sh +ROOT="$COMMON_DIR"/../../.. + +HELPER="$ROOT"/vendor/carbon/build/tools/extract_utils.sh if [ ! -f "$HELPER" ]; then echo "Unable to find helper script at $HELPER" exit 1 @@ -36,27 +41,30 @@ fi . "$HELPER" # Initialize the common helper -setup_vendor "$DEVICE_COMMON" "$VENDOR" "$LINEAGE_ROOT" true +setup_vendor "$DEVICE_COMMON" "$VENDOR" "$ROOT" true -# Copyright headers and guards -write_headers "twolip jasmine_sprout wayne clover lavender platina jason whyred" - -write_makefiles "$MY_DIR"/proprietary-files.txt true - -# Finish -write_footers - -if [ -s "$MY_DIR"/../$DEVICE/proprietary-files.txt ]; then +if ([[ "$ONLY_DEVICE" = "false" ]] || [[ -z "$ONLY_DEVICE" ]]) && [[ -s "${COMMON_DIR}"/proprietary-files.txt ]]; then + # Copyright headers and guards + write_headers "$GUARDED_DEVICES_COMMON" + # The common blobs + write_makefiles "$COMMON_DIR"/proprietary-files.txt true + # Finish + write_footers +fi +if ([[ "$ONLY_COMMON" = "false" ]] || [[ -z "$ONLY_COMMON" ]]) && [[ -s "${DEVICE_DIR}"/proprietary-files.txt ]]; then + # Reinitialize the helper for device and write copyright headers and guards + DEVICE_COMMON="$DEVICE" + if [[ ! "$IS_COMMON" = "true" ]]; then + IS_COMMON=false + GUARDED_DEVICES= + fi # Reinitialize the helper for device INITIAL_COPYRIGHT_YEAR="$DEVICE_BRINGUP_YEAR" - setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT" false - + setup_vendor "$DEVICE" "$VENDOR" "$ROOT" "$IS_COMMON" "$CLEAN_VENDOR" # Copyright headers and guards - write_headers - + write_headers "$GUARDED_DEVICES" # The standard device blobs - write_makefiles "$MY_DIR"/../$DEVICE/proprietary-files.txt true - + write_makefiles "${DEVICE_DIR}"/proprietary-files.txt true # We are done! write_footers fi