Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 0x1306a94/0ec21861a579887c5355ebff575fbd0a to your computer and use it in GitHub Desktop.
Save 0x1306a94/0ec21861a579887c5355ebff575fbd0a to your computer and use it in GitHub Desktop.
提取chromium net 模块静态库以及依赖库
#!/bin/sh
set -e
# $1 编译输出目录
# $2 lib输出根目录
function print_usage_and_exit() {
echo "${0} [build_out_dir] [libs_out_dir]"
exit 1
}
function get_fullpath() {
_PWD=`pwd`
if [ -d $1 ]; then
cd $1
elif [ -f $1 ]; then
cd `dirname $1`
else
cd
fi
echo $(cd ..; cd -)
cd ${_PWD} >/dev/null
}
LIBS=$(cat <<EOF
libnet.a
libbase.a
libbrotli.a
libbase_i18n.a
libbase_paths.a
libbase_static.a
libboringssl.a
libchrome_zlib.a
libcrcrypto.a
libdynamic_annotations.a
libicui18n.a
libicuuc.a
libprefs.a
libprotobuf_lite.a
libsdch.a
liburl.a
libzlib_x86_simd.a
libevent.a
libmodp_b64.a
libnet_quic_proto.a
libprefs.a
EOF
)
BUILD_ROOT=`get_fullpath ${1}`
LIB_ROOT=`get_fullpath ${2}`
echo "BUILD_ROOT: ${BUILD_ROOT}"
echo "LIB_ROOT: ${LIB_ROOT}"
function extract_lib() {
for path in $(ls $1);
do
if [[ -d $1/$path ]];
then
extract_lib $1/$path
elif [[ "${path}" == *.a && "${LIBS}" == *$(basename $path)* ]];
then
# echo "$1/${path}"
DIR_NAME=$(basename $(dirname $1/$path))
# echo "DIR_NAME: ${DIR_NAME}"
mkdir -p $LIB_ROOT/libs/$DIR_NAME
cp -f $1/$path $LIB_ROOT/libs/$DIR_NAME
echo "cp $1/$path to $LIB_ROOT/libs/$DIR_NAME/$path"
fi
done
}
extract_lib $BUILD_ROOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment