Skip to content

Commit 35e1746

Browse files
committed
加入arm架构编译脚本
1 parent 0b9a29e commit 35e1746

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ openssl-1.0.2g
44
libwebsockets
55
libuv
66
android-toolchain-aarch64
7+
android-toolchain-arm

03-build-arm.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
# 当一个命令执行失败时,shell会立即退出
4+
set -e
5+
# path to NDK
6+
export NDK=/opt/android-ndk
7+
# create a local android toolchain
8+
$NDK/build/tools/make-standalone-toolchain.sh \
9+
--force \
10+
--arch=arm \
11+
--platform=android-21 \
12+
--toolchain=arm-linux-android-4.9 \
13+
--install-dir=`pwd`/android-toolchain-arm
14+
15+
# setup environment to use the gcc/ld from the android toolchain
16+
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
17+
export TOOL=arm-linux-androideabi
18+
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
19+
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
20+
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
21+
export LINK=${CXX}
22+
export LD=$NDK_TOOLCHAIN_BASENAME-ld
23+
export AR=$NDK_TOOLCHAIN_BASENAME-ar
24+
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
25+
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
26+
27+
# setup buildflags
28+
export ARCH_FLAGS=""
29+
export ARCH_LINK=
30+
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
31+
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
32+
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
33+
export LDFLAGS=" ${ARCH_LINK} "
34+
35+
36+
echo 'build zlib'
37+
# configure and build zlib
38+
[ ! -f ./android-toolchain-arm/lib/libz.a ] && {
39+
cd zlib-1.2.8
40+
PATH=$TOOLCHAIN_PATH:$PATH ./configure --static --prefix=$TOOLCHAIN_PATH/..
41+
PATH=$TOOLCHAIN_PATH:$PATH make
42+
PATH=$TOOLCHAIN_PATH:$PATH make install
43+
cd ..
44+
}
45+
echo 'build zlib done'
46+
47+
echo 'build openssl'
48+
# configure and build openssl
49+
{
50+
PREFIX=$TOOLCHAIN_PATH/..
51+
cd openssl-1.0.2g
52+
./Configure android --prefix=${PREFIX} no-shared no-idea no-mdc2 no-rc5 no-zlib no-zlib-dynamic enable-tlsext no-ssl2 no-ssl3 enable-ec enable-ecdh enable-ecp
53+
PATH=$TOOLCHAIN_PATH:$PATH make depend
54+
PATH=$TOOLCHAIN_PATH:$PATH make
55+
PATH=$TOOLCHAIN_PATH:$PATH make install_sw
56+
cd ..
57+
}
58+
echo 'build openssl done'
59+
60+
echo 'build libuv'
61+
# configure and build libuv
62+
[ ! -f ./libuv/out/Debug/libuv.a ] && {
63+
PREFIX=$TOOLCHAIN_PATH/..
64+
cd libuv
65+
./gyp_uv.py -Dtarget_arch=arm -DOS=android -f make-android
66+
make -C out
67+
cd ..
68+
}
69+
echo 'build libuv done'
70+
71+
# configure and build libwebsockets
72+
[ ! -f ./android-toolchain-arm/lib/libwebsockets.a ] && {
73+
cd libwebsockets
74+
[ ! -d build ] && mkdir build
75+
cd build
76+
PATH=$TOOLCHAIN_PATH:$PATH cmake \
77+
-DCMAKE_C_COMPILER=$CC \
78+
-DCMAKE_AR=$AR \
79+
-DCMAKE_RANLIB=$RANLIB \
80+
-DCMAKE_C_FLAGS="$CFLAGS" \
81+
-DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PATH/.. \
82+
-DLWS_WITH_SHARED=ON \
83+
-DLWS_WITH_STATIC=ON \
84+
-DLWS_WITHOUT_DAEMONIZE=ON \
85+
-DLWS_WITHOUT_TESTAPPS=ON \
86+
-DLWS_IPV6=OFF \
87+
-DLWS_USE_BUNDLED_ZLIB=OFF \
88+
-DLWS_WITH_SSL=ON \
89+
-DLWS_WITH_HTTP2=ON \
90+
-DLWS_WITH_LIBUV=ON \
91+
-DLWS_WITH_PLUGINS=ON \
92+
-DLWS_WITH_LWSWS=ON \
93+
-DLWS_OPENSSL_LIBRARIES="$TOOLCHAIN_PATH/../lib/libssl.a;$TOOLCHAIN_PATH/../lib/libcrypto.a" \
94+
-DLWS_OPENSSL_INCLUDE_DIRS=$TOOLCHAIN_PATH/../include \
95+
-DLWS_LIBUV_LIBRARIES="${TOOLCHAIN_PATH}/../../libuv/out/Debug/libuv.a" \
96+
-DLWS_LIBUV_INCLUDE_DIRS=${TOOLCHAIN_PATH}/../../libuv/include \
97+
-DCMAKE_BUILD_TYPE=Debug \
98+
..
99+
PATH=$TOOLCHAIN_PATH:$PATH make
100+
PATH=$TOOLCHAIN_PATH:$PATH make install
101+
cd ../..
102+
}
File renamed without changes.

0 commit comments

Comments
 (0)