Skip to content

Commit 87ff6f6

Browse files
committed
pre install use cache.
1 parent c70b054 commit 87ff6f6

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

tools/install-pre-lib.sh

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,45 @@ function fix_prefix(){
4343

4444
function download() {
4545
local plat=$1
46+
47+
local oname="build/pre/${TAG}-$plat.zip"
48+
if [[ -f "$oname" ]];then
49+
echo "$oname already exist,no need download."
50+
return
51+
fi
52+
4653
local fname="$LIB_NAME-$plat-universal-$VER.zip"
4754
local url="https://github.com/debugly/MRFFToolChainBuildShell/releases/download/$TAG/$fname"
55+
4856
echo "---[download $fname]-----------------"
4957
echo "$url"
50-
mkdir -p build/pre && cd build/pre
51-
curl -LO "$url"
52-
mkdir -p ../product/$plat/universal
53-
unzip -oq $fname -d ../product/$plat/universal
54-
if command -v tree >/dev/null 2>&1; then
55-
tree -L 2 ../product/$plat/universal
58+
mkdir -p build/pre
59+
local tname="build/pre/${TAG}.tmp"
60+
curl -L "$url" -o "$tname"
61+
if [[ $? -eq 0 ]];then
62+
mv "$tname" "$oname"
63+
fi
64+
}
65+
66+
function extract(){
67+
local plat=$1
68+
local oname="build/pre/${TAG}-$plat.zip"
69+
70+
if [[ -f "$oname" ]];then
71+
mkdir -p ../product/$plat/universal
72+
unzip -oq "$oname" -d ../product/$plat/universal
73+
if command -v tree >/dev/null 2>&1; then
74+
tree -L 2 ../product/$plat/universal
75+
fi
76+
else
77+
echo "you need download ${oname} firstly."
78+
exit 1
5679
fi
57-
echo ""
58-
cd - >/dev/null
5980
}
6081

6182
function install(){
6283
download "$*"
84+
extract "$*"
6385
fix_prefix "$*"
6486
}
6587

@@ -81,7 +103,7 @@ VER=$(echo $TAG | awk -F - '{print $2}')
81103

82104
if [[ "$PLAT" == 'ios' || "$PLAT" == 'macos' ]]; then
83105
install $PLAT
84-
elif [[ "$PLAT" == 'all' ]]; then
106+
elif [[ "$PLAT" == 'all' ]]; then
85107
plats="ios macos"
86108
for plat in $plats; do
87109
install $plat

0 commit comments

Comments
 (0)