setup_anddev.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/bash
  2. function explain_usage()
  3. {
  4. echo "This script configures the \"commandergenius\" SDL Android port"
  5. echo "for the build of openMSX."
  6. echo ""
  7. echo "The script depends on the Android SDK and NDK and on the"
  8. echo "\"commandergenius\" SDL Android port."
  9. echo ""
  10. echo "First download and install the Android SDK and NDK"
  11. echo "as per the instructions on the Android website."
  12. echo ""
  13. echo "Please make sure to add the Android SDK and NDK tools locations"
  14. echo "to your PATH variable, as per the instructions on the Android"
  15. echo "website. Otherwise the setup will fail."
  16. echo ""
  17. echo "Subsequently download the \"commandergenius\" SDL Android port"
  18. echo "into your favorite location."
  19. echo ""
  20. echo "Example:"
  21. echo "> cd /opt"
  22. echo "> git clone https://github.com/pelya/commandergenius.git"
  23. echo ""
  24. echo "Once that is done, you can launch this script."
  25. echo "You must specify the path to the \"commandergenius\" SDL Android port"
  26. echo "on the command line or in environment parameter SDL_ANDROID_PORT_PATH."
  27. echo ""
  28. echo "Example 1:"
  29. echo "> export SDL_ANDROID_PORT_PATH=/opt/commandergenius"
  30. echo "> ./setup_anddev.sh"
  31. echo ""
  32. echo "Example 2:"
  33. echo "> ./setup_anddev.sh /opt/commandergenius"
  34. echo ""
  35. }
  36. if [ $# -eq 0 -a -z "$SDL_ANDROID_PORT_PATH" ]; then
  37. explain_usage
  38. exit 1
  39. fi
  40. if [ $# -eq 1 ]; then
  41. sdl_android_port_path="$1"
  42. else
  43. sdl_android_port_path="$SDL_ANDROID_PORT_PATH"
  44. fi
  45. if [ ! -d "${sdl_android_port_path}" ]; then
  46. echo "Can not find directory ${sdl_android_port_path}"
  47. exit 1
  48. fi
  49. sdl_port_app_dir="${sdl_android_port_path}/project/jni/application"
  50. if [ ! -d "${sdl_port_app_dir}" ]; then
  51. echo "Can not find expected sub-directory project/jni/application"
  52. echo "in specified directory ${sdl_android_port_path}"
  53. exit 1
  54. fi
  55. this_script_dir=$(dirname $0)
  56. this_script_dir=$(cd ${this_script_dir}; pwd)
  57. my_home_dir=${this_script_dir%/*}
  58. my_home_dir=${my_home_dir%/*}
  59. my_android_dir="${my_home_dir}/build/android/openmsx"
  60. my_relative_dir="${my_android_dir##*/}"
  61. echo "Setting-up softlink to this application in the SDL android port."
  62. if [ -h "${sdl_port_app_dir}/${my_relative_dir}" ]; then
  63. rm "${sdl_port_app_dir}/${my_relative_dir}"
  64. fi
  65. if [ -d "${sdl_port_app_dir}/${my_relative_dir}" ]; then
  66. echo "ERROR: found directory ${my_relative_dir} in ${sdl_port_app_dir}"
  67. echo "This seems to be another app with the same name."
  68. echo "Please resolve the conflict and then re-run this script."
  69. exit 1
  70. fi
  71. ln -s "${my_android_dir}" "${sdl_port_app_dir}/${my_relative_dir}"
  72. rm -f "${sdl_port_app_dir}/src"
  73. ln -s "${my_relative_dir}" "${sdl_port_app_dir}/src"
  74. echo "Making environment.props file for the build script"
  75. cat > "${my_android_dir}/environment.props" << @EOT
  76. # Do not edit this file. It is generated by setup_anddev.sh
  77. sdl_android_port_path="${sdl_android_port_path}"
  78. my_home_dir="${my_home_dir}"
  79. @EOT
  80. cd "${my_android_dir}"
  81. ./generate_AndroidAppSettings.sh
  82. if [ $? -ne 0 ]; then
  83. exit 1
  84. fi
  85. echo "Configuring SDL android port to build this application"
  86. cd "${sdl_android_port_path}"
  87. ./changeAppSettings.sh -a
  88. if [ $? -ne 0 ]; then
  89. echo "ERROR: an unexpected problem occurred while running changeAppSettings.sh -a"
  90. echo " in ${sdl_android_port_path}"
  91. exit 1
  92. fi
  93. echo ""
  94. echo "You can now build the application from the openMSX android build directory"
  95. echo ""
  96. echo "Example"
  97. echo "> cd ${my_android_dir}"
  98. echo "> ./launch_anddev_build.sh"