remove constants from build.gradle

cleanup, iterating over built-in data rather than my hard-coded VARIANTS
and BUILDS arrays, which now go away. Renamed obj- and libs- directories
to better fit the variables the system provides.
This commit is contained in:
Eric House 2017-06-01 07:41:51 -07:00
parent f49aac71cf
commit 5c893127de

View file

@ -1,8 +1,6 @@
def INITIAL_CLIENT_VERS = 8 def INITIAL_CLIENT_VERS = 8
def VERSION_CODE_BASE = 115 def VERSION_CODE_BASE = 115
def VERSION_NAME = '4.4.119' def VERSION_NAME = '4.4.119'
def VARIANTS = [ "xw4", "xw4d" ]
def BUILDS = [ "Debug", "Release" ]
boolean forFDroid = hasProperty('forFDroid') boolean forFDroid = hasProperty('forFDroid')
// Get the git revision we're using. Since fdroid modifies files as // Get the git revision we're using. Since fdroid modifies files as
@ -126,18 +124,18 @@ android {
// debugging don't work. // debugging don't work.
xw4 { xw4 {
release { release {
jniLibs.srcDir "../libs-release-xw4" jniLibs.srcDir "../libs-xw4Release"
} }
debug { debug {
jniLibs.srcDir "../libs-debug-xw4" jniLibs.srcDir "../libs-xw4Debug"
} }
} }
xw4d { xw4d {
release { release {
jniLibs.srcDir "../libs-release-xw4d" jniLibs.srcDir "../libs-xw4dRelease"
} }
debug { debug {
jniLibs.srcDir "../libs-debug-xw4d" jniLibs.srcDir "../libs-xw4dDebug"
} }
} }
} }
@ -192,23 +190,40 @@ task mkXml(type: Exec) {
} }
afterEvaluate { afterEvaluate {
VARIANTS.each { VARIANT -> ArrayList<String> cleanCmdLst = new ArrayList<>(["rm", "-rf"]);
String variantCaps = VARIANT.capitalize() android.applicationVariants.all { variant ->
BUILDS.each { BUILD -> // print "variant: " + variant.name + "\n"
String nameLC = BUILD.toLowerCase() String BUILD = variant.getBuildType().getName()
String lib = "libs-${nameLC}-${VARIANT}" // print "type: " + BUILD + "\n"
String ndkBuildTask = "ndkBuild${variantCaps}${BUILD}" String FLAVOR = variant.getFlavorName()
// print "flavor: " + variant.getFlavorName() + "\n"
// print "variant: " + variant + "\n"
String variantCaps = variant.name.capitalize()
String nameLC = variant.getBuildType().getName().toLowerCase()
String lib = "libs-${variant.name}"
String ndkBuildTask = "ndkBuild${variantCaps}"
task "$ndkBuildTask"(type: Exec) { task "$ndkBuildTask"(type: Exec) {
workingDir '../' workingDir '../'
commandLine './scripts/ndkbuild.sh', '-j3', commandLine './scripts/ndkbuild.sh', '-j3',
"BUILD_TARGET=${nameLC}", "INITIAL_CLIENT_VERS=$INITIAL_CLIENT_VERS", "BUILD_TARGET=${nameLC}", "INITIAL_CLIENT_VERS=$INITIAL_CLIENT_VERS",
"VARIANT=$VARIANT", "NDK_LIBS_OUT=${lib}", "NDK_OUT=./obj-${nameLC}-${VARIANT}" "VARIANT=${FLAVOR}", "NDK_LIBS_OUT=${lib}",
"NDK_OUT=./obj-${variant.name}"
} }
String compileTask = "compile${variantCaps}${BUILD}Ndk" String compileTask = "compile${variantCaps}Ndk"
tasks.getByName(compileTask).dependsOn ndkBuildTask tasks.getByName(compileTask).dependsOn ndkBuildTask
// For clean task
cleanCmdLst.add("libs-${variant.name}")
cleanCmdLst.add("./obj-${variant.name}")
} }
task cleanNDK(type: Exec) {
workingDir '../'
commandLine cleanCmdLst
} }
clean.dependsOn 'cleanNDK'
String copyStringsTask = "copyStringsXw4D" String copyStringsTask = "copyStringsXw4D"
task "$copyStringsTask"(type: Exec) { task "$copyStringsTask"(type: Exec) {
@ -220,21 +235,6 @@ afterEvaluate {
preBuild.dependsOn copyStringsTask preBuild.dependsOn copyStringsTask
} }
clean.dependsOn 'cleanNDK'
task cleanNDK(type: Exec) {
ArrayList<String> lst = new ArrayList<String>(["rm", "-rf"]);
BUILDS.each { BUILD ->
String buildLC = BUILD.toLowerCase()
VARIANTS.each { VARIANT ->
lst.add("libs-${buildLC}-${VARIANT}")
lst.add("obj-${buildLC}-${VARIANT}")
}
}
workingDir '../'
commandLine lst
}
task makeBuildAssets() { task makeBuildAssets() {
def assetsDir = android.sourceSets.main.assets.srcDirs.toArray()[0] def assetsDir = android.sourceSets.main.assets.srcDirs.toArray()[0]
String path = new File(assetsDir, 'build-info.txt').getAbsolutePath() String path = new File(assetsDir, 'build-info.txt').getAbsolutePath()