From 08d224c9f39b3ed8479596b4964f0678991493e2 Mon Sep 17 00:00:00 2001 From: Geoffrey Bonneville Date: Tue, 7 Nov 2023 11:40:10 +0100 Subject: [PATCH] Build android in CI --- .clang-format-ignore | 3 ++ .github/workflows/actions.yml | 30 ++++++++++++ .gitignore | 3 ++ android/build.gradle | 73 ++++++++++++++++++++++++++++ android/gradle.properties | 6 +++ android/src/main/AndroidManifest.xml | 6 +++ 6 files changed, 121 insertions(+) create mode 100644 android/build.gradle create mode 100644 android/gradle.properties create mode 100644 android/src/main/AndroidManifest.xml diff --git a/.clang-format-ignore b/.clang-format-ignore index 97e66e0aa..52ac9b665 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -7,6 +7,9 @@ cmake-build-*/* libtransmission/version.h web/node_modules/* +# android +android/* + # third-party maintained projects third-party/* diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index a2590a2d8..35f17a49b 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -793,3 +793,33 @@ jobs: with: name: binaries-${{ github.job }} path: pfx/**/* + + android: + needs: [ what-to-make ] + runs-on: ubuntu-22.04 + steps: + - name: Get Source + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + gradle-version: 7.6 + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: Install NDK + run: sdkmanager "ndk;26.1.10909125" + + - name: Build Transmission + working-directory: ./android + run: gradle build diff --git a/.gitignore b/.gitignore index 05eb55296..e151d1ddf 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ node_modules/ /third-party/miniupnp/miniupnpcstrings.h /third-party/suffixes_dafsa.h /web/public_html/transmission-app.js.map +/android/.cxx +/android/.gradle +/android/build # CLion IDE build directory /cmake-build-*/ diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 000000000..362a481fe --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,73 @@ +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath "com.android.tools.build:gradle:7.2.1" + } +} + +apply plugin: "com.android.library" + + +def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') } + +def getExtOrDefault(name) { + return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Transmission_" + name] +} + +def getExtOrIntegerDefault(name) { + return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Transmission_" + name]).toInteger() +} + +android { + ndkVersion getExtOrDefault("ndkVersion") + compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") + + defaultConfig { + minSdkVersion getExtOrIntegerDefault("minSdkVersion") + targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") + externalNativeBuild { + cmake { + abiFilters "x86_64" + arguments "-DANDROID_STL=c++_shared", "-DWITH_CRYPTO=openssl", "-DCMAKE_CXX_FLAGS=-lz" + } + } + } + externalNativeBuild { + cmake { + path "../CMakeLists.txt" + } + } + buildTypes { + release { + minifyEnabled false + } + } + + lintOptions { + disable "GradleCompatible" + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + buildFeatures { + prefab true + } +} + +repositories { + mavenCentral() + google() +} + + +dependencies { + implementation "com.android.ndk.thirdparty:openssl:1.1.1q-beta-1" + implementation "com.android.ndk.thirdparty:curl:7.85.0-beta-1" +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 000000000..b0e294add --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,6 @@ +Transmission_kotlinVersion=1.7.0 +# quotactl is defined from >= 26 +Transmission_minSdkVersion=26 +Transmission_targetSdkVersion=31 +Transmission_compileSdkVersion=31 +Transmission_ndkversion=21.4.7075529 diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..42defb2ac --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + +