• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2
3if (( BASH_VERSINFO[0] < 3 )); then
4  echo "Must be running BASH version 3 or newer!"
5  exit 1
6fi
7
8if [[ -z $TOP ]]; then \
9  echo "You must do envsetup beforehand."
10  exit 1
11fi
12
13# We are currently in frameworks/rs, so compute our top-level directory.
14MY_ANDROID_DIR="$TOP"
15cd "$MY_ANDROID_DIR"
16
17if [[ $OSTYPE != *linux* ]]; then \
18  echo "Only works on Linux."
19  exit 1
20fi
21
22SHORT_OSNAME=linux
23SONAME=so
24# Target architectures and their system library names.
25declare -a TARGETS=(generic_armv5 aosp_arm aosp_mips aosp_x86)
26declare -a ABI_NAMES=(armeabi armeabi-v7a mips x86)
27declare -a SYS_NAMES=(generic_armv5 generic generic_mips generic_x86)
28declare -i NUM_CORES="$(awk '/^processor/ { i++ } END { print i }' /proc/cpuinfo)"
29
30echo "Using $NUM_CORES cores"
31
32# Turn off the build cache and make sure we build all of LLVM from scratch.
33#export ANDROID_USE_BUILDCACHE=false
34
35# PREBUILTS_DIR is where we want to copy our new files to.
36PREBUILTS_DIR="$MY_ANDROID_DIR/prebuilts/conscrypt/"
37
38print_usage() {
39  echo "USAGE: $0 [-h|--help] [-n|--no-build] [-x]"
40  echo "OPTIONS:"
41  echo "    -h, --help     : Display this help message."
42  echo "    -n, --no-build : Skip the build step and just copy files."
43  echo "    -x             : Display commands before they are executed."
44}
45
46build_libs() {
47  local t="$1"
48  echo Building for target $t
49  cd $MY_ANDROID_DIR
50  WITH_HOST_DALVIK=false make -j32 PRODUCT-$t-userdebug APP-conscrypt_unbundled-libconscrypt_jni || exit 1
51}
52
53# Build everything by default
54build_me=1
55
56while [[ $# -gt 0 ]]; do
57  case "$1" in
58    -h|--help)
59      print_usage
60      exit 0
61      ;;
62    -n|--no-build)
63      build_me=0
64      ;;
65    -x)
66      # set lets us enable bash -x mode.
67      set -x
68      ;;
69    *)
70      echo Unknown argument: "$1"
71      print_usage
72      exit 99
73      break
74      ;;
75  esac
76  shift
77done
78
79declare -i i
80
81if [ $build_me -eq 1 ]; then
82
83  echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
84  echo !!! BUILDING CONSCRYPT PREBUILTS !!!
85  echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86
87  source build/envsetup.sh
88
89  for (( i=0; i < ${#TARGETS[@]}; i++ )); do
90    build_libs "${TARGETS[$i]}"
91  done
92
93  echo DONE BUILDING CONSCRYPT PREBUILTS
94
95else
96
97  echo SKIPPING BUILD OF CONSCRYPT PREBUILTS
98
99fi
100
101DATE="$(date +"%Y%m%d")"
102
103cd "$PREBUILTS_DIR" || exit 3
104repo start "pb_$DATE" .
105
106# Don't copy device prebuilts on Darwin. We don't need/use them.
107for (( i=0; i < ${#TARGETS[@]}; i++ )); do
108  sys="${SYS_NAMES[$i]}"
109  abi="${ABI_NAMES[$i]}"
110  sys_lib_dir="$MY_ANDROID_DIR/out/target/product/$sys/system/lib"
111  if [[ ! -d "jni/$abi" ]]; then
112    mkdir -p "jni/$abi"
113  fi
114  cp "$sys_lib_dir/libconscrypt_jni.so" "jni/$abi/" || exit 4
115done
116
117# javalib.jar
118cp "$MY_ANDROID_DIR/out/target/common/obj/JAVA_LIBRARIES/conscrypt_unbundled_intermediates/classes.jar" .
119