diff options
-rw-r--r-- | SConstruct | 4 | ||||
-rwxr-xr-x | buildscripts/runandroidsim.sh | 10 | ||||
-rwxr-xr-x | buildscripts/setup-android-toolchain.sh | 40 | ||||
-rw-r--r-- | etc/evergreen.yml | 81 | ||||
-rw-r--r-- | etc/scons/android_toolchain.vars | 1 | ||||
-rw-r--r-- | src/mongo/util/errno_util.cpp | 2 | ||||
-rw-r--r-- | src/third_party/boost-1.60.0/libs/filesystem/src/operations.cpp | 7 |
7 files changed, 71 insertions, 74 deletions
diff --git a/SConstruct b/SConstruct index 087bcba6d69..c26cdfd1429 100644 --- a/SConstruct +++ b/SConstruct @@ -2468,8 +2468,10 @@ def doConfigure(myenv): # On 32-bit systems, we need to define this in order to get access to # the 64-bit versions of fseek, etc. + # except on 32 bit android where it breaks boost if not conf.CheckTypeSize('off_t', includes="#include <sys/types.h>", expect=8): - myenv.Append(CPPDEFINES=["_FILE_OFFSET_BITS=64"]) + if not env.TargetOSIs('android'): + myenv.Append(CPPDEFINES=["_FILE_OFFSET_BITS=64"]) conf.Finish() diff --git a/buildscripts/runandroidsim.sh b/buildscripts/runandroidsim.sh index 458cd93c2f8..1efb9e2aabd 100755 --- a/buildscripts/runandroidsim.sh +++ b/buildscripts/runandroidsim.sh @@ -1,8 +1,8 @@ #!/bin/sh -if [ "$#" -lt "4" ]; then +if [ "$#" -lt "5" ]; then echo "usage:" - echo "$0 <android-sdk-path> <sysarch> <directory> <test-path-in-directory>" + echo "$0 <android-sdk-path> <sysarch> <image-api-version> <directory> <test-path-in-directory>" exit 1 fi @@ -13,6 +13,8 @@ ANDROID_SDK=$1 shift ANDROID_SYSTEM_IMAGE_ARCH=$1 shift +ANDROID_IMAGE_API_VERSION=$1 +shift DIRECTORY=$1 shift TEST_PATH_IN_DIRECTORY=$1 @@ -40,12 +42,12 @@ cleanup() { } echo "Creating Android virtual device" -echo no | $ANDROID_SDK/tools/bin/avdmanager create avd --force -k "system-images;android-24;google_apis;$ANDROID_SYSTEM_IMAGE_ARCH" --name android_avd --abi google_apis/$ANDROID_SYSTEM_IMAGE_ARCH -p android_avd +echo no | $ANDROID_SDK/tools/bin/avdmanager create avd --force -k "system-images;android-$ANDROID_IMAGE_API_VERSION;google_apis;$ANDROID_SYSTEM_IMAGE_ARCH" --name android_avd --abi google_apis/$ANDROID_SYSTEM_IMAGE_ARCH -p android_avd trap 'cleanup $?' INT TERM EXIT echo "Starting the virtual device on the emulator" -$ANDROID_SDK/emulator/emulator @android_avd -no-window -no-audio & +$ANDROID_SDK/emulator/emulator @android_avd -no-window -no-audio -no-accel & EMULATOR_PID=$! echo "Waiting for the adb service to be ready for commands" diff --git a/buildscripts/setup-android-toolchain.sh b/buildscripts/setup-android-toolchain.sh index 4557aa693b2..1a3b73c5d8a 100755 --- a/buildscripts/setup-android-toolchain.sh +++ b/buildscripts/setup-android-toolchain.sh @@ -3,9 +3,9 @@ set -o verbose set -o errexit -_SystemImageArch=$1 +ToolchainArch=$1 shift -_ToolchainArch=$1 +API_VERSION=$1 shift if [ -z "$PYTHON" ] ; then @@ -13,22 +13,30 @@ if [ -z "$PYTHON" ] ; then fi SDK_ROOT=$PWD/android_sdk -mkdir $SDK_ROOT - -TOOLCHAIN=$PWD/android_toolchain -mkdir $TOOLCHAIN - -API_VERSION=24 +if [ ! -e $SDK_ROOT ]; then + mkdir $SDK_ROOT + ( + cd $SDK_ROOT + SDK_PACKAGE=sdk-tools-linux-3859397.zip + curl -O https://dl.google.com/android/repository/$SDK_PACKAGE + unzip $SDK_PACKAGE + echo y | ./tools/bin/sdkmanager \ + "platforms;android-27" \ + "ndk-bundle" \ + "emulator" \ + "patcher;v4" \ + "platform-tools" \ + "build-tools;23.0.3" \ + "system-images;android-25;google_apis;armeabi-v7a" \ + "system-images;android-25;google_apis;arm64-v8a" \ + "system-images;android-21;google_apis;x86_64" + ) +fi -( - cd $SDK_ROOT - SDK_PACKAGE=sdk-tools-linux-3859397.zip - curl -O https://dl.google.com/android/repository/$SDK_PACKAGE - unzip $SDK_PACKAGE - echo y | ./tools/bin/sdkmanager "platforms;android-24" "emulator" "ndk-bundle" "platform-tools" "build-tools;23.0.3" "system-images;android-24;google_apis;$_SystemImageArch" -) +TOOLCHAIN=$PWD/android_toolchain-${ToolchainArch}-${API_VERSION} +rm -rf $TOOLCHAIN -$PYTHON $SDK_ROOT/ndk-bundle/build/tools/make_standalone_toolchain.py --arch $_ToolchainArch --api $API_VERSION --stl=libc++ --force --install-dir $TOOLCHAIN +$PYTHON $SDK_ROOT/ndk-bundle/build/tools/make_standalone_toolchain.py --arch $ToolchainArch --api $API_VERSION --stl=libc++ --install-dir $TOOLCHAIN echo SDK_ROOT=${SDK_ROOT} echo TOOLCHAIN=${TOOLCHAIN} diff --git a/etc/evergreen.yml b/etc/evergreen.yml index c8ac28bd85e..31acc222626 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -1023,7 +1023,7 @@ functions: set -o verbose if [ "${setup_android_toolchain|}" = "true" ]; then ${activate_virtualenv} - PYTHON=$python ${compile_env|} src/buildscripts/setup-android-toolchain.sh ${android_toolchain_system_image_arch} ${android_toolchain_target_arch} + PYTHON=$python ${compile_env|} src/buildscripts/setup-android-toolchain.sh ${android_toolchain_target_arch} ${android_toolchain_api_version} fi "scons cache pruning" : @@ -1455,6 +1455,8 @@ functions: exit_status=$? # If compile fails we do not run any tests if [ $exit_status -ne 0 ]; then + echo "Dumping build/scons/config.log" + cat build/scons/config.log touch ${skip_tests} fi exit $exit_status @@ -1733,10 +1735,10 @@ functions: ${compile_env|} buildscripts/runiossim.sh ${ios_sim_device} ${ios_sim_runtime} "build/mongo-embedded-sdk-${version}/bin/mongo_embedded_mongoc_client_test" --tempPath /data elif [ ${enable_embedded_tests|false} = "android_emulator" ]; then # strip because the binaries with debug symbols are too big for the default storage on the emulator - find build/mongo-embedded-sdk-${version}/bin -type f | xargs $(dirname $(pwd))/android_toolchain/bin/*-linux-android*-strip - find build/mongo-embedded-sdk-${version}/lib -type f -name "*.so" | xargs $(dirname $(pwd))/android_toolchain/bin/*-linux-android*-strip - ${compile_env|} buildscripts/runandroidsim.sh $(dirname $(pwd))/android_sdk ${android_toolchain_system_image_arch} "build/mongo-embedded-sdk-${version}" "bin/mongo_embedded_capi_test" --tempPath /data - ${compile_env|} buildscripts/runandroidsim.sh $(dirname $(pwd))/android_sdk ${android_toolchain_system_image_arch} "build/mongo-embedded-sdk-${version}" "bin/mongo_embedded_mongoc_client_test" --tempPath /data + find build/mongo-embedded-sdk-${version}/bin -type f | xargs $(dirname $(pwd))/android_toolchain-${android_toolchain_target_arch}-${android_toolchain_api_version}/bin/*-linux-android*-strip + find build/mongo-embedded-sdk-${version}/lib -type f -name "*.so" | xargs $(dirname $(pwd))/android_toolchain-${android_toolchain_target_arch}-${android_toolchain_api_version}/bin/*-linux-android*-strip + ${compile_env|} buildscripts/runandroidsim.sh $(dirname $(pwd))/android_sdk ${android_toolchain_system_image_arch} ${android_system_image_version} "build/mongo-embedded-sdk-${version}" "bin/mongo_embedded_capi_test" --tempPath /data + ${compile_env|} buildscripts/runandroidsim.sh $(dirname $(pwd))/android_sdk ${android_toolchain_system_image_arch} ${android_system_image_version} "build/mongo-embedded-sdk-${version}" "bin/mongo_embedded_mongoc_client_test" --tempPath /data elif [ ${enable_embedded_tests|false} = "native" ]; then "build/mongo-embedded-sdk-${version}/bin/mongo_embedded_capi_test" "build/mongo-embedded-sdk-${version}/bin/mongo_embedded_mongoc_client_test" @@ -3371,6 +3373,11 @@ tasks: --js-engine=none --link-model=dynamic --prefix='$BUILD_ROOT/mongo-embedded-sdk-$MONGO_VERSION' + --dbg=off + --opt=size + --enable-free-mon=off + --use-system-mongo-c=on + --wiredtiger=off CPPPATH='$BUILD_ROOT/mongo-embedded-sdk-$MONGO_VERSION/include/libbson-1.0 $BUILD_ROOT/mongo-embedded-sdk-$MONGO_VERSION/include/libmongoc-1.0' # Need to sign artifacts on iOS-ish. @@ -9350,11 +9357,7 @@ buildvariants: compile_env: DEVELOPER_DIR=/Applications/Xcode9.2.app compile_flags: >- -j$(sysctl -n hw.logicalcpu) - --dbg=off - --opt=size - --enable-free-mon=off --variables-files=etc/scons/xcode_macos.vars - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- -DTHREADS_PTHREAD_ARG=2 @@ -9384,11 +9387,7 @@ buildvariants: cmake_path: /Applications/cmake-3.11.0-Darwin-x86_64/CMake.app/Contents/bin/cmake compile_flags: >- -j$(sysctl -n hw.logicalcpu) - --dbg=off - --opt=size - --enable-free-mon=off --variables-files=etc/scons/xcode_ios.vars - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- -DTHREADS_PTHREAD_ARG=2 @@ -9418,11 +9417,7 @@ buildvariants: compile_env: DEVELOPER_DIR=/Applications/Xcode9.2.app compile_flags: >- -j$(sysctl -n hw.logicalcpu) - --dbg=off - --opt=size - --enable-free-mon=off --variables-files=etc/scons/xcode_ios_sim.vars - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- -DTHREADS_PTHREAD_ARG=2 @@ -9454,11 +9449,7 @@ buildvariants: compile_env: DEVELOPER_DIR=/Applications/XCode9.2.app compile_flags: >- -j$(sysctl -n hw.logicalcpu) - --dbg=off - --opt=size - --enable-free-mon=off --variables-files=etc/scons/xcode_tvos.vars - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- -DTHREADS_PTHREAD_ARG=2 @@ -9487,11 +9478,7 @@ buildvariants: compile_env: DEVELOPER_DIR=/Applications/XCode9.2.app compile_flags: >- -j$(sysctl -n hw.logicalcpu) - --dbg=off - --opt=size - --enable-free-mon=off --variables-files=etc/scons/xcode_tvos_sim.vars - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- -DTHREADS_PTHREAD_ARG=2 @@ -9522,12 +9509,8 @@ buildvariants: # We need --allocator=system here to work around SERVER-XXXXX compile_flags: >- -j$(grep -c ^processor /proc/cpuinfo) - --dbg=off - --opt=size - --enable-free-mon=off --variables-files=etc/scons/mongodbtoolchain_gcc.vars --allocator=system - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: -DCMAKE_C_COMPILER=/opt/mongodbtoolchain/v2/bin/gcc @@ -9551,20 +9534,16 @@ buildvariants: compile_env: JAVA_HOME=/opt/java/jdk8/ compile_flags: >- -j$(grep -c ^processor /proc/cpuinfo) - --dbg=off - --opt=size - --enable-free-mon=off - --android-toolchain-path=$(dirname $(pwd))/android_toolchain + --android-toolchain-path=$(dirname $(pwd))/android_toolchain-arm-21 --variables-files=etc/scons/android_toolchain.vars - --use-system-mongo-c=on LIBS=clang_rt.builtins-arm-android - LIBPATH="$(dirname $($(dirname $(pwd))/android_toolchain/bin/clang -print-file-name=libclang_rt.builtins-arm-android.a)) \$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" + LIBPATH="$(dirname $($(dirname $(pwd))/android_toolchain-arm-21/bin/clang -print-file-name=libclang_rt.builtins-arm-android.a)) \$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- - -DANDROID_NATIVE_API_LEVEL=24 + -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_ABI=armeabi-v7a -DTHREADS_PTHREAD_ARG=2 -DCMAKE_TOOLCHAIN_FILE=$WORKDIR/android_sdk/ndk-bundle/build/cmake/android.toolchain.cmake - -DCMAKE_FIND_ROOT_PATH="$WORKDIR/android_toolchain;$WORKDIR/src/build/mongo-embedded-sdk-$VERSION-tmp" + -DCMAKE_FIND_ROOT_PATH="$WORKDIR/android_toolchain-arm-21;$WORKDIR/src/build/mongo-embedded-sdk-$VERSION-tmp" -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER @@ -9576,7 +9555,9 @@ buildvariants: enable_embedded_tests: android_emulator setup_android_toolchain: true android_toolchain_system_image_arch: "armeabi-v7a" + android_system_image_version: "25" android_toolchain_target_arch: "arm" + android_toolchain_api_version: "21" tasks: - name: compile_mobile @@ -9591,19 +9572,15 @@ buildvariants: compile_env: JAVA_HOME=/opt/java/jdk8/ compile_flags: >- -j$(grep -c ^processor /proc/cpuinfo) - --dbg=off - --opt=size - --enable-free-mon=off - --android-toolchain-path=$(dirname $(pwd))/android_toolchain + --android-toolchain-path=$(dirname $(pwd))/android_toolchain-arm64-21 --variables-files=etc/scons/android_toolchain.vars - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- - -DANDROID_NATIVE_API_LEVEL=24 + -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_ABI=arm64-v8a -DTHREADS_PTHREAD_ARG=2 -DCMAKE_TOOLCHAIN_FILE=$WORKDIR/android_sdk/ndk-bundle/build/cmake/android.toolchain.cmake - -DCMAKE_FIND_ROOT_PATH="$WORKDIR/android_toolchain;$WORKDIR/src/build/mongo-embedded-sdk-$VERSION-tmp" + -DCMAKE_FIND_ROOT_PATH="$WORKDIR/android_toolchain-arm64-21;$WORKDIR/src/build/mongo-embedded-sdk-$VERSION-tmp" -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER @@ -9615,7 +9592,9 @@ buildvariants: enable_embedded_tests: android_emulator setup_android_toolchain: true android_toolchain_system_image_arch: "arm64-v8a" + android_system_image_version: "25" android_toolchain_target_arch: "arm64" + android_toolchain_api_version: "21" tasks: - name: compile_mobile @@ -9630,19 +9609,15 @@ buildvariants: compile_env: JAVA_HOME=/opt/java/jdk8/ compile_flags: >- -j$(grep -c ^processor /proc/cpuinfo) - --dbg=off - --opt=size - --enable-free-mon=off - --android-toolchain-path=$(dirname $(pwd))/android_toolchain + --android-toolchain-path=$(dirname $(pwd))/android_toolchain-x86_64-21 --variables-files=etc/scons/android_toolchain.vars - --use-system-mongo-c=on LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" cdriver_cmake_flags: >- - -DANDROID_NATIVE_API_LEVEL=24 + -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_ABI=x86_64 -DTHREADS_PTHREAD_ARG=2 -DCMAKE_TOOLCHAIN_FILE=$WORKDIR/android_sdk/ndk-bundle/build/cmake/android.toolchain.cmake - -DCMAKE_FIND_ROOT_PATH="$WORKDIR/android_toolchain;$WORKDIR/src/build/mongo-embedded-sdk-$VERSION-tmp" + -DCMAKE_FIND_ROOT_PATH="$WORKDIR/android_toolchain-x86_64-21;$WORKDIR/src/build/mongo-embedded-sdk-$VERSION-tmp" -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER @@ -9651,10 +9626,12 @@ buildvariants: compile_env: JAVA_HOME=/opt/java/jdk8/ disable_unit_tests: true # The Android x86_64 emulator requires KVM. - enable_embedded_tests: false + enable_embedded_tests: android_emulator setup_android_toolchain: true android_toolchain_system_image_arch: "x86_64" + android_system_image_version: 21 android_toolchain_target_arch: "x86_64" + android_toolchain_api_version: "21" tasks: - name: compile_mobile diff --git a/etc/scons/android_toolchain.vars b/etc/scons/android_toolchain.vars index 10212a90ebd..cd1b00159a0 100644 --- a/etc/scons/android_toolchain.vars +++ b/etc/scons/android_toolchain.vars @@ -20,6 +20,7 @@ CXX=os.path.join(toolchain_path, "bin", "clang++" + compiler_suffix) AR=subprocess.check_output([CXX, '-print-prog-name=ar']).strip() LINKFLAGS='-static-libstdc++' +CPPDEFINES='__ANDROID_API__=21' TARGET_OS="android" TOOLS="gcc g++ gnulink ar gas" diff --git a/src/mongo/util/errno_util.cpp b/src/mongo/util/errno_util.cpp index fca401aa129..aa6733de737 100644 --- a/src/mongo/util/errno_util.cpp +++ b/src/mongo/util/errno_util.cpp @@ -58,7 +58,7 @@ std::string errnoWithDescription(int errNumber) { char buf[kBuflen]; char* msg{nullptr}; -#if defined(__GNUC__) && defined(_GNU_SOURCE) +#if defined(__GNUC__) && defined(_GNU_SOURCE) && (__ANDROID_API__ > 22) msg = strerror_r(errNumber, buf, kBuflen); #elif defined(_WIN32) diff --git a/src/third_party/boost-1.60.0/libs/filesystem/src/operations.cpp b/src/third_party/boost-1.60.0/libs/filesystem/src/operations.cpp index b5e0f661ba6..05f67b6220b 100644 --- a/src/third_party/boost-1.60.0/libs/filesystem/src/operations.cpp +++ b/src/third_party/boost-1.60.0/libs/filesystem/src/operations.cpp @@ -11,6 +11,12 @@ //--------------------------------------------------------------------------------------// // define 64-bit offset macros BEFORE including boost/config.hpp (see ticket #5355) +// +// Mongodb modification: +// Don't mess with _FILE_OFFSET_BITS or __USE_FILE_OFFSET64 on android because +// it breaks compiling boost against some older android api versions +// +#if !(defined(__ANDROID__) && (__ANDROID_API__ < 24)) #if !(defined(__HP_aCC) && defined(_ILP32) && !defined(_STATVFS_ACPP_PROBLEMS_FIXED)) #define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect, #endif @@ -28,6 +34,7 @@ #else #define _FILE_OFFSET_BITS 64 #endif +#endif // define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows // the library is being built (possibly exporting rather than importing code) |