-
Notifications
You must be signed in to change notification settings - Fork 242
Autobuild: Combine and simplify Android build scripts #2527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| #!/bin/bash | ||
| set -eu | ||
|
|
||
| COMMANDLINETOOLS_VERSION=6858069 | ||
| ANDROID_NDK_VERSION=r21d | ||
| ANDROID_PLATFORM=android-30 | ||
| ANDROID_BUILD_TOOLS=30.0.2 | ||
| AQTINSTALL_VERSION=2.0.6 | ||
| QT_VERSION=5.15.2 | ||
|
|
||
| # Only variables which are really needed by sub-commands are exported. | ||
| # Definitions have to stay in a specific order due to dependencies. | ||
| QT_BASEDIR="/opt/Qt" | ||
| ANDROID_BASEDIR="/opt/android" | ||
| BUILD_DIR=build | ||
| export ANDROID_SDK_ROOT="${ANDROID_BASEDIR}/android-sdk" | ||
| COMMANDLINETOOLS_DIR="${ANDROID_SDK_ROOT}"/cmdline-tools/latest/ | ||
| ANDROID_NDK_ROOT="${ANDROID_BASEDIR}/android-ndk" | ||
| ANDROID_NDK_HOST="linux-x86_64" | ||
| ANDROID_SDKMANAGER="${COMMANDLINETOOLS_DIR}/bin/sdkmanager" | ||
| export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/" | ||
| export PATH="${PATH}:${ANDROID_SDK_ROOT}/tools" | ||
| export PATH="${PATH}:${ANDROID_SDK_ROOT}/platform-tools" | ||
|
|
||
| if [[ ! ${jamulus_buildversionstring:-} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
| echo "Environment variable jamulus_buildversionstring has to be set to a valid version string" | ||
| exit 1 | ||
| fi | ||
|
|
||
| setup_ubuntu_dependencies() { | ||
| export DEBIAN_FRONTEND="noninteractive" | ||
|
|
||
| sudo apt-get -qq update | ||
| sudo apt-get -qq --no-install-recommends -y install build-essential zip unzip bzip2 p7zip-full curl chrpath openjdk-8-jdk-headless | ||
| } | ||
|
|
||
| setup_android_sdk() { | ||
| mkdir -p "${ANDROID_BASEDIR}" | ||
|
|
||
| if [[ -d "${COMMANDLINETOOLS_DIR}" ]]; then | ||
| echo "Using commandlinetools installation from previous run (actions/cache)" | ||
| else | ||
| mkdir -p "${COMMANDLINETOOLS_DIR}" | ||
| curl -s -o downloadfile "https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}_latest.zip" | ||
| unzip -q downloadfile | ||
| mv cmdline-tools/* "${COMMANDLINETOOLS_DIR}" | ||
| fi | ||
|
|
||
| yes | "${ANDROID_SDKMANAGER}" --licenses | ||
| "${ANDROID_SDKMANAGER}" --update | ||
| "${ANDROID_SDKMANAGER}" "platforms;${ANDROID_PLATFORM}" | ||
| "${ANDROID_SDKMANAGER}" "build-tools;${ANDROID_BUILD_TOOLS}" | ||
| } | ||
|
|
||
| setup_android_ndk() { | ||
| mkdir -p "${ANDROID_BASEDIR}" | ||
| if [[ -d "${ANDROID_NDK_ROOT}" ]]; then | ||
| echo "Using NDK installation from previous run (actions/cache)" | ||
| else | ||
| curl -s -o downloadfile "https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip" | ||
| unzip -q downloadfile | ||
| mv "android-ndk-${ANDROID_NDK_VERSION}" "${ANDROID_NDK_ROOT}" | ||
| fi | ||
| } | ||
|
|
||
| setup_qt() { | ||
| if [[ -d "${QT_BASEDIR}" ]]; then | ||
| echo "Using Qt installation from previous run (actions/cache)" | ||
| else | ||
| echo "Installing Qt..." | ||
| python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}" | ||
| python3 -m aqt install-qt --outputdir "${QT_BASEDIR}" linux android "${QT_VERSION}" \ | ||
| --archives qtbase qttools qttranslations qtandroidextras | ||
| fi | ||
| } | ||
|
|
||
| build_app_as_apk() { | ||
| QT_DIR="${QT_BASEDIR}/${QT_VERSION}/android" | ||
| MAKE="${ANDROID_NDK_ROOT}/prebuilt/${ANDROID_NDK_HOST}/bin/make" | ||
|
|
||
| "${QT_DIR}/bin/qmake" -spec android-clang | ||
| "${MAKE}" -j "$(nproc)" | ||
| "${MAKE}" INSTALL_ROOT="${BUILD_DIR}" -f Makefile install | ||
| "${QT_DIR}"/bin/androiddeployqt --input android-Jamulus-deployment-settings.json --output "${BUILD_DIR}" \ | ||
| --android-platform "${ANDROID_PLATFORM}" --jdk "${JAVA_HOME}" --gradle | ||
| } | ||
|
|
||
| pass_artifact_to_job() { | ||
| mkdir deploy | ||
| artifact_deploy_filename="jamulus_${jamulus_buildversionstring}_android.apk" | ||
| echo "Moving ${BUILD_DIR}/build/outputs/apk/debug/build-debug.apk to deploy/${artifact_deploy_filename}" | ||
| mv "./${BUILD_DIR}/build/outputs/apk/debug/build-debug.apk" "./deploy/${artifact_deploy_filename}" | ||
| echo "::set-output name=artifact_1::${artifact_deploy_filename}" | ||
| } | ||
|
|
||
| case "${1:-}" in | ||
| setup) | ||
| setup_ubuntu_dependencies | ||
| setup_android_ndk | ||
| setup_android_sdk | ||
| setup_qt | ||
| ;; | ||
| build) | ||
| build_app_as_apk | ||
| ;; | ||
| get-artifacts) | ||
| pass_artifact_to_job | ||
| ;; | ||
| *) | ||
| echo "Unknown stage '${1:-}'" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although this would apply to all scripts: We should probably output something like "NOTE: This script is designed to run on GitHub Actions, not locally. Please run the deploy scripts in the respective OS folder" |
||
| exit 1 | ||
| esac | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.