trojan_go.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. #
  3. #
  4. # Copyright (C) 2021 by nekohasekai <[email protected]>
  5. # Copyright (C) 2021 by Max Lv <[email protected]>
  6. # Copyright (C) 2021 by Mygod Studio <[email protected]>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. #
  22. source "bin/init/env.sh"
  23. export CGO_ENABLED=1
  24. export GOOS=android
  25. CURR="plugin/trojan-go"
  26. CURR_PATH="$PROJECT/$CURR"
  27. ROOT="$CURR_PATH/src/main/jniLibs"
  28. OUTPUT="trojan-go"
  29. LIB_OUTPUT="lib$OUTPUT.so"
  30. git submodule update --init "$CURR/*"
  31. cd $CURR_PATH/src/main/go/trojan-go
  32. DIR="$ROOT/armeabi-v7a"
  33. mkdir -p $DIR
  34. env CC=$ANDROID_ARM_CC GOARCH=arm GOARM=7 go build -x -o $DIR/$LIB_OUTPUT -tags "client" -trimpath -ldflags="-s -w -buildid="
  35. $ANDROID_ARM_STRIP $DIR/$LIB_OUTPUT
  36. DIR="$ROOT/arm64-v8a"
  37. mkdir -p $DIR
  38. env CC=$ANDROID_ARM64_CC GOARCH=arm64 go build -x -o $DIR/$LIB_OUTPUT -tags "client" -trimpath -ldflags="-s -w -buildid="
  39. $ANDROID_ARM64_STRIP $DIR/$LIB_OUTPUT
  40. DIR="$ROOT/x86"
  41. mkdir -p $DIR
  42. env CC=$ANDROID_X86_CC GOARCH=386 go build -x -o $DIR/$LIB_OUTPUT -tags "client" -trimpath -ldflags="-s -w -buildid="
  43. $ANDROID_X86_STRIP $DIR/$LIB_OUTPUT
  44. DIR="$ROOT/x86_64"
  45. mkdir -p $DIR
  46. env CC=$ANDROID_X86_64_CC GOARCH=amd64 go build -x -o $DIR/$LIB_OUTPUT -tags "client" -trimpath -ldflags="-s -w -buildid="
  47. $ANDROID_X86_64_STRIP $DIR/$LIB_OUTPUT