Implement differently logic to strip and copy the tvos libraries

This commit is contained in:
Eric Miotto
2021-07-05 13:50:39 -07:00
parent 245db5371d
commit 376b6f20eb

View File

@@ -1444,6 +1444,25 @@ function cmake_config_opt() {
fi
}
function copy_lib_stripping_architecture() {
local source="$1"
local dest="$2"
local arch="$3"
# An alternative approach would be to use || to first
# attempt the removal of the slice and fall back to the
# copy when failing.
# However, this would leave unneeded error messages in the logs
# that may hinder investigation; in addition, in this scenario
# the `call` function seems to not propagate correctly failure
# exit codes.
if lipo -archs "${source}" | grep -q "${arch}"; then
call lipo -remove "${arch}" "${source}" -output "${dest}"
else
call cp "${source}" "${dest}"
fi
}
function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
local clang_dest_dir="$1"
@@ -1470,7 +1489,7 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
if [[ -f "${HOST_LIB_PATH}" ]]; then
if [[ "$OS" == "tvos" ]]; then
# This is to avoid strip failures when generating a toolchain
call lipo -remove i386 "${HOST_LIB_PATH}" -output "${DEST_LIB_PATH}" || call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
copy_lib_stripping_architecture "${HOST_LIB_PATH}" "${DEST_LIB_PATH}" i386
else
call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
fi
@@ -1487,7 +1506,7 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
if [[ "$OS" == "tvos" ]]; then
# This is to avoid strip failures when generating a toolchain
call lipo -remove i386 "${HOST_SIM_LIB_PATH}" -output "${DEST_SIM_LIB_PATH}" || call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
copy_lib_stripping_architecture "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}" i386
else
call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
fi