Split build type for f-droid build

This commit is contained in:
世界 2021-02-28 21:01:58 +08:00
parent f0e45007d1
commit 5a5e602bc7
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
3 changed files with 84 additions and 51 deletions

View File

@ -19,15 +19,10 @@ def serviceAccountCredentialsFile = rootProject.file("service_account_credential
def beta = verName.contains("preview")
if (serviceAccountCredentialsFile.isFile()) {
setupPlay(beta)
play.serviceAccountCredentials = serviceAccountCredentialsFile
} else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) {
setupPlay(beta)
}
void setupPlay(boolean beta) {
@ -35,10 +30,8 @@ void setupPlay(boolean beta) {
apply plugin: 'com.github.triplet.play'
play {
track = beta ? "beta" : "production"
defaultToAppBundles = true
}
}
@ -52,10 +45,6 @@ def fcmVersion = '21.0.1'
def crashlyticsVersion = '17.3.1'
def playCoreVersion = '1.9.1'
repositories {
jcenter()
}
dependencies {
implementation "androidx.browser:browser:1.3.0"
@ -117,7 +106,6 @@ dependencies {
def keystorePwd = null
def alias = null
def pwd = null
def ignoreX86 = false
Properties properties
def base64 = System.getenv("LOCAL_PROPERTIES")
@ -133,13 +121,26 @@ if (properties != null) {
keystorePwd = properties.getProperty("KEYSTORE_PASS")
alias = properties.getProperty("ALIAS_NAME")
pwd = properties.getProperty("ALIAS_PASS")
ignoreX86 = properties.getProperty("IGNORE_X86") == "true"
}
keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS")
alias = alias ?: System.getenv("ALIAS_NAME")
pwd = pwd ?: System.getenv("ALIAS_PASS")
def targetAbi = ""
if (!gradle.startParameter.taskNames.isEmpty()) {
if (gradle.startParameter.taskNames.size == 1) {
def targetTask = gradle.startParameter.taskNames[0].toLowerCase()
if (targetTask.contains("arm64")) {
targetAbi = "arm64"
} else if (targetTask.contains("arm")) {
targetAbi = "arm"
}
} else {
targetAbi = "~"
}
}
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
@ -154,11 +155,17 @@ android {
enable true
universalApk false
if (ignoreX86) {
exclude 'x86', 'x86_64'
if (!targetAbi.isBlank()) {
if (targetAbi == "arm64") {
exclude 'x86', 'x86_64', 'armeabi-v7a'
} else if (targetAbi == "arm") {
exclude 'x86', 'x86_64', 'arm64-v8a'
} else {
exclude 'x86', 'x86_64'
}
}
}
}
defaultConfig {
@ -269,9 +276,7 @@ android {
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
matchingFallbacks = ['debug']
if (keystorePwd != null) {
signingConfig signingConfigs.release
}
signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release
}
release {
@ -286,7 +291,7 @@ android {
signingConfig signingConfigs.release
}
fossRelease {
foss {
debuggable false
jniDebuggable false
minifyEnabled true
@ -296,6 +301,14 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
matchingFallbacks = ['debug']
}
fdroidArmRelease {
initWith foss
}
fdroidArm64Release {
initWith foss
}
}
sourceSets {
@ -336,7 +349,7 @@ android {
}
}
fossRelease {
foss {
jni {
srcDirs = ['./jni/']
}
@ -383,7 +396,7 @@ android {
}
tasks.all { task ->
if (((task.name.endsWith('Ndk') || task.name.startsWith('generateJsonModel') || task.name.startsWith('externalNativeBuild'))) && !task.name.contains("Foss")) {
if (((task.name.endsWith('Ndk') || task.name.startsWith('generateJsonModel') || task.name.startsWith('externalNativeBuild'))) && !(task.name.contains("Foss") || task.name.contains("Fdroid"))) {
task.enabled = false
}
if (task.name.contains("uploadCrashlyticsMappingFile")) {

View File

@ -1,31 +1,24 @@
import cn.hutool.core.codec.Base64
import com.android.build.gradle.internal.tasks.factory.dependsOn
import org.apache.tools.ant.filters.StringInputStream
import java.util.*
import java.io.*
plugins {
id("com.android.library")
id("org.mozilla.rust-android-gradle.rust-android")
}
var ignoreX86 = false
lateinit var properties: Properties
val base64 = System.getenv("LOCAL_PROPERTIES")
if (!base64.isNullOrBlank()) {
properties = Properties()
properties.load(ByteArrayInputStream(Base64.decode(base64)))
} else if (project.rootProject.file("local.properties").exists()) {
properties = Properties()
properties.load(StringInputStream(project.rootProject.file("local.properties").readText()))
var targetAbi = ""
if (gradle.startParameter.taskNames.isNotEmpty()) {
if (gradle.startParameter.taskNames.size == 1) {
val targetTask = gradle.startParameter.taskNames[0].toLowerCase()
if (targetTask.contains("arm64")) {
targetAbi = "arm64"
} else if (targetTask.contains("arm")) {
targetAbi = "arm"
}
} else {
targetAbi = "~"
}
}
if (::properties.isInitialized) {
ignoreX86 = properties.getProperty("IGNORE_X86") == "true"
}
android {
ndkVersion = rootProject.extra.get("ndkVersion").toString()
@ -37,10 +30,12 @@ android {
}
buildToolsVersion = "30.0.3"
if (ignoreX86) {
splits.abi {
exclude("x86", "x86_64")
}
if (targetAbi.isNotBlank()) {
splits.abi.exclude(* when (targetAbi) {
"arm" -> arrayOf("x86", "x86_64", "arm64-v8a")
"arm64" -> arrayOf("x86", "x86_64", "armeabi-v7a")
else -> arrayOf("x86", "x86_64")
})
}
}
@ -48,10 +43,11 @@ android {
cargo {
module = "src/main/rust/shadowsocks-rust"
libname = "ss-local"
targets = if (ignoreX86) {
listOf("arm", "arm64")
} else {
listOf("arm", "arm64", "x86", "x86_64")
targets = when {
targetAbi.isBlank() -> listOf("arm", "arm64", "x86", "x86_64")
targetAbi == "arm" -> listOf("arm")
targetAbi == "arm64" -> listOf("arm64")
else -> listOf("arm", "arm64")
}
profile = findProperty("CARGO_PROFILE")?.toString() ?: "release"
extraCargoBuildArguments = listOf("--bin", "sslocal")

View File

@ -2,6 +2,21 @@ plugins {
id 'com.android.library'
}
def targetAbi = ""
if (!gradle.startParameter.taskNames.isEmpty()) {
if (gradle.startParameter.taskNames.size == 1) {
def targetTask = gradle.startParameter.taskNames[0].toLowerCase()
if (targetTask.contains("arm64")) {
targetAbi = "arm64"
} else if (targetTask.contains("arm")) {
targetAbi = "arm"
}
} else {
targetAbi = "~"
}
}
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
@ -15,10 +30,19 @@ android {
externalNativeBuild {
ndkBuild {
if (!targetAbi.isBlank()) {
if (targetAbi == "arm64") {
abiFilters 'arm64-v8a'
} else if (targetAbi == "arm") {
abiFilters 'armeabi-v7a'
} else {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
} else {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
arguments "NDK_APPLICATION_MK:=src/main/jni/Application.mk", "APP_PLATFORM:=android-21", "--jobs=8"
}
}
}