Add android build to drone steps

This commit is contained in:
Jason Rhinelander 2020-10-24 15:35:08 -03:00
parent bb40433612
commit 7a533e19a3
3 changed files with 101 additions and 1 deletions

View File

@ -71,7 +71,7 @@ local debian_pipeline(name, image,
) + extra_cmds,
}
],
};
};
// Macos build
local mac_builder(name,
@ -128,6 +128,18 @@ local static_check_and_upload = [
local static_build_deps='autoconf automake make qttools5-dev file libtool gperf pkg-config patch openssh-client';
local android_build_steps(android_abi, android_platform=21, jobs=6) = [
'mkdir build-' + android_abi,
'cd build-' + android_abi,
'cmake .. -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_C_FLAGS=-fdiagnostics-color=always ' +
'-DCMAKE_TOOLCHAIN_FILE=/usr/lib/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake ' +
'-DANDROID_PLATFORM=' + android_platform + ' -DANDROID_ABI=' + android_abi + ' ' +
'-DBUILD_STATIC_DEPS=ON -DSTATIC=ON -G Ninja',
'ninja -j' + jobs + ' -v wallet_api',
'cd ..',
];
[
// Various debian builds
@ -159,4 +171,32 @@ local static_build_deps='autoconf automake make qttools5-dev file libtool gperf
build_tests=false, extra_cmds=static_check_and_upload, lto=true),
mac_builder('macOS (Release)', run_tests=true),
mac_builder('macOS (Debug)', build_type='Debug', cmake_extra='-DBUILD_DEBUG_UTILS=ON'),
// Android builds; we do them all in one image because the android NDK is huge
{ name: 'Android builds', kind: 'pipeline', type: 'docker', platform: { arch: 'amd64' },
steps: [submodules, {
name: 'build',
image: 'debian:sid',
environment: { SSH_KEY: { from_secret: "SSH_KEY" } },
commands: [
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
'echo deb http://deb.debian.org/debian sid contrib >/etc/apt/sources.list.d/sid-contrib.list',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
// Keep cached copies of the android NDK around because it is huge:
'if [ -d /cache ]; then if ! [ -d /cache/google-android-ndk-installer ]; then mkdir /cache/google-android-ndk-installer; fi; ln -s /cache/google-android-ndk-installer /var/cache/; fi',
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends cmake g++ git ninja-build ccache tar xz-utils google-android-ndk-installer ' + static_build_deps,
]
+ android_build_steps('armeabi-v7a')
+ android_build_steps('arm64-v8a')
+ android_build_steps('x86_64')
+ android_build_steps('x86')
+ [
'./utils/build_scripts/android-static-upload.sh armeabi-v7a arm64-v8a x86_64 x86'
]
}
]
}
]

View File

@ -320,6 +320,8 @@ if(CMAKE_CROSSCOMPILING)
else()
list(APPEND boost_extra "address-model=32")
endif()
elseif(ANDROID)
set(boost_bootstrap_cxx "CXX=c++")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)

View File

@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Script used with Drone CI to upload build artifacts (because specifying all this in
# .drone.jsonnet is too painful).
set -o errexit
if [ -z "$SSH_KEY" ]; then
echo -e "\n\n\n\e[31;1mUnable to upload artifact: SSH_KEY not set\e[0m"
# Just warn but don't fail, so that this doesn't trigger a build failure for untrusted builds
exit 0
fi
echo "$SSH_KEY" >ssh_key
set -o xtrace # Don't start tracing until *after* we write the ssh key
chmod 600 ssh_key
branch_or_tag=${DRONE_BRANCH:-${DRONE_TAG:-unknown}}
upload_to="builds.lokinet.dev/${DRONE_REPO// /_}/${branch_or_tag// /_}"
tmpdir=android-deps-${DRONE_COMMIT}
mkdir -p $tmpdir
cp src/wallet/api/wallet2_api.h $tmpdir
for android_abi in "$@"; do
mkdir -p $tmpdir/${android_abi}
cp -v build-${android_abi}/src/wallet/api/libwallet_api.a $tmpdir/${android_abi}
done
filename=android-deps-${DRONE_COMMIT}.tar.xz
tar cJvf $filename $tmpdir
# sftp doesn't have any equivalent to mkdir -p, so we have to split the above up into a chain of
# -mkdir a/, -mkdir a/b/, -mkdir a/b/c/, ... commands. The leading `-` allows the command to fail
# without error.
upload_dirs=(${upload_to//\// })
mkdirs=
dir_tmp=""
for p in "${upload_dirs[@]}"; do
dir_tmp="$dir_tmp$p/"
mkdirs="$mkdirs
-mkdir $dir_tmp"
done
sftp -i ssh_key -b - -o StrictHostKeyChecking=off drone@builds.lokinet.dev <<SFTP
$mkdirs
put $filename $upload_to
SFTP
set +o xtrace
echo -e "\n\n\n\n\e[32;1mUploaded to https://${upload_to}/${filename}\e[0m\n\n\n"