Skip to content

Commit

Permalink
mido: Sync extractors with templates
Browse files Browse the repository at this point in the history
 * This introduces fixup scripts and kang mode and fixes
   passing of arguments longer than one word,
   such as --section "Hello world".

Change-Id: I038d64c8d3b55c26bb1b9798cc67b9e8ad37e292
  • Loading branch information
vladimiroltean authored and zeelog committed Apr 18, 2020
1 parent 30456ee commit d316b9c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 33 deletions.
67 changes: 41 additions & 26 deletions extract-files.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017 The LineageOS Project
# Copyright (C) 2017, 2019 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,64 +16,79 @@
# limitations under the License.
#

# If we're being sourced by the common script that we called,
# stop right here. No need to go down the rabbit hole.
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
return
fi

set -e

# Required!
DEVICE=mido
VENDOR=xiaomi

# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi
if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi

LINEAGE_ROOT="$MY_DIR"/../../..
LINEAGE_ROOT="${MY_DIR}/../../.."

HELPER="$LINEAGE_ROOT"/vendor/lineage/build/tools/extract_utils.sh
HELPER="$LINEAGE_ROOT/vendor/lineage/build/tools/extract_utils.sh"
if [ ! -f "$HELPER" ]; then
echo "Unable to find helper script at $HELPER"
exit 1
fi
. "$HELPER"
source "${HELPER}"

# Default to sanitizing the vendor folder before extraction
CLEAN_VENDOR=true

while [ "$1" != "" ]; do
case $1 in
-n | --no-cleanup ) CLEAN_VENDOR=false
;;
-s | --section ) shift
SECTION=$1
CLEAN_VENDOR=false
;;
* ) SRC=$1
;;
SECTION=
KANG=

while [ "${#}" -gt 0 ]; do
case "${1}" in
-n | --no-cleanup )
CLEAN_VENDOR=false
;;
-k | --kang )
KANG="--kang"
;;
-s | --section )
SECTION="${2}"; shift
CLEAN_VENDOR=false
;;
* )
SRC="${1}"
;;
esac
shift
done

if [ -z "$SRC" ]; then
SRC=adb
if [ -z "${SRC}" ]; then
SRC="adb"
fi

# Initialize the helper
setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT" false "$CLEAN_VENDOR"
setup_vendor "${DEVICE}" "${VENDOR}" "${LINEAGE_ROOT}" false "${CLEAN_VENDOR}"

extract "$MY_DIR"/proprietary-files.txt "$SRC" "$SECTION"
extract "${MY_DIR}"/proprietary-files.txt "${SRC}" \
"${KANG}" --section "${SECTION}"

DEVICE_BLOB_ROOT="$LINEAGE_ROOT"/vendor/"$VENDOR"/"$DEVICE"/proprietary
DEVICE_BLOB_ROOT="${LINEAGE_ROOT}"/vendor/"${VENDOR}"/"${DEVICE}"/proprietary

# Camera configs
sed -i "s|/system/etc/camera|/vendor/etc/camera|g" "$DEVICE_BLOB_ROOT"/vendor/lib/libmmcamera2_sensor_modules.so
sed -i "s|/system/etc/camera|/vendor/etc/camera|g" "${DEVICE_BLOB_ROOT}"/vendor/lib/libmmcamera2_sensor_modules.so

# Camera socket
sed -i "s|/data/misc/camera/cam_socket|/data/vendor/qcam/cam_socket|g" "$DEVICE_BLOB_ROOT"/vendor/bin/mm-qcamera-daemon
sed -i "s|/data/misc/camera/cam_socket|/data/vendor/qcam/cam_socket|g" "${DEVICE_BLOB_ROOT}"/vendor/bin/mm-qcamera-daemon

# Camera data
for CAMERA_LIB in libmmcamera2_cpp_module.so libmmcamera2_dcrf.so libmmcamera2_iface_modules.so libmmcamera2_imglib_modules.so libmmcamera2_mct.so libmmcamera2_pproc_modules.so libmmcamera2_q3a_core.so libmmcamera2_sensor_modules.so libmmcamera2_stats_algorithm.so libmmcamera2_stats_modules.so libmmcamera_dbg.so libmmcamera_imglib.so libmmcamera_pdafcamif.so libmmcamera_pdaf.so libmmcamera_tintless_algo.so libmmcamera_tintless_bg_pca_algo.so libmmcamera_tuning.so; do
sed -i "s|/data/misc/camera/|/data/vendor/qcam/|g" "$DEVICE_BLOB_ROOT"/vendor/lib/$CAMERA_LIB
sed -i "s|/data/misc/camera/|/data/vendor/qcam/|g" "${DEVICE_BLOB_ROOT}"/vendor/lib/${CAMERA_LIB}
done

# Camera debug log file
sed -i "s|persist.camera.debug.logfile|persist.vendor.camera.dbglog|g" "$DEVICE_BLOB_ROOT"/vendor/lib/libmmcamera_dbg.so

"$MY_DIR"/setup-makefiles.sh
sed -i "s|persist.camera.debug.logfile|persist.vendor.camera.dbglog|g" "${DEVICE_BLOB_ROOT}"/vendor/lib/libmmcamera_dbg.so
"${MY_DIR}/setup-makefiles.sh"
15 changes: 8 additions & 7 deletions setup-makefiles.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017 The LineageOS Project
# Copyright (C) 2017, 2019 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,31 +18,32 @@

set -e

# Required!
DEVICE=mido
VENDOR=xiaomi

INITIAL_COPYRIGHT_YEAR=2017

# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi
if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi

LINEAGE_ROOT="$MY_DIR"/../../..
LINEAGE_ROOT="${MY_DIR}/../../.."

HELPER="$LINEAGE_ROOT"/vendor/lineage/build/tools/extract_utils.sh
HELPER="$LINEAGE_ROOT/vendor/lineage/build/tools/extract_utils.sh"
if [ ! -f "$HELPER" ]; then
echo "Unable to find helper script at $HELPER"
exit 1
fi
. "$HELPER"
source "${HELPER}"

# Initialize the helper
setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT"
setup_vendor "${DEVICE}" "${VENDOR}" "${LINEAGE_ROOT}"

# Copyright headers and guards
write_headers

write_makefiles "$MY_DIR"/proprietary-files.txt true
write_makefiles "${MY_DIR}/proprietary-files.txt" true

# Finish
write_footers

0 comments on commit d316b9c

Please sign in to comment.