Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
126 lines (119 loc) · 4.87 KB
/
Copy pathbuild.gradle
File metadata and controls
126 lines (119 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// For building the open-source release of TalkBack.
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.compose) apply false
}
apply from: 'shared.gradle'
apply from: 'version.gradle'
dependencies {
implementation project(':talkback')
// SandFly AI, when sandfly-ai/ is checked out (see settings.gradle). SandFly finds it by name.
if (findProject(':sandflyai') != null) {
phoneImplementation project(':sandflyai')
}
}
// SandFly's signing key: SANDFLY_KEYSTORE, or ~/.android/sandfly-release.jks, with its password in
// SANDFLY_KEY_PASSWORD, or on a Mac in the Keychain item "SandFly Android signing key". Without
// them, builds are signed with the debug key, and cannot update or be updated by SandFly's builds.
def sandflyKeystore = file(System.getenv("SANDFLY_KEYSTORE") ?: "${System.getProperty("user.home")}/.android/sandfly-release.jks")
def sandflyKeyPassword = System.getenv("SANDFLY_KEY_PASSWORD") ?: ""
if (sandflyKeyPassword.isEmpty() && sandflyKeystore.isFile() && new File("/usr/bin/security").canExecute()) {
try {
sandflyKeyPassword = providers.exec {
commandLine("/usr/bin/security", "find-generic-password", "-a", "sandfly", "-s", "SandFly Android signing key", "-w")
ignoreExitValue = true
}.standardOutput.asText.get().trim()
} catch (Exception ignored) {
}
}
def signWithSandflyKey = sandflyKeystore.isFile() && !sandflyKeyPassword.isEmpty()
// The SandFly add-on is signed the same way.
ext.sandflyKeystore = sandflyKeystore
ext.sandflyKeyPassword = sandflyKeyPassword
ext.signWithSandflyKey = signWithSandflyKey
android {
namespace = "com.android.talkback"
if (signWithSandflyKey) {
signingConfigs {
sandfly {
storeFile = sandflyKeystore
storePassword = sandflyKeyPassword
keyAlias = "sandfly"
keyPassword = sandflyKeyPassword
}
}
}
defaultConfig {
applicationId = talkbackApplicationId
// The version code is 100000000 plus the build number. Gboard does its own touch typing,
// which types a key when the finger slides off the keyboard, unless the screen reader's
// package has the support_lift_to_type meta-data and a version code of at least 60105832.
versionCode = 100000000 + gitCommitCount
versionName = sandflyVersionName
minSdk = 26
targetSdk = 36
testInstrumentationRunner = 'android.test.InstrumentationTestRunner'
multiDexEnabled = true
}
buildTypes {
// The published builds are debug builds, signed with SandFly's key. Android runs a
// debuggable app without compiling it, which makes navigation several times slower on
// a watch, so they are not debuggable. Debug logging in the libraries stays on.
debug {
debuggable = false
if (signWithSandflyKey) {
signingConfig = signingConfigs.sandfly
}
}
}
// The NDK of the native modules, whose tools strip debug symbols from the native libraries.
ndkVersion = "27.3.13750724"
packaging {
resources {
excludes += ['LICENSE', 'README']
}
jniLibs {
// On-device AI only runs on arm64-v8a (see OnDeviceAiSettings), so its 26 MB library
// would never load on x86_64.
excludes += ['lib/x86_64/liblitertlm_jni.so']
// Whisper's GPU build links against a libOpenCL.so made only for linking. The phone's own
// driver must be the one loaded.
excludes += ['lib/*/libOpenCL.so']
}
}
lint {
checkReleaseBuilds = false
// Lint the library modules too, where most of the code is, in one report.
checkDependencies = true
// The issues that were already there when lint was added to CI. Only new ones fail the
// build. To accept new ones on purpose, run ./gradlew updateLintBaselinePhoneFullDebug.
baseline = file("lint-baseline.xml")
abortOnError = true
}
flavorDimensions = ["target", "distribution"]
productFlavors {
phone {
dimension = "target"
}
wear {
dimension = "target"
versionNameSuffix = "-wear"
}
// Published on GitHub: it updates itself and uses Shizuku itself.
full {
dimension = "distribution"
}
// Published on Google Play: it uses Shizuku through the SandFly add-on.
play {
dimension = "distribution"
}
}
}
// Watches have only the full build.
androidComponents {
beforeVariants(selector().all()) { variant ->
def flavors = variant.productFlavors.collect { it.second }
if (flavors.contains('wear') && flavors.contains('play')) variant.enable = false
}
}