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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
lintOptions {
// This is important as it will run lint but not abort on error
// Lint has some overly obnoxious "errors" that should really be warnings
abortOnError false
}
defaultConfig {
applicationId "org.dolphinemu.dolphinemu"
minSdkVersion 21
targetSdkVersion 21
// TODO This should be set to the Buildbot build number for release builds, and be "1" for debug builds.
versionCode 13
// TODO This should be set to the string currently provided by NativeLibrary.GetVersionString().
versionName "0.13"
}
signingConfigs {
release {
if (project.hasProperty('keystore')) {
storeFile file(project.property('keystore'))
storePassword project.property('storepass')
keyAlias project.property('keyalias')
keyPassword project.property('keypass')
}
}
}
// Define build types, which are orthogonal to product flavors.
buildTypes {
// Signed by release key, allowing for upload to Play Store.
release {
signingConfig signingConfigs.release
}
// Signed by debug key disallowing distribution on Play Store.
// Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
debug {
applicationIdSuffix ".debug"
versionNameSuffix '-debug'
jniDebuggable true
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(compileNative)
}
}
}
// Define product flavors, which can be split into categories. Common examples
// of product flavors are paid vs. free, ARM vs. x86, etc.
productFlavors {
arm_64 {
flavorDimension "abi"
ndk {
abiFilter "arm64-v8a"
}
}
x86_64 {
flavorDimension "abi"
ndk {
abiFilter "x86_64"
}
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:support-v13:22.0.0'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
// For showing the banner as a circle a-la Material Design Guidelines
compile 'de.hdodenhof:circleimageview:1.2.2'
// For loading huge screenshots from the disk.
compile 'com.squareup.picasso:picasso:2.5.2'
}
task setupCMake(type: Exec) {
// Check if a build properties file exists.
def propsFile = rootProject.file("build.properties")
// If it does, call CMake.
if (propsFile.canRead()) {
// Read the properties file's contents.
def buildProperties = new Properties()
buildProperties.load(new FileInputStream(propsFile))
String abi = getAbi()
mkdir('build/' + abi)
workingDir 'build/' + abi
executable 'cmake'
args "-DANDROID=true",
"-DANDROID_NATIVE_API_LEVEL=android-18",
"-DCMAKE_TOOLCHAIN_FILE=../../../android.toolchain.cmake",
"../../../../..",
"-DGIT_EXECUTABLE=" + getGitPath(),
"-DANDROID_NDK=" + getNdkPath(),
"-DANDROID_TOOLCHAIN_NAME=" + getToolchainName(),
"-DANDROID_ABI=" + abi
} else {
executable 'echo'
args 'No build.properties found; skipping CMake.'
}
}
task compileNative(type: Exec, dependsOn: 'setupCMake') {
// Check if a build properties file exists.
def propsFile = rootProject.file("build.properties")
// If it does, call make.
if (propsFile.canRead()) {
// Read the properties file's contents.
def buildProperties = new Properties()
buildProperties.load(new FileInputStream(propsFile))
String abi = getAbi()
workingDir 'build/' + abi
executable 'make'
args buildProperties.makeArgs
} else {
executable 'echo'
args 'No build.properties found; skipping native build.'
}
}
String getGitPath() {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'which', 'git'
standardOutput = stdout
}
def gitPath = stdout.toString().trim()
project.logger.quiet("Gradle: Found git executuable:" + gitPath)
return gitPath
} catch (ignored) {
// Shouldn't happen. How did the user get this file without git?
project.logger.error("Gradle error: Couldn't find git executable.")
return null;
}
}
String getNdkPath() {
try {
def stdout = new ByteArrayOutputStream()
exec {
// ndk-build.cmd is a file unique to the root directory of android-ndk-r10e.
commandLine 'locate', 'ndk-build.cmd'
standardOutput = stdout
}
def ndkCmdPath = stdout.toString()
def ndkPath = ndkCmdPath.substring(0, ndkCmdPath.lastIndexOf('/'))
project.logger.quiet("Gradle: Found Android NDK:" + ndkPath)
return ndkPath
} catch (ignored) {
project.logger.error("Gradle error: Couldn't find NDK.")
return null;
}
}
String getAbi() {
String taskName = getGradle().startParameter.taskNames[0]
String abi;
if (taskName == null) {
return ""
}
project.logger.quiet("Gradle: Build = " + taskName)
if (taskName.contains("Arm_64")) {
abi = "arm64-v8a"
} else if (taskName.contains("Arm")) {
abi = "armeabi-v7a"
} else if (taskName.contains("X86_64")) {
abi = "x86_64"
}
project.logger.quiet("Gradle: ABI name: " + abi)
return abi;
}
String getToolchainName() {
String taskName = getGradle().startParameter.taskNames[0]
String toolchain;
if (taskName == null) {
return ""
}
if (taskName.contains("Arm_64")) {
toolchain = "aarch64-linux-android-4.9"
} else if (taskName.contains("Arm")) {
toolchain = "arm-linux-androideabi-4.9"
} else if (taskName.contains("X86_64")) {
toolchain = "x86_64-4.9"
}
project.logger.quiet("Gradle: ABI name: " + toolchain)
return toolchain;
}
|