From a4c9555695bac2696897adcc18b926c58db56a97 Mon Sep 17 00:00:00 2001 From: Yanzhan Yang Date: Fri, 19 Jul 2019 00:44:29 +0800 Subject: [PATCH] add static library prune utility (#1755) --- tools/shell/prune_static_library.sh | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tools/shell/prune_static_library.sh diff --git a/tools/shell/prune_static_library.sh b/tools/shell/prune_static_library.sh new file mode 100644 index 0000000000..1b555e92bb --- /dev/null +++ b/tools/shell/prune_static_library.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# Split all static libaries in the current directory into corresponding archtectures + +archs=(armv7 arm64) +libraries=(*.a) +libtool="/usr/bin/libtool" + +rm -rf tmp +mkdir tmp + +echo "splitting and pruning ${libraries[*]}..." + +for library in ${libraries[*]} +do + lipo -info $library + # Extract individual architectures for this library + for arch in ${archs[*]} + do + mkdir -p tmp/$arch + lipo -thin $arch $library -o ./tmp/$arch/${library} + cd tmp/$arch + ar x $library + rm $library + ar -rcs $library *.o + cd ../.. + done +done + +echo "joining static libriries..." +cd tmp +libtool -static -o $library armv7/$library arm64/$library + +# # split static library into objects +# ar x 1.a +# # join objects into static library +# ar -rcs 2.a *.o +# # join static libraries into one single static library +# libtool -static -o 3.a 1.a 2.a +# # list file by file size, prune according to file size +# ls -Slhr directory -- GitLab