blob: c9f436f0bb98ab8869e7ceff5cf2816cebe02ae1 [file] [log] [blame]
Vic Yang51512c52018-11-12 20:16:26 -08001#!/bin/bash
2set -e
3
4STRIP_PATH="${1}"
5CORE="${2}"
6VENDOR="${3}"
7
Vic Yang4873e652020-01-08 14:39:10 -08008TMPDIR="$(mktemp -d ${CORE}.vndk_lib_check.XXXXXXXX)"
9stripped_core="${TMPDIR}/core"
10stripped_vendor="${TMPDIR}/vendor"
Vic Yang51512c52018-11-12 20:16:26 -080011
12function cleanup() {
Vic Yang4873e652020-01-08 14:39:10 -080013 rm -f "${stripped_core}" "${stripped_vendor}"
14 rmdir "${TMPDIR}"
Vic Yang51512c52018-11-12 20:16:26 -080015}
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
Steven Moreland9d279012020-08-06 18:02:31 +000029 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."
Vic Yang51512c52018-11-12 20:16:26 -080043 exit 1
44fi