• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2set -e
3
4STRIP_PATH="${1}"
5CORE="${2}"
6VENDOR="${3}"
7
8TMPDIR="$(mktemp -d ${CORE}.vndk_lib_check.XXXXXXXX)"
9stripped_core="${TMPDIR}/core"
10stripped_vendor="${TMPDIR}/vendor"
11
12function cleanup() {
13  rm -f "${stripped_core}" "${stripped_vendor}"
14  rmdir "${TMPDIR}"
15}
16trap cleanup EXIT
17
18function strip_lib() {
19  ${STRIP_PATH} \
20    -i ${1} \
21    -o ${2} \
22    -d /dev/null \
23    --remove-build-id
24}
25
26strip_lib ${CORE} ${stripped_core}
27strip_lib ${VENDOR} ${stripped_vendor}
28if ! cmp -s ${stripped_core} ${stripped_vendor}; then
29  echo "ERROR: VNDK library $(basename ${CORE%.so}) has different core and" \
30    "vendor variants! This means that the copy used in the system.img/etc" \
31    "and vendor.img/etc images are different. In order to preserve space on" \
32    "some devices, it is helpful if they are the same. Frequently, " \
33    "libraries are different because they or their dependencies compile" \
34    "things based on the macro '__ANDROID_VNDK__' or they specify custom" \
35    "options under 'target: { vendor: { ... } }'. Here are some possible" \
36    "resolutions:"
37  echo "ERROR: 1). Remove differences, possibly using the libvndksupport" \
38    "function android_is_in_vendor_process in order to turn this into a" \
39    "runtime difference."
40  echo "ERROR: 2). Add the library to the VndkMustUseVendorVariantList" \
41    "variable in build/soong/cc/config/vndk.go, which is used to" \
42    "acknowledge this difference."
43  exit 1
44fi
45