-
Notifications
You must be signed in to change notification settings - Fork 322
/
Copy pathbuild-android-xxhash.sh
executable file
·127 lines (90 loc) · 3.8 KB
/
build-android-xxhash.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
# Copyright 2016 leenjewel
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# # read -n1 -p "Press any key to continue..."
set -u
source ./build-android-common.sh
init_log_color
TOOLS_ROOT=$(pwd)
SOURCE="$0"
while [ -h "$SOURCE" ]; do
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
pwd_path="$(cd -P "$(dirname "$SOURCE")" && pwd)"
echo pwd_path=${pwd_path}
echo TOOLS_ROOT=${TOOLS_ROOT}
LIB_VERSION="v0.8.0"
LIB_NAME="xxhash-0.8.0"
LIB_DEST_DIR="${pwd_path}/../output/android/xxhash"
#echo "https://github.com/xxhash/xxhash/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz"
rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}"
[ -f "${LIB_NAME}.tar.gz" ] || curl -L https://github.com/Cyan4973/xxHash/archive/${LIB_VERSION}.tar.gz >${LIB_NAME}.tar.gz
set_android_toolchain_bin
function configure_make() {
ARCH=$1
ABI=$2
ABI_TRIPLE=$3
log_info "configure $ABI start..."
if [ -d "${LIB_NAME}" ]; then
rm -fr "${LIB_NAME}"
fi
tar xfz "${LIB_NAME}.tar.gz"
pushd .
cd "${LIB_NAME}"
# cp -f ../Makefile.xxhash ./Makefile
PREFIX_DIR="${pwd_path}/../output/android/xxhash-${ABI}"
if [ -d "${PREFIX_DIR}" ]; then
rm -fr "${PREFIX_DIR}"
fi
mkdir -p "${PREFIX_DIR}"
OUTPUT_ROOT=${TOOLS_ROOT}/../output/android/xxhash-${ABI}
mkdir -p ${OUTPUT_ROOT}/log
set_android_toolchain "xxhash" "${ARCH}" "${ANDROID_API}"
set_android_cpu_feature "xxhash" "${ARCH}" "${ANDROID_API}"
export ANDROID_NDK_HOME=${ANDROID_NDK_ROOT}
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME}
#LZ4_OUT_DIR="${pwd_path}/../output/android/lz4-${ABI}"
#export LDFLAGS="${LDFLAGS} -L${LZ4_OUT_DIR}/lib"
#export CFLAGS="${CFLAGS} -I${LZ4_OUT_DIR}/include"
android_printf_global_params "$ARCH" "$ABI" "$ABI_TRIPLE" "$PREFIX_DIR" "$OUTPUT_ROOT"
if [[ "${ARCH}" == "x86_64" ]]; then
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --disable-app --enable-lib-only >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
elif [[ "${ARCH}" == "x86" ]]; then
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --disable-app --enable-lib-only >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
elif [[ "${ARCH}" == "arm" ]]; then
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --disable-app --enable-lib-only >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
elif [[ "${ARCH}" == "arm64" ]]; then
# --disable-lib-only need xml2 supc++ stdc++14
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --disable-app --enable-lib-only >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
else
log_error "not support" && exit 1
fi
log_info "make $ABI start..."
export PREFIX=$PREFIX_DIR
make clean >>"${OUTPUT_ROOT}/log/${ABI}.log"
if make -j$(get_cpu_count) >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1; then
make install >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
fi
popd
}
log_info "${PLATFORM_TYPE} ${LIB_NAME} start..."
for ((i = 0; i < ${#ARCHS[@]}; i++)); do
if [[ $# -eq 0 || "$1" == "${ARCHS[i]}" ]]; then
configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android"
fi
done
log_info "${PLATFORM_TYPE} ${LIB_NAME} end..."