setup-makefiles.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2016 The CyanogenMod Project
  4. # Copyright (C) 2017-2021 The LineageOS Project
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. set -e
  19. export DEVICE_COMMON=common
  20. export VENDOR=gapps
  21. # Load extract_utils and do some sanity checks
  22. MY_DIR="${BASH_SOURCE%/*}"
  23. if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi
  24. ANDROID_ROOT="$MY_DIR/../.."
  25. HELPER="$ANDROID_ROOT/tools/extract-utils/extract_utils.sh"
  26. if [ ! -f "$HELPER" ]; then
  27. echo "Unable to find helper script at $HELPER"
  28. exit 1
  29. fi
  30. . "$HELPER"
  31. # Initialize the helper for common gapps
  32. setup_vendor "$DEVICE_COMMON" "$VENDOR" "$ANDROID_ROOT" true
  33. # Copyright headers
  34. write_headers "arm arm64 x86 x86_64"
  35. # Common gapps
  36. write_makefiles "$MY_DIR"/proprietary-files-common.txt
  37. # Gapps that are too large for grouper
  38. printf "\n" >> "$PRODUCTMK"
  39. echo "ifeq (\$(TARGET_IS_GROUPER),)" >> "$PRODUCTMK"
  40. write_makefiles "$MY_DIR"/proprietary-files-common-nongrouper.txt
  41. echo "endif" >> "$PRODUCTMK"
  42. # Overlays
  43. cd overlay
  44. OVERLAYS=$(for dir in $(ls -d */); do echo ${dir%%/}; done)
  45. OVERLAYS=$(echo $OVERLAYS | paste -s -d ' ')
  46. cd - >/dev/null
  47. printf "\n" >> "$PRODUCTMK"
  48. echo "PRODUCT_SOONG_NAMESPACES += vendor/$VENDOR/overlay" >> "$PRODUCTMK"
  49. echo "PRODUCT_PACKAGES += $OVERLAYS" >> "$PRODUCTMK"
  50. sed -i 's/TARGET_DEVICE/TARGET_ARCH/g' "$ANDROIDMK"
  51. # We are done with common
  52. write_footers
  53. for DEVICE in arm arm64 x86 x86_64; do
  54. # Reinitialize the helper for target gapps
  55. setup_vendor "$DEVICE" "$VENDOR" "$ANDROID_ROOT"
  56. # Copyright headers and guards
  57. write_headers "$DEVICE"
  58. write_makefiles "$MY_DIR"/proprietary-files-$DEVICE.txt
  59. # Gapps that are too large for grouper
  60. printf "\n" >> "$PRODUCTMK"
  61. echo "ifeq (\$(TARGET_IS_GROUPER),)" >> "$PRODUCTMK"
  62. write_makefiles "$MY_DIR"/proprietary-files-$DEVICE-nongrouper.txt
  63. echo "endif" >> "$PRODUCTMK"
  64. # Workaround for VelvetTitan on tangorpro
  65. if grep -q "VelvetTitan" "$PRODUCTMK"; then
  66. sed -i '/VelvetTitan/d' "$PRODUCTMK"
  67. printf "\n" >> "$PRODUCTMK"
  68. echo "ifneq (\$(filter %tangorpro,\$(TARGET_PRODUCT)),)" >> "$PRODUCTMK"
  69. echo "PRODUCT_PACKAGES += VelvetTitan" >> "$PRODUCTMK"
  70. echo "endif" >> "$PRODUCTMK"
  71. fi
  72. printf '\n%s\n' "\$(call inherit-product, vendor/gapps/common/common-vendor.mk)" >> "$PRODUCTMK"
  73. sed -i 's/TARGET_DEVICE/TARGET_ARCH/g' "$ANDROIDMK"
  74. # We are done with target
  75. write_footers
  76. done