Merge pull request 'build.gradle include' (#455) from android-packaging into master
the build was successful Details

Reviewed-on: #455
This commit is contained in:
Sarah Jamie Lewis 2020-12-15 13:27:10 -08:00
commit f44cb450a5
2 changed files with 151 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<manifest package="ca.openprivacy.cwtch.ui" xmlns:android="http://schemas.android.com/apk/res/android"
android:versionName="1.0"
android:versionCode="1"
android:versionCode="4"
android:installLocation="auto">
<application android:hardwareAccelerated="true"
android:name="org.qtproject.qt5.android.bindings.QtApplication"

150
android/build.gradle Normal file
View File

@ -0,0 +1,150 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion '28.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
// kinda of cheaty, would prefer to use if (System.getEnv("GOARCH") == "arm64") {
// but it doesn't want to work in this context
if (qt5AndroidDir.contains("arm64")) {
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
// Note that because of the way that therecipe/qt bundles libraries
// only the specific architecture specified by GOARCH /GOARM will *actually*
// work so we currently have to do separate builds for each arch - this needs to be fixed.
include "arm64-v8a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
// QT deploy has to be run twice to generate the libgo_base.so for each arch
universalApk false
}
}
task linkBuildDebugArm64(type: Exec) {
workingDir '../build/build/outputs/apk/debug/'
commandLine 'ln', '-sf', 'build-arm64-v8a-debug.apk', 'build-debug.apk'
}
task renameBuildReleaseArm64(type: Exec) {
workingDir '../build/build/outputs/apk/release/'
commandLine 'mv', 'build-arm64-v8a-release-unsigned.apk', 'build-release-unsigned.apk'
}
afterEvaluate {
assembleDebug.finalizedBy(linkBuildDebugArm64)
assembleRelease.finalizedBy(renameBuildReleaseArm64)
}
} else {
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
// Note that because of the way that therecipe/qt bundles libraries
// only the specific architecture specified by GOARCH /GOARM will *actually*
// work so we currently have to do separate builds for each arch - this needs to be fixed.
include "armeabi-v7a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
// QT deploy has to be run twice to generate the libgo_base.so for each arch
universalApk false
}
}
task linkBuildDebugArm7(type: Exec) {
workingDir '../build/build/outputs/apk/debug/'
commandLine 'ln', '-sf', 'build-armeabi-v7a-debug.apk', 'build-debug.apk'
}
task renameBuildReleaseArm7(type: Exec) {
workingDir '../build/build/outputs/apk/release/'
commandLine 'mv', 'build-armeabi-v7a-release-unsigned.apk', 'build-release-unsigned.apk'
}
afterEvaluate {
assembleDebug.finalizedBy(linkBuildDebugArm7)
assembleRelease.finalizedBy(renameBuildReleaseArm7)
}
}
lintOptions {
abortOnError true
}
}