build.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. set -e
  3. MODE=${1:---debug}
  4. TYPE=${2:-linux}
  5. MODE=${MODE/*-/}
  6. build(){
  7. pwd
  8. $WORKDIR/entrypoint $1
  9. }
  10. build_arm64(){
  11. CWD=$(pwd)
  12. cd $WORKDIR/flutter
  13. flutter pub get
  14. cd $WORKDIR
  15. $WORKDIR/flutter/ndk_arm64.sh
  16. cp $WORKDIR/target/aarch64-linux-android/release/liblibrustdesk.so $WORKDIR/flutter/android/app/src/main/jniLibs/arm64-v8a/librustdesk.so
  17. cd $CWD
  18. }
  19. build_apk(){
  20. cd $WORKDIR/flutter
  21. MODE=$1 $WORKDIR/flutter/build_android.sh
  22. cd $WORKDIR
  23. }
  24. key_gen(){
  25. if [ ! -f $WORKDIR/flutter/android/key.properties ]
  26. then
  27. if [ ! -f $HOME/upload-keystore.jks ]
  28. then
  29. $WORKDIR/.devcontainer/setup.sh key
  30. fi
  31. read -r -p "enter the password used to generate $HOME/upload-keystore.jks\n" password
  32. echo -e "storePassword=${password}\nkeyPassword=${password}\nkeyAlias=upload\nstoreFile=$HOME/upload-keystore.jks" > $WORKDIR/flutter/android/key.properties
  33. else
  34. echo "Believing storeFile is created ref: $WORKDIR/flutter/android/key.properties"
  35. fi
  36. }
  37. android_build(){
  38. if [ ! -d $WORKDIR/flutter/android/app/src/main/jniLibs/arm64-v8a ]
  39. then
  40. $WORKDIR/.devcontainer/setup.sh android
  41. fi
  42. build_arm64
  43. case $1 in
  44. debug)
  45. build_apk debug
  46. ;;
  47. release)
  48. key_gen
  49. build_apk release
  50. ;;
  51. esac
  52. }
  53. case "$MODE:$TYPE" in
  54. "debug:linux")
  55. build
  56. ;;
  57. "release:linux")
  58. build --release
  59. ;;
  60. "debug:android")
  61. android_build debug
  62. ;;
  63. "release:android")
  64. android_build release
  65. ;;
  66. esac