From 40913b5f498de7a6a33d7c03a7f9ff04e6356a99 Mon Sep 17 00:00:00 2001 From: Nakhyun Choi Date: Tue, 27 Oct 2020 18:42:09 +0900 Subject: [PATCH 1/2] fix the local build is available again --- tools/build-android-common.sh | 18 +++++++++---- tools/build-android-curl.sh | 6 ++++- tools/build-android-lz4.sh | 2 +- tools/build-android-nghttp2.sh | 6 ++++- tools/build-android-openssl.sh | 6 ++++- tools/build-android-rsync.sh | 2 +- tools/build-android-xxhash.sh | 2 +- tools/build-android-zstd.sh | 2 +- tools/build-ios-common.sh | 47 ++++++++++++++++++++++------------ tools/build-ios-curl.sh | 17 +++++------- tools/build-ios-nghttp2.sh | 17 +++++------- tools/build-ios-openssl.sh | 17 +++++------- 12 files changed, 80 insertions(+), 62 deletions(-) diff --git a/tools/build-android-common.sh b/tools/build-android-common.sh index ba1e6819..591762e7 100755 --- a/tools/build-android-common.sh +++ b/tools/build-android-common.sh @@ -16,16 +16,24 @@ source ./build-common.sh +if [ -z ${arch+x} ]; then + arch=("arm" "arm64" "x86" "x86_64") +fi +if [ -z ${abi+x} ]; then + abi=("armeabi-v7a" "arm64-v8a" "x86" "x86_64") +fi +if [ -z ${api+x} ]; then + api=23 +fi + export PLATFORM_TYPE="Android" -export ARCHS=("$arch") -export ABIS=("$abi") -export ABI_TRIPLES=("$arch-linux-android") -export ANDROID_API=$api +export ARCHS=(${arch[@]}) +export ABIS=(${abi[@]}) +export ANDROID_API=(${api[@]}) # for test # export ARCHS=("x86_64") # export ABIS=("x86_64") -# export ABI_TRIPLES=("x86_64-linux-android") if [[ -z ${ANDROID_NDK_ROOT} ]]; then echo "ANDROID_NDK_ROOT not defined" diff --git a/tools/build-android-curl.sh b/tools/build-android-curl.sh index dbab87a6..b6485d74 100755 --- a/tools/build-android-curl.sh +++ b/tools/build-android-curl.sh @@ -20,6 +20,10 @@ set -u source ./build-android-common.sh +if [ -z ${version+x} ]; then + version="7.68.0" +fi + init_log_color TOOLS_ROOT=$(pwd) @@ -124,7 +128,7 @@ 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]}" "${ABI_TRIPLES[i]}" + configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android" fi done diff --git a/tools/build-android-lz4.sh b/tools/build-android-lz4.sh index a5d2cc84..2a19e6e6 100755 --- a/tools/build-android-lz4.sh +++ b/tools/build-android-lz4.sh @@ -117,7 +117,7 @@ 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]}" "${ABI_TRIPLES[i]}" + configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android" fi done diff --git a/tools/build-android-nghttp2.sh b/tools/build-android-nghttp2.sh index 0e979828..ee81cc77 100755 --- a/tools/build-android-nghttp2.sh +++ b/tools/build-android-nghttp2.sh @@ -20,6 +20,10 @@ set -u source ./build-android-common.sh +if [ -z ${version+x} ]; then + version="1.40.0" +fi + init_log_color TOOLS_ROOT=$(pwd) @@ -115,7 +119,7 @@ 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]}" "${ABI_TRIPLES[i]}" + configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android" fi done diff --git a/tools/build-android-openssl.sh b/tools/build-android-openssl.sh index 764a4598..27a3ae1b 100755 --- a/tools/build-android-openssl.sh +++ b/tools/build-android-openssl.sh @@ -20,6 +20,10 @@ set -u source ./build-android-common.sh +if [ -z ${version+x} ]; then + version="1.1.1d" +fi + init_log_color TOOLS_ROOT=$(pwd) @@ -119,7 +123,7 @@ 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]}" "${ABI_TRIPLES[i]}" + configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android" fi done diff --git a/tools/build-android-rsync.sh b/tools/build-android-rsync.sh index 5918c00f..1b4ab06b 100755 --- a/tools/build-android-rsync.sh +++ b/tools/build-android-rsync.sh @@ -134,7 +134,7 @@ 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]}" "${ABI_TRIPLES[i]}" + configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android" fi done diff --git a/tools/build-android-xxhash.sh b/tools/build-android-xxhash.sh index 6b5422b9..06c6eb35 100755 --- a/tools/build-android-xxhash.sh +++ b/tools/build-android-xxhash.sh @@ -122,7 +122,7 @@ 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]}" "${ABI_TRIPLES[i]}" + configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android" fi done diff --git a/tools/build-android-zstd.sh b/tools/build-android-zstd.sh index 8cbcdade..20dc1fc9 100755 --- a/tools/build-android-zstd.sh +++ b/tools/build-android-zstd.sh @@ -122,7 +122,7 @@ 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]}" "${ABI_TRIPLES[i]}" + configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ARCHS[i]}-linux-android" fi done diff --git a/tools/build-ios-common.sh b/tools/build-ios-common.sh index 7aaaa9aa..7ce1bc91 100755 --- a/tools/build-ios-common.sh +++ b/tools/build-ios-common.sh @@ -16,18 +16,31 @@ source ./build-common.sh +if [ -z ${api+x} ]; then + api="8.0" +fi +if [ -z ${arch+x} ]; then + arch=("armv7" "arm64" "arm64e" "x86_64") +fi +if [ -z ${sdk+x} ]; then + sdk=("iphoneos" "iphoneos" "iphoneos" "iphonesimulator") +fi +if [ -z ${platform+x} ]; then + platform=("iPhoneOS" "iPhoneOS" "iphoneos" "iPhoneSimulator") +fi + export PLATFORM_TYPE="iOS" export IOS_MIN_TARGET="$api" -export ARCHS=("$arch") -export SDKS=("$sdk") -export PLATFORMS=("$platform") +export ARCHS=(${arch[@]}) +export SDKS=(${sdk[@]}) +export PLATFORMS=(${platform[@]}) # for test !!! # export ARCHS=("armv7") # export SDKS=("iphoneos") # export PLATFORMS=("iPhoneOS") -function get_android_arch() { +function get_ios_arch() { local common_arch=$1 case ${common_arch} in armv7) @@ -49,7 +62,7 @@ function get_android_arch() { } function ios_get_build_host() { - local arch=$(get_android_arch $1) + local arch=$(get_ios_arch $1) case ${arch} in armv7) echo "armv7-ios-darwin" @@ -69,47 +82,47 @@ function ios_get_build_host() { esac } -function set_android_cpu_feature() { +function set_ios_cpu_feature() { local name=$1 - local arch=$(get_android_arch $2) + local arch=$(get_ios_arch $2) local ios_min_target=$3 local sysroot=$4 case ${arch} in armv7) export CC="xcrun -sdk iphoneos clang -arch armv7" export CXX="xcrun -sdk iphoneos clang++ -arch armv7" - export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib " - export CXXFLAGS="-std=c++14 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CXXFLAGS="-std=c++14 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" ;; arm64) export CC="xcrun -sdk iphoneos clang -arch arm64" export CXX="xcrun -sdk iphoneos clang++ -arch arm64" - export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib " - export CXXFLAGS="-std=c++14 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CXXFLAGS="-std=c++14 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" ;; arm64e) # -march=armv8.3 ??? export CC="xcrun -sdk iphoneos clang -arch arm64e" export CXX="xcrun -sdk iphoneos clang++ -arch arm64e" - export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib " - export CXXFLAGS="-std=c++14 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CXXFLAGS="-std=c++14 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include" ;; x86) export CC="xcrun -sdk iphonesimulator clang -arch x86" export CXX="xcrun -sdk iphonesimulator clang++ -arch x86" - export CFLAGS="-arch x86 -target x86-ios-darwin -march=i386 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fstrict-aliasing -O2 -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CFLAGS="-arch x86 -target x86-ios-darwin -march=i386 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fstrict-aliasing -O2 -Wno-ignored-optimization-argument -isysroot ${sysroot} -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" export LDFLAGS="-arch x86 -target x86-ios-darwin -march=i386 -isysroot ${sysroot} -L${sysroot}/usr/lib " - export CXXFLAGS="-std=c++14 -arch x86 -target x86-ios-darwin -march=i386 -msse4.2 -mpopcnt -m64 -mtune=intel -fstrict-aliasing -DIOS -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CXXFLAGS="-std=c++14 -arch x86 -target x86-ios-darwin -march=i386 -msse4.2 -mpopcnt -m64 -mtune=intel -fstrict-aliasing -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" ;; x86-64) export CC="xcrun -sdk iphonesimulator clang -arch x86_64" export CXX="xcrun -sdk iphonesimulator clang++ -arch x86_64" - export CFLAGS="-arch x86_64 -target x86_64-ios-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fstrict-aliasing -O2 -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CFLAGS="-arch x86_64 -target x86_64-ios-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fstrict-aliasing -O2 -Wno-ignored-optimization-argument -isysroot ${sysroot} -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" export LDFLAGS="-arch x86_64 -target x86_64-ios-darwin -march=x86-64 -isysroot ${sysroot} -L${sysroot}/usr/lib " - export CXXFLAGS="-std=c++14 -arch x86_64 -target x86_64-ios-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -fstrict-aliasing -DIOS -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" + export CXXFLAGS="-std=c++14 -arch x86_64 -target x86_64-ios-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -fstrict-aliasing -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include" ;; *) log_error "not support" && exit 1 diff --git a/tools/build-ios-curl.sh b/tools/build-ios-curl.sh index d662bb8d..d0455040 100755 --- a/tools/build-ios-curl.sh +++ b/tools/build-ios-curl.sh @@ -20,6 +20,10 @@ set -u source ./build-ios-common.sh +if [ -z ${version+x} ]; then + version="7.68.0" +fi + TOOLS_ROOT=$(pwd) SOURCE="$0" @@ -45,7 +49,6 @@ echo "https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}. # https://github.com/curl/curl/releases/download/curl-7_69_0/curl-7.69.0.tar.gz # https://github.com/curl/curl/releases/download/curl-7_68_0/curl-7.68.0.tar.gz DEVELOPER=$(xcode-select -print-path) -SDK_VERSION=$(xcrun -sdk iphoneos --show-sdk-version) rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}" [ -f "${LIB_NAME}.tar.gz" ] || curl -LO https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz >${LIB_NAME}.tar.gz @@ -54,6 +57,7 @@ function configure_make() { ARCH=$1 SDK=$2 PLATFORM=$3 + SDK_PATH=$(xcrun -sdk ${SDK} --show-sdk-path) log_info "configure $ARCH start..." @@ -64,15 +68,6 @@ function configure_make() { pushd . cd "${LIB_NAME}" - export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" - export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk" - - if [ ! -d ${CROSS_TOP}/SDKs/${CROSS_SDK} ]; then - log_error "ERROR: iOS SDK version:'${SDK_VERSION}' incorrect, SDK in your system is:" - xcodebuild -showsdks | grep iOS - exit -1 - fi - PREFIX_DIR="${pwd_path}/../output/ios/curl-${ARCH}" if [ -d "${PREFIX_DIR}" ]; then rm -fr "${PREFIX_DIR}" @@ -82,7 +77,7 @@ function configure_make() { OUTPUT_ROOT=${TOOLS_ROOT}/../output/ios/curl-${ARCH} mkdir -p ${OUTPUT_ROOT}/log - set_android_cpu_feature "nghttp2" "${ARCH}" "${IOS_MIN_TARGET}" "${CROSS_TOP}/SDKs/${CROSS_SDK}" + set_ios_cpu_feature "curl" "${ARCH}" "${IOS_MIN_TARGET}" "${SDK_PATH}" OPENSSL_OUT_DIR="${pwd_path}/../output/ios/openssl-${ARCH}" NGHTTP2_OUT_DIR="${pwd_path}/../output/ios/nghttp2-${ARCH}" diff --git a/tools/build-ios-nghttp2.sh b/tools/build-ios-nghttp2.sh index e206284b..c5ddefff 100755 --- a/tools/build-ios-nghttp2.sh +++ b/tools/build-ios-nghttp2.sh @@ -20,6 +20,10 @@ set -u source ./build-ios-common.sh +if [ -z ${version+x} ]; then + version="1.40.0" +fi + TOOLS_ROOT=$(pwd) SOURCE="$0" @@ -42,7 +46,6 @@ init_log_color echo "https://github.com/nghttp2/nghttp2/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz" DEVELOPER=$(xcode-select -print-path) -SDK_VERSION=$(xcrun -sdk iphoneos --show-sdk-version) rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}" [ -f "${LIB_NAME}.tar.gz" ] || curl -LO https://github.com/nghttp2/nghttp2/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz >${LIB_NAME}.tar.gz @@ -51,6 +54,7 @@ function configure_make() { ARCH=$1 SDK=$2 PLATFORM=$3 + SDK_PATH=$(xcrun -sdk ${SDK} --show-sdk-path) log_info "configure $ARCH start..." @@ -61,15 +65,6 @@ function configure_make() { pushd . cd "${LIB_NAME}" - export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" - export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk" - - if [ ! -d ${CROSS_TOP}/SDKs/${CROSS_SDK} ]; then - log_error "ERROR: iOS SDK version:'${SDK_VERSION}' incorrect, SDK in your system is:" - xcodebuild -showsdks | grep iOS - exit -1 - fi - PREFIX_DIR="${pwd_path}/../output/ios/nghttp2-${ARCH}" if [ -d "${PREFIX_DIR}" ]; then rm -fr "${PREFIX_DIR}" @@ -79,7 +74,7 @@ function configure_make() { OUTPUT_ROOT=${TOOLS_ROOT}/../output/ios/nghttp2-${ARCH} mkdir -p ${OUTPUT_ROOT}/log - set_android_cpu_feature "nghttp2" "${ARCH}" "${IOS_MIN_TARGET}" "${CROSS_TOP}/SDKs/${CROSS_SDK}" + set_ios_cpu_feature "nghttp2" "${ARCH}" "${IOS_MIN_TARGET}" "${SDK_PATH}" ios_printf_global_params "$ARCH" "$SDK" "$PLATFORM" "$PREFIX_DIR" "$OUTPUT_ROOT" diff --git a/tools/build-ios-openssl.sh b/tools/build-ios-openssl.sh index a11b2e64..58f2f38a 100755 --- a/tools/build-ios-openssl.sh +++ b/tools/build-ios-openssl.sh @@ -20,6 +20,10 @@ set -u source ./build-ios-common.sh +if [ -z ${version+x} ]; then + version="1.1.1d" +fi + TOOLS_ROOT=$(pwd) SOURCE="$0" @@ -46,7 +50,6 @@ echo "https://www.openssl.org/source/${LIB_NAME}.tar.gz" # https://github.com/openssl/openssl/archive/OpenSSL_1_1_1d.tar.gz # https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz DEVELOPER=$(xcode-select -print-path) -SDK_VERSION=$(xcrun -sdk iphoneos --show-sdk-version) rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}" [ -f "${LIB_NAME}.tar.gz" ] || curl https://www.openssl.org/source/${LIB_NAME}.tar.gz >${LIB_NAME}.tar.gz @@ -55,6 +58,7 @@ function configure_make() { ARCH=$1 SDK=$2 PLATFORM=$3 + SDK_PATH=$(xcrun -sdk ${SDK} --show-sdk-path) log_info "configure $ARCH start..." @@ -65,15 +69,6 @@ function configure_make() { pushd . cd "${LIB_NAME}" - export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" - export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk" - - if [ ! -d ${CROSS_TOP}/SDKs/${CROSS_SDK} ]; then - log_error "ERROR: iOS SDK version:'${SDK_VERSION}' incorrect, SDK in your system is:" - xcodebuild -showsdks | grep iOS - exit -1 - fi - PREFIX_DIR="${pwd_path}/../output/ios/openssl-${ARCH}" if [ -d "${PREFIX_DIR}" ]; then rm -fr "${PREFIX_DIR}" @@ -83,7 +78,7 @@ function configure_make() { OUTPUT_ROOT=${TOOLS_ROOT}/../output/ios/openssl-${ARCH} mkdir -p ${OUTPUT_ROOT}/log - set_android_cpu_feature "nghttp2" "${ARCH}" "${IOS_MIN_TARGET}" "${CROSS_TOP}/SDKs/${CROSS_SDK}" + set_ios_cpu_feature "openssl" "${ARCH}" "${IOS_MIN_TARGET}" "${SDK_PATH}" ios_printf_global_params "$ARCH" "$SDK" "$PLATFORM" "$PREFIX_DIR" "$OUTPUT_ROOT" From 15fdd48932346036a99c78735039c3a61a35a9ba Mon Sep 17 00:00:00 2001 From: Nakhyun Choi Date: Tue, 27 Oct 2020 18:43:19 +0900 Subject: [PATCH 2/2] add macOS support --- tools/build-macos-common.sh | 93 +++++++++++++++++++++++++ tools/build-macos-curl.sh | 127 ++++++++++++++++++++++++++++++++++ tools/build-macos-nghttp2.sh | 119 ++++++++++++++++++++++++++++++++ tools/build-macos-openssl.sh | 129 +++++++++++++++++++++++++++++++++++ 4 files changed, 468 insertions(+) create mode 100755 tools/build-macos-common.sh create mode 100755 tools/build-macos-curl.sh create mode 100755 tools/build-macos-nghttp2.sh create mode 100755 tools/build-macos-openssl.sh diff --git a/tools/build-macos-common.sh b/tools/build-macos-common.sh new file mode 100755 index 00000000..8d0ab375 --- /dev/null +++ b/tools/build-macos-common.sh @@ -0,0 +1,93 @@ +#!/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. + +source ./build-common.sh + +if [ -z ${api+x} ]; then + api="10.12" +fi +if [ -z ${arch+x} ]; then + arch=("x86_64") +fi +if [ -z ${sdk+x} ]; then + sdk=("macosx") +fi +if [ -z ${platform+x} ]; then + platform=("MacOSX") +fi + +export PLATFORM_TYPE="macOS" +export MACOS_MIN_TARGET="$api" +export ARCHS=(${arch[@]}) +export SDKS=(${sdk[@]}) +export PLATFORMS=(${platform[@]}) + +function get_macos_arch() { + local common_arch=$1 + case ${common_arch} in + x86_64) + echo "x86-64" + ;; + esac +} + +function macos_get_build_host() { + local arch=$(get_macos_arch $1) + case ${arch} in + x86-64) + echo "x86_64-apple-darwin" + ;; + esac +} + +function set_macos_cpu_feature() { + local name=$1 + local arch=$(get_macos_arch $2) + local macos_min_target=$3 + local sysroot=$4 + case ${arch} in + x86-64) + export CC="xcrun -sdk macosx clang -arch x86_64" + export CXX="xcrun -sdk macosx clang++ -arch x86_64" + export CFLAGS="-arch x86_64 -target x86_64-apple-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fstrict-aliasing -O2 -Wno-ignored-optimization-argument -isysroot ${sysroot} -mmacosx-version-min=${macos_min_target} -I${sysroot}/usr/include" + export LDFLAGS="-arch x86_64 -target x86_64-apple-darwin -march=x86-64 -isysroot ${sysroot} -L${sysroot}/usr/lib " + export CXXFLAGS="-std=c++14 -arch x86_64 -target x86_64-apple-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -fstrict-aliasing -mmacosx-version-min=${macos_min_target} -I${sysroot}/usr/include" + ;; + *) + log_error "not support" && exit 1 + ;; + esac +} + +function macos_printf_global_params() { + local arch=$1 + local type=$2 + local platform=$3 + local in_dir=$4 + local out_dir=$5 + echo -e "arch = $arch" + echo -e "type = $type" + echo -e "platform = $platform" + echo -e "PLATFORM_TYPE = $PLATFORM_TYPE" + echo -e "MACOS_MIN_TARGET = $MACOS_MIN_TARGET" + echo -e "in_dir = $in_dir" + echo -e "out_dir = $out_dir" + echo -e "CC = $CC" + echo -e "CXX = $CXX" + echo -e "CFLAGS = $CFLAGS" + echo -e "CXXFLAGS = $CXXFLAGS" + echo -e "LDFLAGS = $LDFLAGS" +} diff --git a/tools/build-macos-curl.sh b/tools/build-macos-curl.sh new file mode 100755 index 00000000..768bbe0e --- /dev/null +++ b/tools/build-macos-curl.sh @@ -0,0 +1,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-macos-common.sh + +if [ -z ${version+x} ]; then + version="7.68.0" +fi + +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="curl-$(echo $version | sed 's/\./_/g')" +LIB_NAME="curl-$version" +LIB_DEST_DIR="${pwd_path}/../output/macos/curl-universal" + +init_log_color + +echo "https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz" + +# https://curl.haxx.se/download/${LIB_NAME}.tar.gz +# https://github.com/curl/curl/releases/download/curl-7_69_0/curl-7.69.0.tar.gz +# https://github.com/curl/curl/releases/download/curl-7_68_0/curl-7.68.0.tar.gz +DEVELOPER=$(xcode-select -print-path) +rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}" +[ -f "${LIB_NAME}.tar.gz" ] || curl -LO https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz >${LIB_NAME}.tar.gz + +function configure_make() { + + ARCH=$1 + SDK=$2 + PLATFORM=$3 + SDK_PATH=$(xcrun -sdk ${SDK} --show-sdk-path) + + log_info "configure $ARCH start..." + + if [ -d "${LIB_NAME}" ]; then + rm -fr "${LIB_NAME}" + fi + tar xfz "${LIB_NAME}.tar.gz" + pushd . + cd "${LIB_NAME}" + + PREFIX_DIR="${pwd_path}/../output/macos/curl-${ARCH}" + if [ -d "${PREFIX_DIR}" ]; then + rm -fr "${PREFIX_DIR}" + fi + mkdir -p "${PREFIX_DIR}" + + OUTPUT_ROOT=${TOOLS_ROOT}/../output/macos/curl-${ARCH} + mkdir -p ${OUTPUT_ROOT}/log + + set_macos_cpu_feature "curl" "${ARCH}" "${MACOS_MIN_TARGET}" "${SDK_PATH}" + + OPENSSL_OUT_DIR="${pwd_path}/../output/macos/openssl-${ARCH}" + NGHTTP2_OUT_DIR="${pwd_path}/../output/macos/nghttp2-${ARCH}" + + export LDFLAGS="${LDFLAGS} -L${OPENSSL_OUT_DIR}/lib -L${NGHTTP2_OUT_DIR}/lib" + + macos_printf_global_params "$ARCH" "$SDK" "$PLATFORM" "$PREFIX_DIR" "$OUTPUT_ROOT" + + if [[ "${ARCH}" == "x86_64" ]]; then + + ./Configure --host=$(macos_get_build_host "$ARCH") --prefix="${PREFIX_DIR}" --disable-shared --enable-static --enable-ipv6 --without-libidn2 --with-ssl=${OPENSSL_OUT_DIR} --with-nghttp2=${NGHTTP2_OUT_DIR} >"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1 + + else + log_error "not support" && exit 1 + fi + + log_info "make $ARCH start..." + + make clean >>"${OUTPUT_ROOT}/log/${ARCH}.log" + if make -j8 >>"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1; then + make install >>"${OUTPUT_ROOT}/log/${ARCH}.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]}" "${SDKS[i]}" "${PLATFORMS[i]}" + fi +done + +log_info "lipo start..." + +function lipo_library() { + LIB_SRC=$1 + LIB_DST=$2 + LIB_PATHS=("${ARCHS[@]/#/${pwd_path}/../output/macos/curl-}") + LIB_PATHS=("${LIB_PATHS[@]/%//lib/${LIB_SRC}}") + lipo ${LIB_PATHS[@]} -create -output "${LIB_DST}" +} +mkdir -p "${LIB_DEST_DIR}" +lipo_library "libcurl.a" "${LIB_DEST_DIR}/libcurl-universal.a" + +log_info "${PLATFORM_TYPE} ${LIB_NAME} end..." diff --git a/tools/build-macos-nghttp2.sh b/tools/build-macos-nghttp2.sh new file mode 100755 index 00000000..b82e4b43 --- /dev/null +++ b/tools/build-macos-nghttp2.sh @@ -0,0 +1,119 @@ +#!/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-macos-common.sh + +if [ -z ${version+x} ]; then + version="1.40.0" +fi + +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="v$version" +LIB_NAME="nghttp2-$version" +LIB_DEST_DIR="${pwd_path}/../output/macos/nghttp2-universal" + +init_log_color + +echo "https://github.com/nghttp2/nghttp2/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz" + +DEVELOPER=$(xcode-select -print-path) +rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}" +[ -f "${LIB_NAME}.tar.gz" ] || curl -LO https://github.com/nghttp2/nghttp2/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz >${LIB_NAME}.tar.gz + +function configure_make() { + + ARCH=$1 + SDK=$2 + PLATFORM=$3 + SDK_PATH=$(xcrun -sdk ${SDK} --show-sdk-path) + + log_info "configure $ARCH start..." + + if [ -d "${LIB_NAME}" ]; then + rm -fr "${LIB_NAME}" + fi + tar xfz "${LIB_NAME}.tar.gz" + pushd . + cd "${LIB_NAME}" + + PREFIX_DIR="${pwd_path}/../output/macos/nghttp2-${ARCH}" + if [ -d "${PREFIX_DIR}" ]; then + rm -fr "${PREFIX_DIR}" + fi + mkdir -p "${PREFIX_DIR}" + + OUTPUT_ROOT=${TOOLS_ROOT}/../output/macos/nghttp2-${ARCH} + mkdir -p ${OUTPUT_ROOT}/log + + set_macos_cpu_feature "nghttp2" "${ARCH}" "${MACOS_MIN_TARGET}" "${SDK_PATH}" + + macos_printf_global_params "$ARCH" "$SDK" "$PLATFORM" "$PREFIX_DIR" "$OUTPUT_ROOT" + + if [[ "${ARCH}" == "x86_64" ]]; then + + ./configure --host=$(macos_get_build_host "$ARCH") --prefix="${PREFIX_DIR}" --disable-shared --disable-app --disable-threads --enable-lib-only >"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1 + + else + log_error "not support" && exit 1 + fi + + log_info "make $ARCH start..." + + make clean >>"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1 + if make -j8 >>"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1; then + make install >>"${OUTPUT_ROOT}/log/${ARCH}.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]}" "${SDKS[i]}" "${PLATFORMS[i]}" + fi +done + +log_info "lipo start..." + +function lipo_library() { + LIB_SRC=$1 + LIB_DST=$2 + LIB_PATHS=("${ARCHS[@]/#/${pwd_path}/../output/macos/nghttp2-}") + LIB_PATHS=("${LIB_PATHS[@]/%//lib/${LIB_SRC}}") + lipo ${LIB_PATHS[@]} -create -output "${LIB_DST}" +} +mkdir -p "${LIB_DEST_DIR}" +lipo_library "libnghttp2.a" "${LIB_DEST_DIR}/libnghttp2-universal.a" + +log_info "${PLATFORM_TYPE} ${LIB_NAME} end..." diff --git a/tools/build-macos-openssl.sh b/tools/build-macos-openssl.sh new file mode 100755 index 00000000..24369fd4 --- /dev/null +++ b/tools/build-macos-openssl.sh @@ -0,0 +1,129 @@ +#!/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-macos-common.sh + +if [ -z ${version+x} ]; then + version="1.1.1d" +fi +echo $version + +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} + +# openssl-1.1.0f has a configure bug +# openssl-1.1.1d has fix configure bug +LIB_VERSION="OpenSSL_$(echo $version | sed 's/\./_/g')" +LIB_NAME="openssl-$version" +LIB_DEST_DIR="${pwd_path}/../output/macos/openssl-universal" + +init_log_color + +echo "https://www.openssl.org/source/${LIB_NAME}.tar.gz" + +# https://github.com/openssl/openssl/archive/OpenSSL_1_1_1d.tar.gz +# https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz +DEVELOPER=$(xcode-select -print-path) +rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}" +[ -f "${LIB_NAME}.tar.gz" ] || curl https://www.openssl.org/source/${LIB_NAME}.tar.gz >${LIB_NAME}.tar.gz + +function configure_make() { + + ARCH=$1 + SDK=$2 + PLATFORM=$3 + SDK_PATH=$(xcrun -sdk ${SDK} --show-sdk-path) + + log_info "configure $ARCH start..." + + if [ -d "${LIB_NAME}" ]; then + rm -fr "${LIB_NAME}" + fi + tar xfz "${LIB_NAME}.tar.gz" + pushd . + cd "${LIB_NAME}" + + PREFIX_DIR="${pwd_path}/../output/macos/openssl-${ARCH}" + if [ -d "${PREFIX_DIR}" ]; then + rm -fr "${PREFIX_DIR}" + fi + mkdir -p "${PREFIX_DIR}" + + OUTPUT_ROOT=${TOOLS_ROOT}/../output/macos/openssl-${ARCH} + mkdir -p ${OUTPUT_ROOT}/log + + set_macos_cpu_feature "openssl" "${ARCH}" "${MACOS_MIN_TARGET}" "${SDK_PATH}" + + macos_printf_global_params "$ARCH" "$SDK" "$PLATFORM" "$PREFIX_DIR" "$OUTPUT_ROOT" + + unset MACOSX_DEPLOYMENT_TARGET + + if [[ "${ARCH}" == "x86_64" ]]; then + + # openssl1.1.1d can be set normally, 1.1.0f does not take effect + ./Configure darwin64-x86_64-cc no-shared --prefix="${PREFIX_DIR}" + + else + log_error "not support" && exit 1 + fi + + log_info "make $ARCH start..." + + make clean >"${OUTPUT_ROOT}/log/${ARCH}.log" + if make -j8 >>"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1; then + make install_sw >>"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1 + make install_ssldirs >>"${OUTPUT_ROOT}/log/${ARCH}.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]}" "${SDKS[i]}" "${PLATFORMS[i]}" + fi +done + +log_info "lipo start..." + +function lipo_library() { + LIB_SRC=$1 + LIB_DST=$2 + LIB_PATHS=("${ARCHS[@]/#/${pwd_path}/../output/macos/openssl-}") + LIB_PATHS=("${LIB_PATHS[@]/%//lib/${LIB_SRC}}") + lipo ${LIB_PATHS[@]} -create -output "${LIB_DST}" +} +mkdir -p "${LIB_DEST_DIR}" +lipo_library "libcrypto.a" "${LIB_DEST_DIR}/libcrypto-universal.a" +lipo_library "libssl.a" "${LIB_DEST_DIR}/libssl-universal.a" + +log_info "${PLATFORM_TYPE} ${LIB_NAME} end..."