mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Refactoring build
This commit is contained in:
@ -4,6 +4,10 @@ CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/build/android/include
|
||||
CORE_BOOST_LIBS = $$PWD/build/android/lib/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
|
||||
DEFINES += "_HAS_AUTO_PTR_ETC=0"
|
||||
QMAKE_CFLAGS += -Wno-enum-constexpr-conversion
|
||||
QMAKE_CXXFLAGS += -Wno-enum-constexpr-conversion
|
||||
}
|
||||
|
||||
bundle_xcframeworks {
|
||||
|
||||
@ -1,326 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd boost_1_72_0
|
||||
OUTPUT_DIR="../build/android"
|
||||
|
||||
BOOST_LIBS="filesystem system date_time regex"
|
||||
|
||||
CPPSTD="-std=c++11 -frtti -fexceptions"
|
||||
|
||||
# Must set these after parseArgs to fill in overriden values
|
||||
# Todo: -g -DNDEBUG are for debug builds only...
|
||||
# Boost.test defines are needed to build correct instrumentable boost_unit_test_framework static lib
|
||||
# it does not affect the functionality of <boost/test/included/unit_test.hpp> single-header usage.
|
||||
# See http://www.boost.org/doc/libs/1_66_0/libs/test/doc/html/boost_test/adv_scenarios/static_lib_customizations/entry_point.html
|
||||
EXTRA_FLAGS="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS \
|
||||
-DBOOST_TEST_NO_MAIN -DBOOST_TEST_ALTERNATIVE_INIT_API -DANDROID_STL=c++_static \
|
||||
-Wno-unused-local-typedef"
|
||||
EXTRA_ANDROID_FLAGS="$EXTRA_FLAGS"
|
||||
|
||||
if [[ -n "$USE_CXX11_ABI" ]]; then
|
||||
EXTRA_LINUX_FLAGS="$EXTRA_FLAGS -D_GLIBCXX_USE_CXX11_ABI=$USE_CXX11_ABI"
|
||||
else
|
||||
EXTRA_LINUX_FLAGS="$EXTRA_FLAGS"
|
||||
fi
|
||||
|
||||
doneSection()
|
||||
{
|
||||
echo
|
||||
echo "Done"
|
||||
echo "================================================================="
|
||||
echo
|
||||
}
|
||||
|
||||
bootstrapBoost()
|
||||
{
|
||||
BOOTSTRAP_LIBS=$BOOST_LIBS
|
||||
BOOST_LIBS_COMMA=$(echo $BOOTSTRAP_LIBS | sed -e "s/ /,/g")
|
||||
echo "Bootstrapping for $1 (with libs $BOOST_LIBS_COMMA)"
|
||||
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
generateAndroidUserConfig()
|
||||
{
|
||||
HOSTOS="$(uname | awk '{ print $1}' | tr [:upper:] [:lower:])-" # darwin or linux
|
||||
OSARCH="$(uname -m)"
|
||||
|
||||
# Boost doesn't build with <compileflags>-Werror
|
||||
# Reported to boost-users@lists.boost.org
|
||||
|
||||
cat > "./tools/build/src/user-config.jam" <<EOF
|
||||
using clang : 5.0~x86
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>x86 <target-os>android
|
||||
<compileflags>--target=i686-none-linux-android
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/x86-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/i686-linux-android
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=19
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-mstackrealign
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
;
|
||||
using clang : 5.0~x86_64
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>x86 <target-os>android
|
||||
<compileflags>--target=x86_64-none-linux-android
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/x86_64-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/x86_64-linux-android
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=21
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-mstackrealign
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
;
|
||||
using clang : 5.0~arm
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>arm <target-os>android
|
||||
<compileflags>--target=armv7-none-linux-androideabi
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/arm-linux-androideabi
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=19
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-fno-integrated-as
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
<compileflags>-march=armv7-a
|
||||
<compileflags>-mfloat-abi=softfp
|
||||
<compileflags>-mfpu=vfpv3-d16
|
||||
<compileflags>-mthumb
|
||||
;
|
||||
using clang : 5.0~arm64
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>arm <target-os>android
|
||||
<compileflags>--target=aarch64-none-linux-android
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/aarch64-linux-android-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/aarch64-linux-android
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=21
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
;
|
||||
EOF
|
||||
}
|
||||
|
||||
buildBoost_Android()
|
||||
{
|
||||
mkdir -p $OUTPUT_DIR
|
||||
echo > ${OUTPUT_DIR}/android-build.log
|
||||
|
||||
if [[ -z "$ANDROID_NDK_ROOT" ]]; then
|
||||
echo "Must specify ANDROID_NDK_ROOT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NO_BZIP2=1
|
||||
|
||||
# build libicu if locale requested but not provided
|
||||
# if echo $LIBRARIES | grep locale; then
|
||||
# if [ -e libiconv-libicu-android ]; then
|
||||
# echo "ICONV and ICU already compiled"
|
||||
# else
|
||||
# echo "boost_locale selected - compiling ICONV and ICU"
|
||||
# git clone https://github.com/pelya/libiconv-libicu-android.git
|
||||
# cd libiconv-libicu-android
|
||||
# ./build.sh || exit 1
|
||||
# cd ..
|
||||
# fi
|
||||
# fi
|
||||
|
||||
echo clean
|
||||
./b2 --clean
|
||||
|
||||
echo Building release x86 Boost for Android Emulator
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/x86" toolset=clang-5.0~x86 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=32 variant=release cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building release x86_64 Boost for Android Emulator
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/x86_64" toolset=clang-5.0~x86_64 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=64 variant=release cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building release armv7 Boost for Android
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/armeabi-v7a" toolset=clang-5.0~arm \
|
||||
abi=aapcs architecture=arm address-model=32 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=release cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building release arm64 Boost for Android
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/arm64-v8a" toolset=clang-5.0~arm64 \
|
||||
abi=aapcs architecture=arm address-model=64 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=release cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
buildBoost_Android_debug()
|
||||
{
|
||||
mkdir -p $OUTPUT_DIR
|
||||
echo > ${OUTPUT_DIR}/android-build.log
|
||||
|
||||
export NO_BZIP2=1
|
||||
|
||||
# build libicu if locale requested but not provided
|
||||
# if echo $LIBRARIES | grep locale; then
|
||||
# if [ -e libiconv-libicu-android ]; then
|
||||
# echo "ICONV and ICU already compiled"
|
||||
# else
|
||||
# echo "boost_locale selected - compiling ICONV and ICU"
|
||||
# git clone https://github.com/pelya/libiconv-libicu-android.git
|
||||
# cd libiconv-libicu-android
|
||||
# ./build.sh || exit 1
|
||||
# cd ..
|
||||
# fi
|
||||
# fi
|
||||
|
||||
echo Building debug x86 Boost for Android Emulator
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/x86" toolset=clang-5.0~x86 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=32 variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building debug x86_64 Boost for Android Emulator
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/x86_64" toolset=clang-5.0~x86_64 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=64 variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building debug armv7 Boost for Android
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/armeabi-v7a" toolset=clang-5.0~arm \
|
||||
abi=aapcs architecture=arm address-model=32 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building debug arm64 Boost for Android
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/arm64-v8a" toolset=clang-5.0~arm64 \
|
||||
abi=aapcs architecture=arm address-model=64 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
bootstrapBoost
|
||||
generateAndroidUserConfig
|
||||
buildBoost_Android
|
||||
#buildBoost_Android_debug
|
||||
|
||||
echo "Completed successfully"
|
||||
@ -1,220 +0,0 @@
|
||||
#!/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
|
||||
|
||||
export PLATFORM_TYPE="Android"
|
||||
export ARCHS=("arm" "arm64" "x86" "x86_64")
|
||||
export ABIS=("armeabi-v7a" "arm64-v8a" "x86" "x86_64")
|
||||
export ABI_TRIPLES=("arm-linux-androideabi" "aarch64-linux-android" "i686-linux-android" "x86_64-linux-android")
|
||||
export ANDROID_API=21
|
||||
|
||||
# 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"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function get_toolchain() {
|
||||
HOST_OS=$(uname -s)
|
||||
case ${HOST_OS} in
|
||||
Darwin) HOST_OS=darwin ;;
|
||||
Linux) HOST_OS=linux ;;
|
||||
FreeBsd) HOST_OS=freebsd ;;
|
||||
CYGWIN* | *_NT-*) HOST_OS=cygwin ;;
|
||||
esac
|
||||
|
||||
HOST_ARCH=$(uname -m)
|
||||
case ${HOST_ARCH} in
|
||||
i?86) HOST_ARCH=x86 ;;
|
||||
x86_64 | amd64) HOST_ARCH=x86_64 ;;
|
||||
esac
|
||||
|
||||
echo "${HOST_OS}-${HOST_ARCH}"
|
||||
}
|
||||
|
||||
function get_android_arch() {
|
||||
local common_arch=$1
|
||||
case ${common_arch} in
|
||||
arm)
|
||||
echo "arm-v7a"
|
||||
;;
|
||||
arm64)
|
||||
echo "arm64-v8a"
|
||||
;;
|
||||
x86)
|
||||
echo "x86"
|
||||
;;
|
||||
x86_64)
|
||||
echo "x86-64"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function get_target_build() {
|
||||
local arch=$1
|
||||
case ${arch} in
|
||||
arm-v7a)
|
||||
echo "arm"
|
||||
;;
|
||||
arm64-v8a)
|
||||
echo "arm64"
|
||||
;;
|
||||
x86)
|
||||
echo "x86"
|
||||
;;
|
||||
x86-64)
|
||||
echo "x86_64"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function get_build_host_internal() {
|
||||
local arch=$1
|
||||
case ${arch} in
|
||||
arm-v7a | arm-v7a-neon)
|
||||
echo "arm-linux-androideabi"
|
||||
;;
|
||||
arm64-v8a)
|
||||
echo "aarch64-linux-android"
|
||||
;;
|
||||
x86)
|
||||
echo "i686-linux-android"
|
||||
;;
|
||||
x86-64)
|
||||
echo "x86_64-linux-android"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function android_get_build_host() {
|
||||
local arch=$(get_android_arch $1)
|
||||
get_build_host_internal $arch
|
||||
}
|
||||
|
||||
function get_clang_target_host() {
|
||||
local arch=$1
|
||||
local api=$2
|
||||
case ${arch} in
|
||||
arm-v7a | arm-v7a-neon)
|
||||
echo "armv7a-linux-androideabi${api}"
|
||||
;;
|
||||
arm64-v8a)
|
||||
echo "aarch64-linux-android${api}"
|
||||
;;
|
||||
x86)
|
||||
echo "i686-linux-android${api}"
|
||||
;;
|
||||
x86-64)
|
||||
echo "x86_64-linux-android${api}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function set_android_toolchain_bin() {
|
||||
export PATH=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/$(get_toolchain)/bin:$PATH
|
||||
echo PATH=$PATH
|
||||
}
|
||||
|
||||
function set_android_toolchain() {
|
||||
local name=$1
|
||||
local arch=$(get_android_arch $2)
|
||||
local api=$3
|
||||
local build_host=$(get_build_host_internal "$arch")
|
||||
local clang_target_host=$(get_clang_target_host "$arch" "$api")
|
||||
|
||||
export AR=${build_host}-ar
|
||||
export CC=${clang_target_host}-clang
|
||||
export CXX=${clang_target_host}-clang++
|
||||
export AS=${build_host}-as
|
||||
export LD=${build_host}-ld
|
||||
export RANLIB=${build_host}-ranlib
|
||||
export STRIP=${build_host}-strip
|
||||
}
|
||||
|
||||
function get_common_includes() {
|
||||
local toolchain=$(get_toolchain)
|
||||
echo "-I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/include -I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/local/include"
|
||||
}
|
||||
function get_common_linked_libraries() {
|
||||
local api=$1
|
||||
local arch=$2
|
||||
local toolchain=$(get_toolchain)
|
||||
local build_host=$(get_build_host_internal "$arch")
|
||||
echo "-L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/${build_host}/lib -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/lib/${build_host}/${api} -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/lib"
|
||||
}
|
||||
|
||||
function set_android_cpu_feature() {
|
||||
local name=$1
|
||||
local arch=$(get_android_arch $2)
|
||||
local api=$3
|
||||
case ${arch} in
|
||||
arm-v7a | arm-v7a-neon)
|
||||
export CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
arm64-v8a)
|
||||
export CFLAGS="-march=armv8-a -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=armv8-a -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
x86)
|
||||
export CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=i686 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
x86-64)
|
||||
export CFLAGS="-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=x86-64 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function android_printf_global_params() {
|
||||
local arch=$1
|
||||
local abi=$2
|
||||
local abi_triple=$3
|
||||
local in_dir=$4
|
||||
local out_dir=$5
|
||||
echo -e "arch = $arch"
|
||||
echo -e "abi = $abi"
|
||||
echo -e "abi_triple = $abi_triple"
|
||||
echo -e "PLATFORM_TYPE = $PLATFORM_TYPE"
|
||||
echo -e "ANDROID_API = $ANDROID_API"
|
||||
echo -e "in_dir = $in_dir"
|
||||
echo -e "out_dir = $out_dir"
|
||||
echo -e "AR = $AR"
|
||||
echo -e "CC = $CC"
|
||||
echo -e "CXX = $CXX"
|
||||
echo -e "AS = $AS"
|
||||
echo -e "LD = $LD"
|
||||
echo -e "RANLIB = $RANLIB"
|
||||
echo -e "STRIP = $STRIP"
|
||||
echo -e "CFLAGS = $CFLAGS"
|
||||
echo -e "CXXFLAGS = $CXXFLAGS"
|
||||
echo -e "LDFLAGS = $LDFLAGS"
|
||||
echo -e "CPPFLAGS = $CPPFLAGS"
|
||||
}
|
||||
@ -1,128 +0,0 @@
|
||||
#!/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="curl-7_68_0"
|
||||
LIB_NAME="curl-7.68.0"
|
||||
LIB_DEST_DIR="${pwd_path}/build/android/curl-universal"
|
||||
|
||||
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
|
||||
rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}"
|
||||
[ -f "${LIB_NAME}.tar.gz" ] || curl -L -o ${LIB_NAME}.tar.gz https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz -s
|
||||
[ -f "${LIB_NAME}.tar.gz" ] || log_error "curl download error!"
|
||||
|
||||
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}"
|
||||
|
||||
PREFIX_DIR="${pwd_path}/build/android/${ABI}"
|
||||
if [ -d "${PREFIX_DIR}" ]; then
|
||||
rm -fr "${PREFIX_DIR}"
|
||||
fi
|
||||
mkdir -p "${PREFIX_DIR}"
|
||||
|
||||
OUTPUT_ROOT=${TOOLS_ROOT}/build/android/${ABI}
|
||||
mkdir -p ${OUTPUT_ROOT}/log
|
||||
|
||||
set_android_toolchain "curl" "${ARCH}" "${ANDROID_API}"
|
||||
set_android_cpu_feature "curl" "${ARCH}" "${ANDROID_API}"
|
||||
|
||||
export ANDROID_NDK_HOME=${ANDROID_NDK_ROOT}
|
||||
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME}
|
||||
|
||||
OPENSSL_OUT_DIR="${pwd_path}/../openssl/build/android/${ABI}"
|
||||
|
||||
export LDFLAGS="${LDFLAGS} -L${OPENSSL_OUT_DIR}/lib"
|
||||
# export LDFLAGS="-Wl,-rpath-link,-L${OPENSSL_OUT_DIR}/lib $LDFLAGS "
|
||||
|
||||
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}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
elif [[ "${ARCH}" == "x86" ]]; then
|
||||
|
||||
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
elif [[ "${ARCH}" == "arm" ]]; then
|
||||
|
||||
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
elif [[ "${ARCH}" == "arm64" ]]; then
|
||||
|
||||
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
else
|
||||
log_error "not support" && exit 1
|
||||
fi
|
||||
|
||||
log_info "make $ABI start..."
|
||||
|
||||
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]}" "${ABI_TRIPLES[i]}"
|
||||
fi
|
||||
done
|
||||
|
||||
log_info "${PLATFORM_TYPE} ${LIB_NAME} end..."
|
||||
@ -1,18 +1,10 @@
|
||||
core_android {
|
||||
|
||||
ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
contains(ABI_PATH, "armv7" ) {
|
||||
ABI_PATH = $$replace(ABI_PATH, "armv7", "armeabi-v7a")
|
||||
}
|
||||
contains(ABI_PATH, "arm64_v8a" ) {
|
||||
ABI_PATH = $$replace(ABI_PATH, "arm64_v8a", "arm64-v8a")
|
||||
}
|
||||
INCLUDEPATH += \
|
||||
$$PWD/build/android/$$ABI_PATH/include \
|
||||
$$PWD/../openssl/build/android/$$ABI_PATH/include \
|
||||
$$PWD/build/android/include \
|
||||
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/include
|
||||
|
||||
LIBS += \
|
||||
$$PWD/build/android/$$ABI_PATH/lib/libcurl.a \
|
||||
$$PWD/../openssl/build/android/$$ABI_PATH/lib/libssl.a \
|
||||
$$PWD/../openssl/build/android/$$ABI_PATH/lib/libcrypto.a \
|
||||
$$PWD/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libcurl.a \
|
||||
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/lib/libssl.a \
|
||||
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/lib/libcrypto.a \
|
||||
}
|
||||
|
||||
@ -43,8 +43,7 @@ core_ios {
|
||||
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/android/build/include
|
||||
ICU_LIBS_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
|
||||
LIBS += $$PWD/android/build/$$ICU_LIBS_PATH/libicuuc.a
|
||||
LIBS += $$PWD/android/build/$$ICU_LIBS_PATH/libicudata.a
|
||||
LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicuuc.a
|
||||
LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicudata.a
|
||||
}
|
||||
|
||||
@ -11,16 +11,7 @@ open_ssl_common {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/$$OPEN_SSL_PLATFORM/lib
|
||||
|
||||
core_android {
|
||||
|
||||
OPENSSL_ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
contains(OPENSSL_ABI_PATH, "armv7" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "armv7", "armeabi-v7a")
|
||||
}
|
||||
contains(OPENSSL_ABI_PATH, "arm64_v8a" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "arm64_v8a", "arm64-v8a")
|
||||
}
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/android/$$OPENSSL_ABI_PATH/lib
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/lib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
@ -123,7 +123,7 @@ def get_android_args(platform, sdk_ver=21):
|
||||
"v8_static_library=true",
|
||||
"v8_monolithic=true",
|
||||
"use_custom_libcxx=false",
|
||||
"android_ndk_version=\\\"21.1.6352462\\\"",
|
||||
"android_ndk_version=\\\"26.2.11394342\\\"",
|
||||
"android_sdk_version=\\\"" + str(sdk_ver) + "\\\"",
|
||||
"clang_use_chrome_plugins=false",
|
||||
"v8_use_external_startup_data=false",
|
||||
|
||||
@ -30,6 +30,8 @@ core_android {
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_armv7): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/armeabi-v7a
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/x86
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86_64): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/x86_64
|
||||
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
|
||||
@ -19,6 +19,11 @@ isEmpty(PUBLISHER_NAME){
|
||||
PUBLISHER_NAME = $$cat(copyright.txt)
|
||||
}
|
||||
|
||||
DEST_MAKEFILE_NAME = $$(DEST_MAKEFILE_NAME)
|
||||
!isEmpty(DEST_MAKEFILE_NAME){
|
||||
MAKEFILE = $${DEST_MAKEFILE_NAME}
|
||||
}
|
||||
|
||||
APPLICATION_NAME_DEFAULT = $$(APPLICATION_NAME_DEFAULT)
|
||||
!isEmpty(APPLICATION_NAME_DEFAULT){
|
||||
DEFINES += "APPLICATION_NAME_DEFAULT=$${APPLICATION_NAME_DEFAULT}"
|
||||
@ -366,6 +371,7 @@ core_android {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "-", "_")
|
||||
CORE_BUILDS_PLATFORM_PREFIX = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "armeabi_v7", "armv7")
|
||||
CORE_BUILDS_PLATFORM_PREFIX = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "armv7a", "armv7")
|
||||
CORE_BUILDS_PLATFORM_PREFIX_DST = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
|
||||
!isEmpty(OO_DESTDIR_BUILD_OVERRIDE) {
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_arm64_v8a):OO_DESTDIR_BUILD_OVERRIDE=$$OO_DESTDIR_BUILD_OVERRIDE/arm64-v8a
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <unistd.h>
|
||||
#if __ANDROID_API__ < 28
|
||||
#if __ANDROID_API__ < 22
|
||||
static void swab(const char* __src, char* __dst, ssize_t __byte_count)
|
||||
{
|
||||
ssize_t len = __byte_count;
|
||||
|
||||
@ -52,26 +52,33 @@
|
||||
v8::Local<v8::String> CreateV8String(v8::Isolate* i, const char* str, const int& len = -1);
|
||||
v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
|
||||
|
||||
#define ANDROID_LOGS
|
||||
#ifdef ANDROID_LOGS
|
||||
#include <JniLogUtils.h>
|
||||
//#define ANDROID_LOGS_ALL_FUNCTIONS
|
||||
#include <android/log.h>
|
||||
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "js", __VA_ARGS__)
|
||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "js", __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifdef V8_OS_XP
|
||||
#if 1
|
||||
class MallocArrayBufferAllocator : public v8::ArrayBuffer::Allocator
|
||||
{
|
||||
public:
|
||||
virtual void* Allocate(size_t length)
|
||||
{
|
||||
LOGW("allocate: %d\n", (int)length);
|
||||
void* ret = malloc(length);
|
||||
memset(ret, 0, length);
|
||||
return ret;
|
||||
}
|
||||
virtual void* AllocateUninitialized(size_t length)
|
||||
{
|
||||
LOGW("allocate_uninitialized: %d\n", (int)length);
|
||||
return malloc(length);
|
||||
}
|
||||
virtual void Free(void* data, size_t length)
|
||||
{
|
||||
LOGW("free: %d\n", (int)length);
|
||||
free(data);
|
||||
}
|
||||
};
|
||||
@ -114,7 +121,9 @@ public:
|
||||
v8::V8::InitializeICUDefaultLocation(sPrA.c_str());
|
||||
v8::V8::InitializeExternalStartupData(sPrA.c_str());
|
||||
#ifdef V8_VERSION_89_PLUS
|
||||
m_platform = v8::platform::NewDefaultPlatform();
|
||||
//m_platform = v8::platform::NewDefaultPlatform();
|
||||
v8::V8::SetFlagsFromString("--single-threaded");
|
||||
m_platform = v8::platform::NewSingleThreadedDefaultPlatform();
|
||||
v8::V8::InitializePlatform(m_platform.get());
|
||||
#else
|
||||
m_platform = v8::platform::CreateDefaultPlatform();
|
||||
@ -481,9 +490,15 @@ namespace NSJSBase
|
||||
CInspectorPool::get().getInspector(V8IsolateOneArg).startAgent(false);
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID_LOGS_ALL_FUNCTIONS
|
||||
std::string sFuncName(name);
|
||||
std::string sFunc = "[JS call_func: " + sFuncName + "]";
|
||||
LOGW(sFunc.c_str());
|
||||
#endif
|
||||
|
||||
LOGGER_START
|
||||
|
||||
v8::Local<v8::String> _name = CreateV8String(CV8Worker::GetCurrent(), name);
|
||||
v8::Local<v8::String> _name = CreateV8String(CV8Worker::GetCurrent(), name);
|
||||
v8::Handle<v8::Value> _func = value->Get(V8ContextFirstArg _name).ToLocalChecked();
|
||||
|
||||
CJSValueV8* _return = new CJSValueV8();
|
||||
@ -514,7 +529,12 @@ namespace NSJSBase
|
||||
|
||||
LOGGER_LAP_NAME(name)
|
||||
|
||||
JSSmart<CJSValue> _ret = _return;
|
||||
#ifdef ANDROID_LOGS_ALL_FUNCTIONS
|
||||
sFunc = "[JS call_func_end: " + sFuncName + "]";
|
||||
LOGW(sFunc.c_str());
|
||||
#endif
|
||||
|
||||
JSSmart<CJSValue> _ret = _return;
|
||||
return _ret;
|
||||
}
|
||||
|
||||
@ -804,10 +824,8 @@ namespace NSJSBase
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID_LOGS
|
||||
LOGE("NSJSBase::CV8TryCatch::Check() - error:");
|
||||
LOGE(std::to_string(nLineNumber).c_str());
|
||||
LOGE(strCode.c_str());
|
||||
LOGE(strException.c_str());
|
||||
std::string sLog = "[JS (" + std::to_string(nLineNumber) + ")]: " + strCode + ", " + strException;
|
||||
LOGE(sLog.c_str());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -39,8 +39,8 @@
|
||||
|
||||
namespace NSTimers
|
||||
{
|
||||
// CLOCK_MONOTONIC defined ONLY since macOS 10.12!!! (crash on earlier version)
|
||||
DWORD GetTickCount()
|
||||
// CLOCK_MONOTONIC defined ONLY since macOS 10.12!!! (crash on earlier version)
|
||||
DWORD GetTickCount()
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
|
||||
return ::GetTickCount();
|
||||
@ -49,55 +49,55 @@ namespace NSTimers
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
return (ts.tv_sec * 1000 + (DWORD)(ts.tv_nsec / 1000000));
|
||||
return (ts.tv_sec * 1000 + (DWORD)(ts.tv_nsec / 1000000));
|
||||
#else
|
||||
//uint64_t nano = mach_absolute_time();
|
||||
//return nano / 1000000;
|
||||
return getUptimeInMilliseconds();
|
||||
//uint64_t nano = mach_absolute_time();
|
||||
//return nano / 1000000;
|
||||
return getUptimeInMilliseconds();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
CTimer::CTimer() : NSThreads::CBaseThread()
|
||||
{
|
||||
m_dwInterval = 40;
|
||||
m_bIsCOMNeed = FALSE;
|
||||
}
|
||||
CTimer::~CTimer()
|
||||
{
|
||||
}
|
||||
CTimer::CTimer() : NSThreads::CBaseThread()
|
||||
{
|
||||
m_dwInterval = 40;
|
||||
m_bIsCOMNeed = FALSE;
|
||||
}
|
||||
CTimer::~CTimer()
|
||||
{
|
||||
}
|
||||
|
||||
void CTimer::SetInterval(const DWORD& dwInterval) { m_dwInterval = dwInterval; }
|
||||
void CTimer::SetCOMNeed(const INT& bIsCOM) { m_bIsCOMNeed = bIsCOM; }
|
||||
void CTimer::SetInterval(const DWORD& dwInterval) { m_dwInterval = dwInterval; }
|
||||
void CTimer::SetCOMNeed(const INT& bIsCOM) { m_bIsCOMNeed = bIsCOM; }
|
||||
|
||||
DWORD CTimer::ThreadProc()
|
||||
{
|
||||
DWORD CTimer::ThreadProc()
|
||||
{
|
||||
#ifdef _CAN_USE_COM_THREADS
|
||||
if (m_bIsCOMNeed)
|
||||
CoInitialize(NULL);
|
||||
if (m_bIsCOMNeed)
|
||||
CoInitialize(NULL);
|
||||
#endif
|
||||
DWORD m_startTime, m_curTime;
|
||||
m_startTime = NSTimers::GetTickCount();
|
||||
DWORD m_startTime, m_curTime;
|
||||
m_startTime = NSTimers::GetTickCount();
|
||||
|
||||
while (m_bRunThread)
|
||||
{
|
||||
m_curTime = NSTimers::GetTickCount();
|
||||
while (m_curTime - m_startTime < m_dwInterval)
|
||||
{
|
||||
NSThreads::Sleep(10);
|
||||
if (!m_bRunThread)
|
||||
break;
|
||||
m_curTime = NSTimers::GetTickCount();
|
||||
}
|
||||
while (m_bRunThread)
|
||||
{
|
||||
m_curTime = NSTimers::GetTickCount();
|
||||
while (m_curTime - m_startTime < m_dwInterval)
|
||||
{
|
||||
NSThreads::Sleep(10);
|
||||
if (!m_bRunThread)
|
||||
break;
|
||||
m_curTime = NSTimers::GetTickCount();
|
||||
}
|
||||
|
||||
m_startTime = NSTimers::GetTickCount();
|
||||
OnTimer();
|
||||
}
|
||||
m_startTime = NSTimers::GetTickCount();
|
||||
OnTimer();
|
||||
}
|
||||
|
||||
#ifdef _CAN_USE_COM_THREADS
|
||||
if (m_bIsCOMNeed)
|
||||
CoUninitialize();
|
||||
if (m_bIsCOMNeed)
|
||||
CoUninitialize();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,51 +41,51 @@
|
||||
|
||||
namespace NSTimers
|
||||
{
|
||||
KERNEL_DECL DWORD GetTickCount();
|
||||
KERNEL_DECL DWORD GetTickCount();
|
||||
|
||||
class KERNEL_DECL CTimer : public NSThreads::CBaseThread
|
||||
class KERNEL_DECL CTimer : public NSThreads::CBaseThread
|
||||
{
|
||||
private:
|
||||
DWORD m_dwInterval;
|
||||
INT m_bIsCOMNeed;
|
||||
INT m_bIsCOMNeed;
|
||||
|
||||
public:
|
||||
CTimer();
|
||||
virtual ~CTimer();
|
||||
CTimer();
|
||||
virtual ~CTimer();
|
||||
|
||||
void SetInterval(const DWORD& dwInterval);
|
||||
void SetCOMNeed(const INT& bIsCOM);
|
||||
void SetInterval(const DWORD& dwInterval);
|
||||
void SetCOMNeed(const INT& bIsCOM);
|
||||
|
||||
protected:
|
||||
virtual DWORD ThreadProc();
|
||||
virtual DWORD ThreadProc();
|
||||
|
||||
virtual void OnTimer() = 0;
|
||||
};
|
||||
|
||||
inline static unsigned long getUptimeInMilliseconds()
|
||||
{
|
||||
|
||||
inline static unsigned long getUptimeInMilliseconds()
|
||||
{
|
||||
#if defined(_IOS) || defined(_MAC)
|
||||
const int64_t kOneMillion = 1000 * 1000;
|
||||
static mach_timebase_info_data_t s_timebase_info;
|
||||
|
||||
if (s_timebase_info.denom == 0) {
|
||||
(void) mach_timebase_info(&s_timebase_info);
|
||||
}
|
||||
|
||||
// mach_absolute_time() returns billionth of seconds,
|
||||
// so divide by one million to get milliseconds
|
||||
return (unsigned long)((mach_absolute_time() * s_timebase_info.numer) / (kOneMillion * s_timebase_info.denom));
|
||||
const int64_t kOneMillion = 1000 * 1000;
|
||||
static mach_timebase_info_data_t s_timebase_info;
|
||||
|
||||
if (s_timebase_info.denom == 0) {
|
||||
(void) mach_timebase_info(&s_timebase_info);
|
||||
}
|
||||
|
||||
// mach_absolute_time() returns billionth of seconds,
|
||||
// so divide by one million to get milliseconds
|
||||
return (unsigned long)((mach_absolute_time() * s_timebase_info.numer) / (kOneMillion * s_timebase_info.denom));
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __ANDROID__
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
return (ts.tv_sec * 1000 + (DWORD)(ts.tv_nsec / 1000000));
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
return (ts.tv_sec * 1000 + (DWORD)(ts.tv_nsec / 1000000));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -28,6 +28,10 @@ core_windows {
|
||||
LIBS += -lUser32
|
||||
}
|
||||
|
||||
core_android {
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/include \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jpeg \
|
||||
|
||||
Reference in New Issue
Block a user