2017-01-18 16:01:25 +01:00
|
|
|
def INITIAL_CLIENT_VERS = 8
|
2017-05-18 15:53:03 +02:00
|
|
|
def VERSION_CODE_BASE = 114
|
|
|
|
def VERSION_NAME = '4.4.118'
|
2017-05-23 15:37:31 +02:00
|
|
|
def VARIANTS = [ "xw4", "xw4d" ]
|
2017-01-18 16:01:25 +01:00
|
|
|
def BUILDS = [ "Debug", "Release" ]
|
2017-01-23 01:22:35 +01:00
|
|
|
def GITREV = "git describe --tags --dirty".execute().text.trim()
|
2017-01-18 16:01:25 +01:00
|
|
|
|
|
|
|
apply plugin: 'com.android.application'
|
|
|
|
|
|
|
|
android {
|
2017-02-04 17:12:40 +01:00
|
|
|
buildToolsVersion '23.0.3'
|
2017-01-18 16:01:25 +01:00
|
|
|
defaultConfig {
|
|
|
|
minSdkVersion 7
|
|
|
|
targetSdkVersion 23
|
|
|
|
versionCode VERSION_CODE_BASE
|
|
|
|
versionName VERSION_NAME
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rename all output artifacts to include version information
|
|
|
|
applicationVariants.all { variant ->
|
|
|
|
// renameArtifact(variant)
|
|
|
|
// variant.buildConfigField "String", "FIELD_NAME", "\"my String\""
|
|
|
|
def GCM_SENDER_ID = System.getenv("GCM_SENDER_ID")
|
|
|
|
variant.buildConfigField "String", "SENDER_ID", "\"$GCM_SENDER_ID\""
|
|
|
|
def CRITTERCISM_APP_ID = System.getenv("CRITTERCISM_APP_ID")
|
|
|
|
variant.buildConfigField "String", "CRITTERCISM_APP_ID", "\"$CRITTERCISM_APP_ID\""
|
|
|
|
|
2017-01-23 01:22:35 +01:00
|
|
|
resValue "string", "git_rev", "$GITREV"
|
|
|
|
variant.buildConfigField "String", "GIT_REV", "\"$GITREV\""
|
2017-01-18 17:27:48 +01:00
|
|
|
|
|
|
|
// def stamp = Long.valueOf('date +\'%s\''.execute().text.trim());
|
|
|
|
def stamp = Math.round(System.currentTimeMillis() / 1000)
|
|
|
|
variant.buildConfigField "long", "BUILD_STAMP", "$stamp"
|
|
|
|
|
|
|
|
// FIX ME
|
|
|
|
variant.buildConfigField "String", "STRINGS_HASH", "\"00000\""
|
|
|
|
|
|
|
|
def senderID = System.getenv("GCM_SENDER_ID")
|
|
|
|
variant.buildConfigField "String", "GCM_SENDER_ID", "\"$senderID\""
|
|
|
|
|
|
|
|
variant.buildConfigField "short", "CLIENT_VERS_RELAY", "$INITIAL_CLIENT_VERS"
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
flavorDimensions "variant"//, "abi"
|
|
|
|
productFlavors {
|
|
|
|
xw4 {
|
|
|
|
dimension "variant"
|
2017-05-23 15:37:31 +02:00
|
|
|
applicationId "org.eehouse.android.xw4"
|
2017-01-18 16:01:25 +01:00
|
|
|
manifestPlaceholders = [ APP_ID: applicationId ]
|
|
|
|
resValue "string", "app_name", "CrossWords"
|
|
|
|
resValue "string", "nbs_port", "3344"
|
|
|
|
resValue "string", "invite_prefix", "/and/"
|
2017-01-20 16:56:03 +01:00
|
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
2017-05-23 15:37:31 +02:00
|
|
|
xw4d {
|
2017-01-18 16:01:25 +01:00
|
|
|
dimension "variant"
|
2017-05-23 15:37:31 +02:00
|
|
|
applicationId "org.eehouse.android.xw4dbg"
|
2017-01-18 16:01:25 +01:00
|
|
|
manifestPlaceholders = [ APP_ID: applicationId ]
|
|
|
|
resValue "string", "app_name", "CrossDbg"
|
|
|
|
resValue "string", "nbs_port", "3345"
|
|
|
|
resValue "string", "invite_prefix", "/anddbg/"
|
2017-01-20 16:56:03 +01:00
|
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "true"
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// WARNING: "all" breaks things. Seems to be a keyword. Need
|
|
|
|
// to figure out how to express include-all-abis
|
|
|
|
// all {
|
|
|
|
// dimension "abi"
|
|
|
|
// versionCode 0 + VERSION_CODE_BASE
|
|
|
|
// }
|
|
|
|
// armeabi {
|
|
|
|
// dimension "abi"
|
|
|
|
// versionCode 1 + VERSION_CODE_BASE
|
|
|
|
// }
|
|
|
|
// x86 {
|
|
|
|
// dimension "abi"
|
|
|
|
// versionCode 2 + VERSION_CODE_BASE
|
|
|
|
// }
|
|
|
|
// armeabiv7a {
|
|
|
|
// dimension "abi"
|
|
|
|
// versionCode 3 + VERSION_CODE_BASE
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
signingConfigs {
|
2017-01-23 00:27:35 +01:00
|
|
|
debug {
|
|
|
|
def path = System.getenv("DEBUG_KEYSTORE_PATH")
|
|
|
|
if (! path) {
|
|
|
|
path = "./debug.keystore"
|
|
|
|
}
|
|
|
|
storeFile file(path)
|
|
|
|
keyAlias "androiddebugkey"
|
|
|
|
storePassword "android"
|
|
|
|
keyPassword "android"
|
|
|
|
}
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
debuggable false
|
2017-01-19 06:27:48 +01:00
|
|
|
minifyEnabled false // PENDING
|
2017-01-18 16:01:25 +01:00
|
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
|
|
}
|
|
|
|
debug {
|
|
|
|
debuggable true
|
|
|
|
// This doesn't work on marshmallow: duplicate permission error
|
|
|
|
// applicationIdSuffix ".debug"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
// Use symlinks instead of setting non-conventional
|
|
|
|
// directories here. AS doesn't respect what's set here: it'll
|
|
|
|
// compile, but post-install app launch and source-level
|
|
|
|
// debugging don't work.
|
2017-01-19 17:10:16 +01:00
|
|
|
xw4 {
|
|
|
|
release {
|
|
|
|
jniLibs.srcDir "../libs-release-xw4"
|
|
|
|
}
|
|
|
|
debug {
|
|
|
|
jniLibs.srcDir "../libs-debug-xw4"
|
|
|
|
}
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
2017-05-23 15:37:31 +02:00
|
|
|
xw4d {
|
2017-01-19 17:10:16 +01:00
|
|
|
release {
|
2017-05-23 15:37:31 +02:00
|
|
|
jniLibs.srcDir "../libs-release-xw4d"
|
2017-01-19 17:10:16 +01:00
|
|
|
}
|
|
|
|
debug {
|
2017-05-23 15:37:31 +02:00
|
|
|
jniLibs.srcDir "../libs-debug-xw4d"
|
2017-01-19 17:10:16 +01:00
|
|
|
}
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lintOptions {
|
|
|
|
abortOnError false
|
|
|
|
}
|
|
|
|
|
|
|
|
applicationVariants.all { variant ->
|
|
|
|
variant.outputs.each { output ->
|
2017-01-23 00:55:31 +01:00
|
|
|
def newName = output.outputFile.name
|
2017-01-23 01:22:35 +01:00
|
|
|
newName = newName.replace(".apk","-${GITREV}.apk")
|
2017-01-23 00:55:31 +01:00
|
|
|
newName = newName.replace("app-","")
|
|
|
|
output.outputFile = new File(output.outputFile.parent, newName)
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2017-01-19 04:03:36 +01:00
|
|
|
// Look into replacing this with a fetch too PENDING
|
|
|
|
compile files('../libs/gcm.jar')
|
|
|
|
|
2017-02-04 17:12:40 +01:00
|
|
|
compile 'com.android.support:support-v4:23.4.0'
|
2017-01-19 04:03:36 +01:00
|
|
|
|
2017-05-23 15:37:31 +02:00
|
|
|
xw4dCompile 'com.crittercism:crittercism-android-agent:+'
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
task mkImages(type: Exec) {
|
|
|
|
workingDir '../'
|
|
|
|
commandLine './scripts/mkimages.sh'
|
|
|
|
}
|
|
|
|
|
|
|
|
task copyStrings(type: Exec) {
|
|
|
|
workingDir '../'
|
|
|
|
commandLine './scripts/copy-strings.py'
|
|
|
|
}
|
|
|
|
|
|
|
|
task ndkSetup(type: Exec) {
|
|
|
|
workingDir '../'
|
|
|
|
commandLine "./scripts/ndksetup.sh", "--with-clang"
|
|
|
|
}
|
|
|
|
|
|
|
|
task myPreBuild(dependsOn: ['ndkSetup', 'mkImages', 'copyStrings', 'mkXml']) {
|
|
|
|
}
|
|
|
|
preBuild.dependsOn myPreBuild
|
|
|
|
|
|
|
|
task mkXml(type: Exec) {
|
|
|
|
workingDir '../'
|
|
|
|
commandLine './scripts/mk_xml.py', '-o',
|
|
|
|
"app/src/main/java/org/eehouse/android/xw4/loc/LocIDsData.java",
|
|
|
|
'-t', "debug"
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
VARIANTS.each { VARIANT ->
|
|
|
|
String variantCaps = VARIANT.capitalize()
|
|
|
|
BUILDS.each { BUILD ->
|
|
|
|
String nameLC = BUILD.toLowerCase()
|
2017-01-19 17:10:16 +01:00
|
|
|
String lib = "libs-${nameLC}-${VARIANT}"
|
|
|
|
String ndkBuildTask = "ndkBuild${variantCaps}${BUILD}"
|
|
|
|
task "$ndkBuildTask"(type: Exec) {
|
2017-01-18 16:01:25 +01:00
|
|
|
workingDir '../'
|
|
|
|
commandLine './scripts/ndkbuild.sh', '-j3',
|
|
|
|
"BUILD_TARGET=${nameLC}", "INITIAL_CLIENT_VERS=$INITIAL_CLIENT_VERS",
|
2017-01-19 17:10:16 +01:00
|
|
|
"VARIANT=$VARIANT", "NDK_LIBS_OUT=${lib}", "NDK_OUT=./obj-${nameLC}-${VARIANT}"
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
String compileTask = "compile${variantCaps}${BUILD}Ndk"
|
2017-01-19 17:10:16 +01:00
|
|
|
tasks.getByName(compileTask).dependsOn ndkBuildTask
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-23 15:37:31 +02:00
|
|
|
String copyStringsTask = "copyStringsXw4D"
|
2017-01-18 16:01:25 +01:00
|
|
|
task "$copyStringsTask"(type: Exec) {
|
|
|
|
workingDir './'
|
|
|
|
environment.put('APPNAME', 'CrossDbg')
|
|
|
|
commandLine 'make', '-f', '../scripts/Variant.mk',
|
2017-05-23 15:37:31 +02:00
|
|
|
"src/xw4d/res/values/strings.xml"
|
2017-01-18 16:01:25 +01:00
|
|
|
}
|
|
|
|
preBuild.dependsOn copyStringsTask
|
|
|
|
}
|
|
|
|
|
2017-01-19 17:10:16 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-01-18 16:01:25 +01:00
|
|
|
// def getVersionName() {
|
|
|
|
// try {
|
|
|
|
// def stdout = new ByteArrayOutputStream()
|
|
|
|
// exec {
|
|
|
|
// commandLine 'git', 'describe', '--dirty'
|
|
|
|
// standardOutput = stdout
|
|
|
|
// }
|
|
|
|
// return stdout.toString().trim()
|
|
|
|
// }
|
|
|
|
// catch (ignored) {
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// def renameArtifact(variant) {
|
|
|
|
// variant.outputs.each { output ->
|
|
|
|
// def name = String.format( "XWords4-%s-%s.apk", variant.name,
|
|
|
|
// getVersionName() )
|
|
|
|
// output.outputFile = new File( (String)output.outputFile.parent,
|
|
|
|
// (String)name )
|
|
|
|
// }
|
|
|
|
// }
|