android_app.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2020 Project CHIP Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. set -e
  18. set -x
  19. env
  20. if [ -z "$ANDROID_HOME" ]; then
  21. echo "ANDROID_HOME not set!"
  22. exit 1
  23. fi
  24. if [ -z "$ANDROID_NDK_HOME" ]; then
  25. echo "ANDROID_NDK_HOME not set!"
  26. exit 1
  27. fi
  28. if [ -z "$TARGET_CPU" ]; then
  29. echo "TARGET_CPU not set! Candidates: arm, arm64, x86 and x64."
  30. exit 1
  31. fi
  32. # Build shared CHIP libs
  33. source scripts/activate.sh
  34. gn gen --check --fail-on-unused-args out/"android_$TARGET_CPU" --args="target_os=\"android\" target_cpu=\"$TARGET_CPU\" android_ndk_root=\"$ANDROID_NDK_HOME\" android_sdk_root=\"$ANDROID_HOME\""
  35. ninja -C out/"android_$TARGET_CPU" src/setup_payload/java src/controller/java default
  36. rsync -a out/"android_$TARGET_CPU"/lib/*.jar src/android/CHIPTool/app/libs
  37. rsync -a out/"android_$TARGET_CPU"/lib/jni/* src/android/CHIPTool/app/src/main/jniLibs
  38. # Build ot-commissioner libs
  39. git submodule update --init --recursive third_party/ot-commissioner/repo
  40. TARGET_CPU=arm64 ./third_party/ot-commissioner/build-android-libs.sh