• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3readonly OUT_DIR="$1"
4readonly DIST_DIR="$2"
5readonly BUILD_NUMBER="$3"
6
7readonly SCRIPT_DIR="$(dirname "$0")"
8
9readonly ARM=arm64
10readonly X86=x86_64
11
12NATIVE_LIBRARIES=${SCRIPT_DIR}"/../../out/host/darwin-x86/lib64"
13
14# Find lipo command used to create and manipulate universal binaries
15LIPO=$(/usr/bin/xcrun --find lipo)
16
17mkdir ${OUT_DIR}/${ARM}
18mkdir ${OUT_DIR}/${X86}
19
20# Split all universal binaries built for layoutlib into an ARM64 version and a X86_64 version
21for f in ${NATIVE_LIBRARIES}/*
22do
23  ${LIPO} $f -output ${OUT_DIR}/${ARM}/$(basename $f) -thin ${ARM}
24  ${LIPO} $f -output ${OUT_DIR}/${X86}/$(basename $f) -thin ${X86}
25done
26
27# Put the single architecture binaries inside the DIST folder to be accessible on ab/
28if [[ -d "${DIST_DIR}" ]]; then
29    cp -r ${OUT_DIR}/${ARM} ${DIST_DIR}/layoutlib_native/darwin
30    cp -r ${OUT_DIR}/${X86} ${DIST_DIR}/layoutlib_native/darwin
31fi
32
33# Clean
34rm -rf ${OUT_DIR}/${ARM}
35rm -rf ${OUT_DIR}/${X86}
36
37exit 0
38