setup-makefiles.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. export TARGET_ENABLE_CHECKELF=true
  26. HELPER="$ANDROID_ROOT/tools/extract-utils/extract_utils.sh"
  27. if [ ! -f "$HELPER" ]; then
  28. echo "Unable to find helper script at $HELPER"
  29. exit 1
  30. fi
  31. . "$HELPER"
  32. # Initialize the helper for common gapps
  33. setup_vendor "$DEVICE_COMMON" "$VENDOR" "$ANDROID_ROOT" true
  34. # Copyright headers
  35. write_headers "arm arm64 x86 x86_64"
  36. # Common gapps
  37. write_makefiles "$MY_DIR"/proprietary-files-common.txt
  38. # Gapps that are too large for grouper
  39. printf "\n" >> "$PRODUCTMK"
  40. echo "ifeq (\$(TARGET_IS_GROUPER),)" >> "$PRODUCTMK"
  41. write_makefiles "$MY_DIR"/proprietary-files-common-nongrouper.txt
  42. echo "endif" >> "$PRODUCTMK"
  43. # Overlays
  44. cd overlay
  45. OVERLAYS=$(for dir in $(ls -d */); do echo ${dir%%/}; done)
  46. OVERLAYS=$(echo $OVERLAYS | paste -s -d ' ')
  47. cd - >/dev/null
  48. printf "\n" >> "$PRODUCTMK"
  49. echo "PRODUCT_SOONG_NAMESPACES += vendor/$VENDOR/overlay" >> "$PRODUCTMK"
  50. echo "PRODUCT_PACKAGES += $OVERLAYS" >> "$PRODUCTMK"
  51. sed -i 's/TARGET_DEVICE/TARGET_ARCH/g' "$ANDROIDMK"
  52. # We are done with common
  53. write_footers
  54. for DEVICE in arm arm64 x86 x86_64; do
  55. # Reinitialize the helper for target gapps
  56. setup_vendor "$DEVICE" "$VENDOR" "$ANDROID_ROOT"
  57. # Copyright headers and guards
  58. write_headers "$DEVICE"
  59. write_makefiles "$MY_DIR"/proprietary-files-$DEVICE.txt
  60. # Gapps that are too large for grouper
  61. printf "\n" >> "$PRODUCTMK"
  62. echo "ifeq (\$(TARGET_IS_GROUPER),)" >> "$PRODUCTMK"
  63. write_makefiles "$MY_DIR"/proprietary-files-$DEVICE-nongrouper.txt
  64. echo "endif" >> "$PRODUCTMK"
  65. # Workaround for VelvetTitan on tangorpro
  66. if grep -q "VelvetTitan" "$PRODUCTMK"; then
  67. sed -i '/VelvetTitan/d' "$PRODUCTMK"
  68. printf "\n" >> "$PRODUCTMK"
  69. echo "ifneq (\$(filter %tangorpro,\$(TARGET_PRODUCT)),)" >> "$PRODUCTMK"
  70. echo "PRODUCT_PACKAGES += VelvetTitan" >> "$PRODUCTMK"
  71. echo "endif" >> "$PRODUCTMK"
  72. fi
  73. printf '\n%s\n' "\$(call inherit-product, vendor/gapps/common/common-vendor.mk)" >> "$PRODUCTMK"
  74. sed -i 's/TARGET_DEVICE/TARGET_ARCH/g' "$ANDROIDMK"
  75. # We are done with target
  76. write_footers
  77. done