build-ndk-prebuilts.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash -ex
  2. # Copyright 2017 Google Inc. All rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. if [ -z "${OUT_DIR}" ]; then
  16. echo Must set OUT_DIR
  17. exit 1
  18. fi
  19. TOP=$(pwd)
  20. source build/envsetup.sh
  21. PLATFORM_SDK_VERSION=$(get_build_var PLATFORM_SDK_VERSION)
  22. PLATFORM_VERSION_ALL_CODENAMES=$(get_build_var PLATFORM_VERSION_ALL_CODENAMES)
  23. # PLATFORM_VERSION_ALL_CODESNAMES is a comma separated list like O,P. We need to
  24. # turn this into ["O","P"].
  25. PLATFORM_VERSION_ALL_CODENAMES=${PLATFORM_VERSION_ALL_CODENAMES/,/'","'}
  26. PLATFORM_VERSION_ALL_CODENAMES="[\"${PLATFORM_VERSION_ALL_CODENAMES}\"]"
  27. SOONG_OUT=${OUT_DIR}/soong
  28. SOONG_NDK_OUT=${OUT_DIR}/soong/ndk
  29. rm -rf ${SOONG_OUT}
  30. mkdir -p ${SOONG_OUT}
  31. cat > ${SOONG_OUT}/soong.config << EOF
  32. {
  33. "Ndk_abis": true
  34. }
  35. EOF
  36. # We only really need to set some of these variables, but soong won't merge this
  37. # with the defaults, so we need to write out all the defaults with our values
  38. # added.
  39. cat > ${SOONG_OUT}/soong.variables << EOF
  40. {
  41. "Platform_sdk_version": ${PLATFORM_SDK_VERSION},
  42. "Platform_version_active_codenames": ${PLATFORM_VERSION_ALL_CODENAMES},
  43. "DeviceName": "flounder",
  44. "DeviceArch": "arm64",
  45. "DeviceArchVariant": "armv8-a",
  46. "DeviceCpuVariant": "denver64",
  47. "DeviceAbi": [
  48. "arm64-v8a"
  49. ],
  50. "DeviceUsesClang": true,
  51. "DeviceSecondaryArch": "arm",
  52. "DeviceSecondaryArchVariant": "armv7-a-neon",
  53. "DeviceSecondaryCpuVariant": "denver",
  54. "DeviceSecondaryAbi": [
  55. "armeabi-v7a"
  56. ],
  57. "HostArch": "x86_64",
  58. "HostSecondaryArch": "x86",
  59. "Malloc_not_svelte": false,
  60. "Safestack": false
  61. }
  62. EOF
  63. m --skip-make ${SOONG_OUT}/ndk.timestamp
  64. if [ -n "${DIST_DIR}" ]; then
  65. mkdir -p ${DIST_DIR} || true
  66. tar cjf ${DIST_DIR}/ndk_platform.tar.bz2 -C ${SOONG_OUT} ndk
  67. fi