diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2018-07-09 17:20:43 -0400 |
---|---|---|
committer | Gabriel Russell <gabriel.russell@mongodb.com> | 2018-07-24 17:06:45 -0400 |
commit | ca05978a1128cc1e170986bea104ef4087ee6bd2 (patch) | |
tree | 130f3e3e85b5145dfabb5f1cb3a92a50659970bc | |
parent | 5f195f34feada214fd0ab6d83e16d56ac27cef17 (diff) | |
download | mongo-ca05978a1128cc1e170986bea104ef4087ee6bd2.tar.gz |
SERVER-36245 Create a multi-arch android variant
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | etc/evergreen.yml | 103 | ||||
-rw-r--r-- | src/mongo/embedded/android/build.gradle | 27 | ||||
-rw-r--r-- | src/mongo/embedded/android/gradle.properties | 13 | ||||
-rw-r--r-- | src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.jar | bin | 0 -> 54708 bytes | |||
-rw-r--r-- | src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.properties | 6 | ||||
-rw-r--r-- | src/mongo/embedded/android/gradlew | 172 | ||||
-rw-r--r-- | src/mongo/embedded/android/gradlew.bat | 84 | ||||
-rw-r--r-- | src/mongo/embedded/android/mongodb-embedded-capi/build.gradle | 25 | ||||
-rw-r--r-- | src/mongo/embedded/android/mongodb-embedded-capi/src/main/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | src/mongo/embedded/android/settings.gradle | 1 |
11 files changed, 437 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 2db92b85522..eb9f70011b2 100644 --- a/.gitignore +++ b/.gitignore @@ -154,4 +154,8 @@ CMakeLists.txt *.wixpdb DriverInclude.wxs +# Gradle +.gradle +src/mongo/embedded/java/mongodb-embedded-capi/build/ + compile_commands.json diff --git a/etc/evergreen.yml b/etc/evergreen.yml index 648a4d4bd9f..1a1f742b91c 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -3432,6 +3432,7 @@ tasks: script: | set -o errexit set -o verbose + tar cfvz ./embedded-sdk.tgz ./mongo-embedded-sdk-${version} # Upload it so we can download from EVG. @@ -3462,6 +3463,7 @@ tasks: script: | set -o errexit set -o verbose + if [ ${enable_embedded_tests|false} = "ios_tvos_simulator" -a $(command -v xcrun) ]; then find ./lib -type f -name "*.dylib" -print0 | xargs -0 -L 1 xcrun codesign -s - fi @@ -3495,6 +3497,9 @@ tasks: params: working_dir: "src/build" script: | + set -o errexit + set -o verbose + if [ "${is_patch}" = "true" ]; then rm -f src/build/embedded-sdk.tgz fi @@ -3515,6 +3520,89 @@ tasks: permissions: public-read content_type: ${content_type|application/x-gzip} +- name: embedded_sdk_multiarch_android_package + depends_on: + - name: embedded_sdk_s3_put + variant: embedded-sdk-android-arm32 + - name: embedded_sdk_s3_put + variant: embedded-sdk-android-arm64 + - name: embedded_sdk_s3_put + variant: embedded-sdk-android-x86_64 + commands: + - command: manifest.load + - func: "git get project" + - func: "get buildnumber" + - func: "set up credentials" + - func: "setup android toolchain" # noop if ${setup_android_toolchain} is not "true" + - func: "generate compile expansions" + - func: "apply compile expansions" + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/embedded-sdk/embedded-sdk-android-arm32/${revision}/${version}.tgz + bucket: mciuploads + local_file: "embedded-sdk-android-armeabi-v7a.tgz" + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/embedded-sdk/embedded-sdk-android-arm64/${revision}/${version}.tgz + bucket: mciuploads + local_file: "embedded-sdk-android-arm64-v8a.tgz" + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/embedded-sdk/embedded-sdk-android-x86_64/${revision}/${version}.tgz + bucket: mciuploads + local_file: "embedded-sdk-android-x86_64.tgz" + - command: shell.exec + params: + script: | + set -o errexit + set -o verbose + + if [ "${setup_android_toolchain|}" = "true" ]; then + export ANDROID_HOME=$(pwd)/android_sdk + + cd src/src/mongo/embedded/android + + chmod +x gradlew + + for arch in arm64-v8a armeabi-v7a x86_64 ; do + tar zxvf ../../../../../embedded-sdk-android-$arch.tgz + mkdir -p mongodb-embedded-capi/src/main/jniLibs/$arch + cp ./mongo-embedded-sdk-${version}/lib/*.so mongodb-embedded-capi/src/main/jniLibs/$arch + rm -rf ./mongo-embedded-sdk-${version} + done + + ./gradlew build + + mkdir -p ../../../../build/mongo-embedded-sdk-${version}/aar + cp mongodb-embedded-capi/build/outputs/aar/*.aar ../../../../build/mongo-embedded-sdk-${version}/aar + fi + - command: shell.exec + params: + script: | + set -o errexit + set -o verbose + + if [ "${setup_android_toolchain|}" = "true" ]; then + cd src/build + tar zcvf mongo-embedded-sdk-${version}.tgz mongo-embedded-sdk-${version} + fi + - command: s3.put + params: + #optional: true + aws_key: ${aws_key} + aws_secret: ${aws_secret} + local_file: "src/build/mongo-embedded-sdk-${version}.tgz" + remote_file: "${project}/embedded-sdk/embedded-sdk-android-multiarch/${revision}/${version}.tgz" + bucket: mciuploads + permissions: public-read + content_type: application/tar + display_name: "Embedded SDK Tar Archive" - name: compile_benchmarks depends_on: [] @@ -9896,6 +9984,21 @@ buildvariants: tasks: - name: embedded_sdk_build_and_test +- name: embedded-sdk-android-multiarch + display_name: "Embedded SDK - Android Multiarch Package" + run_on: + - ubuntu1604-build + batchtime: 1440 # 1 day + expansions: + compile_env: JAVA_HOME=/opt/java/jdk8/ + 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: embedded_sdk_multiarch_android_package + ########################################### # Redhat buildvariants # ########################################### diff --git a/src/mongo/embedded/android/build.gradle b/src/mongo/embedded/android/build.gradle new file mode 100644 index 00000000000..ae504cf74f6 --- /dev/null +++ b/src/mongo/embedded/android/build.gradle @@ -0,0 +1,27 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + jcenter() + + } + dependencies { + classpath 'com.android.tools.build:gradle:3.1.2' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/src/mongo/embedded/android/gradle.properties b/src/mongo/embedded/android/gradle.properties new file mode 100644 index 00000000000..1bb109ad42b --- /dev/null +++ b/src/mongo/embedded/android/gradle.properties @@ -0,0 +1,13 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx4096m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.jar b/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 00000000000..7a3265ee94c --- /dev/null +++ b/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.jar diff --git a/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.properties b/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..63a52fcd345 --- /dev/null +++ b/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Jun 07 14:12:06 EDT 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/src/mongo/embedded/android/gradlew b/src/mongo/embedded/android/gradlew new file mode 100644 index 00000000000..cccdd3d517f --- /dev/null +++ b/src/mongo/embedded/android/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/src/mongo/embedded/android/gradlew.bat b/src/mongo/embedded/android/gradlew.bat new file mode 100644 index 00000000000..f9553162f12 --- /dev/null +++ b/src/mongo/embedded/android/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/mongo/embedded/android/mongodb-embedded-capi/build.gradle b/src/mongo/embedded/android/mongodb-embedded-capi/build.gradle new file mode 100644 index 00000000000..925a6cb4c73 --- /dev/null +++ b/src/mongo/embedded/android/mongodb-embedded-capi/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 28 + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + } + + buildTypes { + release { + minifyEnabled false + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' +} diff --git a/src/mongo/embedded/android/mongodb-embedded-capi/src/main/AndroidManifest.xml b/src/mongo/embedded/android/mongodb-embedded-capi/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..8d3ffd30527 --- /dev/null +++ b/src/mongo/embedded/android/mongodb-embedded-capi/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.mongodb.embedded" /> diff --git a/src/mongo/embedded/android/settings.gradle b/src/mongo/embedded/android/settings.gradle new file mode 100644 index 00000000000..a9df6d05560 --- /dev/null +++ b/src/mongo/embedded/android/settings.gradle @@ -0,0 +1 @@ +include ':mongodb-embedded-capi' |