1*fc3927beSAndroid Build Coastguard Worker#!/bin/bash 2*fc3927beSAndroid Build Coastguard Worker 3*fc3927beSAndroid Build Coastguard Workerreadonly OUT_DIR="$1" 4*fc3927beSAndroid Build Coastguard Workerreadonly DIST_DIR="$2" 5*fc3927beSAndroid Build Coastguard Workerreadonly BUILD_NUMBER="$3" 6*fc3927beSAndroid Build Coastguard Worker 7*fc3927beSAndroid Build Coastguard Workerreadonly SCRIPT_DIR="$(dirname "$0")" 8*fc3927beSAndroid Build Coastguard Worker 9*fc3927beSAndroid Build Coastguard Workerreadonly ARM=arm64 10*fc3927beSAndroid Build Coastguard Workerreadonly X86=x86_64 11*fc3927beSAndroid Build Coastguard Worker 12*fc3927beSAndroid Build Coastguard WorkerNATIVE_LIBRARIES=${DIST_DIR}"/layoutlib_native/darwin" 13*fc3927beSAndroid Build Coastguard Worker 14*fc3927beSAndroid Build Coastguard Worker# Find lipo command used to create and manipulate universal binaries 15*fc3927beSAndroid Build Coastguard WorkerLIPO=$(/usr/bin/xcrun --find lipo) 16*fc3927beSAndroid Build Coastguard Worker 17*fc3927beSAndroid Build Coastguard Workermkdir ${OUT_DIR}/${ARM} 18*fc3927beSAndroid Build Coastguard Workermkdir ${OUT_DIR}/${X86} 19*fc3927beSAndroid Build Coastguard Worker 20*fc3927beSAndroid Build Coastguard Worker# Split all universal binaries built for layoutlib into an ARM64 version and a X86_64 version 21*fc3927beSAndroid Build Coastguard Workerfor f in ${NATIVE_LIBRARIES}/* 22*fc3927beSAndroid Build Coastguard Workerdo 23*fc3927beSAndroid Build Coastguard Worker ${LIPO} $f -output ${OUT_DIR}/${ARM}/$(basename $f) -thin ${ARM} 24*fc3927beSAndroid Build Coastguard Worker ${LIPO} $f -output ${OUT_DIR}/${X86}/$(basename $f) -thin ${X86} 25*fc3927beSAndroid Build Coastguard Workerdone 26*fc3927beSAndroid Build Coastguard Worker 27*fc3927beSAndroid Build Coastguard Worker# Put the single architecture binaries inside the DIST folder to be accessible on ab/ 28*fc3927beSAndroid Build Coastguard Workerif [[ -d "${DIST_DIR}" ]]; then 29*fc3927beSAndroid Build Coastguard Worker mkdir -p ${DIST_DIR}/layoutlib_native/darwin 30*fc3927beSAndroid Build Coastguard Worker cp -r ${OUT_DIR}/${ARM} ${DIST_DIR}/layoutlib_native/darwin 31*fc3927beSAndroid Build Coastguard Worker cp -r ${OUT_DIR}/${X86} ${DIST_DIR}/layoutlib_native/darwin 32*fc3927beSAndroid Build Coastguard Workerfi 33*fc3927beSAndroid Build Coastguard Worker 34*fc3927beSAndroid Build Coastguard Worker# Clean 35*fc3927beSAndroid Build Coastguard Workerrm -rf ${OUT_DIR}/${ARM} 36*fc3927beSAndroid Build Coastguard Workerrm -rf ${OUT_DIR}/${X86} 37*fc3927beSAndroid Build Coastguard Worker 38*fc3927beSAndroid Build Coastguard Workerexit 0 39