Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
liyin committed Jan 5, 2017
1 parent eca46da commit 47940fe
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ tools/*-android-toolchain
tools/curl*
tools/openssl*
tools/protobuf*
output/
32 changes: 20 additions & 12 deletions tools/build-curl4android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@

set -u

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 )"

source ./_shared.sh

# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("android" "android-armv7" "android64-arm64" "android-x86" "android-x86_64" "mips" "mips64")
ARCHS=("android" "android-armeabi" "android64-aarch64" "android-x86" "android64" "android-mips" "android-mips64")
OUTNAME=("armeabi" "armeabi-v7a" "arm64-v8a" "x86" "x86_64" "mips" "mips64")
TOOLS_ROOT=`pwd`
TOOLS_ROOT="${pwd_path}"
LIB_NAME="curl-7.51.0"
LIB_DEST_DIR=${TOOLS_ROOT}/libs
LIB_DEST_DIR=${TOOLS_ROOT}/../output/android
NDK=$ANDROID_NDK_ROOT
ANDROID_PLATFORM="android-23"
ANDROID_API="21"
ANDROID_API="23"
[ -f ${LIB_NAME}.tar.gz ] || wget https://curl.haxx.se/download/${LIB_NAME}.tar.gz
# Unarchive library, then configure and make for specified architectures
configure_make()
Expand All @@ -38,12 +46,15 @@ configure_make()

configure $*
# fix me
cp ${TOOLS_ROOT}/../lib/${OUT}/libssl.a ${SYSROOT}/usr/lib
cp ${TOOLS_ROOT}/../lib/${OUT}/libcrypto.a ${SYSROOT}/usr/lib
cp -r ${TOOLS_ROOT}/../include/${OUT}/openssl ${SYSROOT}/usr/include
cp ${TOOLS_ROOT}/../output/android/openssl-android-${OUT}/lib/libssl.a ${SYSROOT}/usr/lib
cp ${TOOLS_ROOT}/../output/android/openssl-android-${OUT}/lib/libcrypto.a ${SYSROOT}/usr/lib
cp -r ${TOOLS_ROOT}/../output/android/openssl-android-${OUT}/include/openssl ${SYSROOT}/usr/include

mkdir -p ${LIB_DEST_DIR}/${OUT}
./configure --prefix=${LIB_DEST_DIR}/${OUT} \
PREFIX_DIR=${LIB_DEST_DIR}/curl-android-${OUT}
if [ -d "${PREFIX_DIR}" ]; then
rm -fr ${PREFIX_DIR}
fi
./configure --prefix=${PREFIX_DIR} \
--with-sysroot=${SYSROOT} \
--host=${TOOL} \
--with-ssl=/usr \
Expand All @@ -56,9 +67,6 @@ configure_make()
if make -j4
then
make install

cp ${LIB_DEST_DIR}/${OUT}/lib/libcurl.a ${TOOLS_ROOT}/../lib/${OUT}
cp -r ${LIB_DEST_DIR}/${OUT}/include/curl ${TOOLS_ROOT}/../include/${OUT}
fi;
popd;
}
Expand Down
32 changes: 22 additions & 10 deletions tools/build-openssl4android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@

set -u

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 )"

source ./_shared.sh

# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("android" "android-armv7" "android64-arm64" "android-x86" "android-x86_64" "mips" "mips64")
ARCHS=("android" "android-armeabi" "android64-aarch64" "android-x86" "android64" "android-mips" "android-mips64")
OUTNAME=("armeabi" "armeabi-v7a" "arm64-v8a" "x86" "x86_64" "mips" "mips64")
TOOLS_ROOT=`pwd`
TOOLS_ROOT="${pwd_path}"
LIB_NAME="openssl-1.1.0c"
LIB_DEST_DIR=${TOOLS_ROOT}/libs
LIB_DEST_DIR=${TOOLS_ROOT}/../output/android
NDK=$ANDROID_NDK_ROOT
ANDROID_API="21"
[ -d ${LIB_DEST_DIR} ] && rm -rf ${LIB_DEST_DIR}
ANDROID_API="23"
[ -f "${LIB_NAME}.tar.gz" ] || wget https://www.openssl.org/source/${LIB_NAME}.tar.gz;
# Unarchive library, then configure and make for specified architectures
configure_make() {
Expand All @@ -35,9 +42,14 @@ configure_make() {
tar xfz "${LIB_NAME}.tar.gz"
pushd "${LIB_NAME}";

PREFIX_DIR=${LIB_DEST_DIR}/openssl-android-${OUT}
if [ -d "${PREFIX_DIR}" ]; then
rm -fr ${PREFIX_DIR}
fi

configure $*
./Configure $ARCH \
--prefix=${LIB_DEST_DIR}/${OUT} \
--prefix=${PREFIX_DIR} \
--with-zlib-include=$SYSROOT/usr/include \
--with-zlib-lib=$SYSROOT/usr/lib \
zlib \
Expand All @@ -49,11 +61,11 @@ configure_make() {
if make -j4
then
make install
[ -d ${TOOLS_ROOT}/../include/$OUT ] || mkdir -p ${TOOLS_ROOT}/../include/$OUT
cp -r include/openssl ${TOOLS_ROOT}/../include/$OUT
# [ -d ${TOOLS_ROOT}/../include/$OUT ] || mkdir -p ${TOOLS_ROOT}/../include/$OUT
# cp -r include/openssl ${TOOLS_ROOT}/../include/$OUT

[ -d ${TOOLS_ROOT}/../lib/$OUT ] || mkdir -p ${TOOLS_ROOT}/../lib/$OUT
find . -type f -iname \( 'libssl.a' -or -iname 'libcrypto.a' \) -exec cp {} ${TOOLS_ROOT}/../lib/$OUT \;
# [ -d ${TOOLS_ROOT}/../lib/$OUT ] || mkdir -p ${TOOLS_ROOT}/../lib/$OUT
# find . -type f -iname \( 'libssl.a' -or -iname 'libcrypto.a' \) -exec cp {} ${TOOLS_ROOT}/../lib/$OUT \;
fi;
}

Expand Down
6 changes: 3 additions & 3 deletions tools/build-openssl4ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PLATFORMS=("iPhoneOS" "iPhoneOS" "iPhoneOS" "iPhoneSimulator" "iPhoneSimulator")
DEVELOPER=`xcode-select -print-path`
SDK_VERSION=""10.2""
LIB_NAME="openssl-1.1.0c"
LIB_DEST_DIR="lib"
LIB_DEST_DIR="${pwd_path}/../output/ios/openssl-ios-universal"
HEADER_DEST_DIR="include"
rm -rf "${HEADER_DEST_DIR}" "${LIB_DEST_DIR}" "${LIB_NAME}"

Expand All @@ -56,7 +56,7 @@ configure_make()
export TOOLS="${DEVELOPER}"
export CC="${TOOLS}/usr/bin/gcc -arch ${ARCH}"

PREFIX_DIR="${pwd_path}/openssl-ios-${ARCH}"
PREFIX_DIR="${pwd_path}/../output/ios/openssl-ios-${ARCH}"
if [ -d "${PREFIX_DIR}" ]; then
rm -fr "${PREFIX_DIR}"
fi
Expand Down Expand Up @@ -89,7 +89,7 @@ done
create_lib()
{
LIB_SRC=$1; LIB_DST=$2;
LIB_PATHS=( "${ARCHS[@]/#/${pwd_path}/openssl-ios-}" )
LIB_PATHS=( "${ARCHS[@]/#/${pwd_path}/../output/ios/openssl-ios-}" )
LIB_PATHS=( "${LIB_PATHS[@]/%//lib/${LIB_SRC}}" )
lipo ${LIB_PATHS[@]} -create -output "${LIB_DST}"
}
Expand Down
28 changes: 18 additions & 10 deletions tools/build-protobuf4android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@

set -u

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 )"

source ./_shared.sh

# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("android" "android-armv7" "android64-arm64" "android-x86" "android-x86_64" "mips" "mips64")
ARCHS=("android" "android-armeabi" "android64-aarch64" "android-x86" "android64" "android-mips" "android-mips64")
OUTNAME=("armeabi" "armeabi-v7a" "arm64-v8a" "x86" "x86_64" "mips" "mips64")
TOOLS_ROOT=`pwd`
TOOLS_ROOT=${pwd_path}
LIB_NAME="protobuf"
LIB_VERSION="3.1.0"
LIB_FILENAME=${LIB_NAME}-${LIB_VERSION}
LIB_DEST_DIR=${TOOLS_ROOT}/libs
LIB_DEST_DIR=${TOOLS_ROOT}/../output/android
NDK=$ANDROID_NDK_ROOT
ANDROID_API="21"
ANDROID_API="23"
# rm -rf ${LIB_DEST_DIR}
[ -f ${LIB_FILENAME}.tar.gz ] || wget https://github.com/google/${LIB_NAME}/archive/v${LIB_VERSION}.tar.gz -O ${LIB_FILENAME}.tar.gz
# Unarchive library, then configure and make for specified architectures
Expand All @@ -38,13 +46,18 @@ configure_make() {
tar xfz "${LIB_FILENAME}.tar.gz"
pushd "${LIB_FILENAME}";

PREFIX_DIR=${LIB_DEST_DIR}/protobuf-android-${OUT}
if [ -d "${PREFIX_DIR}" ]; then
rm -fr ${PREFIX_DIR}
fi

export LDFLAGS="-static-libstdc++"
export LIBS="-lc++_static -latomic"
configure $* "clang"
# fix CXXFLAGS
export CXXFLAGS=${CXXFLAGS/"-finline-limit=64"/""}
./autogen.sh
./configure --prefix=${LIB_DEST_DIR}/${OUT} \
./configure --prefix=${PREFIX_DIR} \
--with-sysroot=${SYSROOT} \
--with-protoc=`which protoc` \
--with-zlib \
Expand All @@ -57,11 +70,6 @@ configure_make() {
then
mkdir -p ${LIB_DEST_DIR}/${OUT}
make install

[ -d ${TOOLS_ROOT}/../lib/${OUT} ] || mkdir -p ${TOOLS_ROOT}/../lib/${OUT}
find ${LIB_DEST_DIR}/${OUT}/lib -type f -iname '*.a' -exec cp {} ${TOOLS_ROOT}/../lib/${OUT} \;
[ -d ${TOOLS_ROOT}/../include/${OUT} ] || mkdir -p ${TOOLS_ROOT}/../include/${OUT}
cp -r ${LIB_DEST_DIR}/$OUT/include/ ${TOOLS_ROOT}/../include/${OUT}
fi;
popd;
}
Expand Down

0 comments on commit 47940fe

Please sign in to comment.