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