build.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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