Vic Yang | 51512c5 | 2018-11-12 20:16:26 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | STRIP_PATH="${1}" |
| 5 | CORE="${2}" |
| 6 | VENDOR="${3}" |
| 7 | |
Vic Yang | 4873e65 | 2020-01-08 14:39:10 -0800 | [diff] [blame] | 8 | TMPDIR="$(mktemp -d ${CORE}.vndk_lib_check.XXXXXXXX)" |
| 9 | stripped_core="${TMPDIR}/core" |
| 10 | stripped_vendor="${TMPDIR}/vendor" |
Vic Yang | 51512c5 | 2018-11-12 20:16:26 -0800 | [diff] [blame] | 11 | |
| 12 | function cleanup() { |
Vic Yang | 4873e65 | 2020-01-08 14:39:10 -0800 | [diff] [blame] | 13 | rm -f "${stripped_core}" "${stripped_vendor}" |
| 14 | rmdir "${TMPDIR}" |
Vic Yang | 51512c5 | 2018-11-12 20:16:26 -0800 | [diff] [blame] | 15 | } |
| 16 | trap cleanup EXIT |
| 17 | |
| 18 | function strip_lib() { |
| 19 | ${STRIP_PATH} \ |
| 20 | -i ${1} \ |
| 21 | -o ${2} \ |
| 22 | -d /dev/null \ |
| 23 | --remove-build-id |
| 24 | } |
| 25 | |
| 26 | strip_lib ${CORE} ${stripped_core} |
| 27 | strip_lib ${VENDOR} ${stripped_vendor} |
| 28 | if ! cmp -s ${stripped_core} ${stripped_vendor}; then |
Steven Moreland | 9d27901 | 2020-08-06 18:02:31 +0000 | [diff] [blame] | 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." |
Vic Yang | 51512c5 | 2018-11-12 20:16:26 -0800 | [diff] [blame] | 43 | exit 1 |
| 44 | fi |