android-tools-osx.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # SDK
  3. # https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip
  4. # SHA-256 4a81754a760fce88cba74d69c364b05b31c53d57b26f9f82355c61d5fe4b9df9
  5. # latest version available here: https://developer.android.com/studio/index.html
  6. # NDK
  7. # https://dl.google.com/android/repository/android-ndk-r15c-darwin-x86_64.zip
  8. # SHA-1 ea4b5d76475db84745aa8828000d009625fc1f98
  9. # latest version available here: https://developer.android.com/ndk/downloads/index.html
  10. BASH_RC=~/.bashrc
  11. GODOT_BUILD_TOOLS_PATH=./godot-dev/build-tools
  12. mkdir -p $GODOT_BUILD_TOOLS_PATH
  13. cd $GODOT_BUILD_TOOLS_PATH
  14. ANDROID_BASE_URL=http://dl.google.com/android/repository
  15. ANDROID_SDK_RELEASE=3859397
  16. ANDROID_SDK_DIR=android-sdk
  17. ANDROID_SDK_FILENAME=sdk-tools-darwin-$ANDROID_SDK_RELEASE.zip
  18. ANDROID_SDK_URL=$ANDROID_BASE_URL/$ANDROID_SDK_FILENAME
  19. ANDROID_SDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_SDK_DIR
  20. ANDROID_SDK_SHA256=4a81754a760fce88cba74d69c364b05b31c53d57b26f9f82355c61d5fe4b9df9
  21. ANDROID_NDK_RELEASE=r15c
  22. ANDROID_NDK_DIR=android-ndk
  23. ANDROID_NDK_FILENAME=android-ndk-$ANDROID_NDK_RELEASE-darwin-x86_64.zip
  24. ANDROID_NDK_URL=$ANDROID_BASE_URL/$ANDROID_NDK_FILENAME
  25. ANDROID_NDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_NDK_DIR
  26. ANDROID_NDK_SHA1=ea4b5d76475db84745aa8828000d009625fc1f98
  27. echo
  28. echo "Download and install Android development tools ..."
  29. echo
  30. if [ ! -e $ANDROID_SDK_FILENAME ]; then
  31. echo "Downloading: Android SDK ..."
  32. curl -L -O $ANDROID_SDK_URL
  33. else
  34. echo $ANDROID_SDK_SHA1 $ANDROID_SDK_FILENAME > $ANDROID_SDK_FILENAME.sha1
  35. if [ $(shasum -a 256 < $ANDROID_SDK_FILENAME | awk '{print $1;}') != $ANDROID_SDK_SHA1 ]; then
  36. echo "Downloading: Android SDK ..."
  37. curl -L -O $ANDROID_SDK_URL
  38. fi
  39. fi
  40. if [ ! -d $ANDROID_SDK_DIR ]; then
  41. echo "Extracting: Android SDK ..."
  42. mkdir -p $ANDROID_SDK_DIR && tar -xf $ANDROID_SDK_FILENAME -C $ANDROID_SDK_DIR
  43. echo
  44. fi
  45. if [ ! -e $ANDROID_NDK_FILENAME ]; then
  46. echo "Downloading: Android NDK ..."
  47. curl -L -O $ANDROID_NDK_URL
  48. else
  49. echo $ANDROID_NDK_MD5 $ANDROID_NDK_FILENAME > $ANDROID_NDK_FILENAME.md5
  50. if [ $(shasum -a 1 < $ANDROID_NDK_FILENAME | awk '{print $1;}') != $ANDROID_NDK_SHA1 ]; then
  51. echo "Downloading: Android NDK ..."
  52. curl -L -O $ANDROID_NDK_URL
  53. fi
  54. fi
  55. if [ ! -d $ANDROID_NDK_DIR ]; then
  56. echo "Extracting: Android NDK ..."
  57. tar -xf $ANDROID_NDK_FILENAME
  58. mv android-ndk-$ANDROID_NDK_RELEASE $ANDROID_NDK_DIR
  59. echo
  60. fi
  61. echo "Installing: Android Tools ..."
  62. #$ANDROID_SDK_DIR/tools/bin/sdkmanager --all
  63. yes | $ANDROID_SDK_DIR/tools/bin/sdkmanager --licenses > /dev/null
  64. $ANDROID_SDK_DIR/tools/bin/sdkmanager 'tools' > /dev/null
  65. $ANDROID_SDK_DIR/tools/bin/sdkmanager 'platform-tools' > /dev/null
  66. $ANDROID_SDK_DIR/tools/bin/sdkmanager 'build-tools;26.0.2' > /dev/null
  67. echo
  68. EXPORT_VAL="export ANDROID_HOME=$ANDROID_SDK_PATH"
  69. if ! grep -q "^$EXPORT_VAL" $BASH_RC; then
  70. echo $EXPORT_VAL >> $BASH_RC
  71. fi
  72. #eval $EXPORT_VAL
  73. EXPORT_VAL="export ANDROID_NDK_ROOT=$ANDROID_NDK_PATH"
  74. if ! grep -q "^$EXPORT_VAL" $BASH_RC; then
  75. echo $EXPORT_VAL >> $BASH_RC
  76. fi
  77. #eval $EXPORT_VAL
  78. EXPORT_VAL="export PATH=$PATH:$ANDROID_SDK_PATH/tools"
  79. if ! grep -q "^export PATH=.*$ANDROID_SDK_PATH/tools.*" $BASH_RC; then
  80. echo $EXPORT_VAL >> $BASH_RC
  81. fi
  82. #eval $EXPORT_VAL
  83. EXPORT_VAL="export PATH=$PATH:$ANDROID_SDK_PATH/tools/bin"
  84. if ! grep -q "^export PATH=.*$ANDROID_SDK_PATH/tools/bin.*" $BASH_RC; then
  85. echo $EXPORT_VAL >> $BASH_RC
  86. fi
  87. #eval $EXPORT_VAL
  88. echo
  89. echo "Done!"
  90. echo