mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-24 07:58:34 +01:00
0153928bcd
Use low-level NFC, a combination of emulated card and reader mode, to work around Google's removal of "beaming" support from Android 10. App emulates a card by declaring support in its AndroidManifest. When a game is open that has data to send, it goes periodically into read mode. If two devices are touched while one is in read mode and the other isn't, they handshake and open a connection that should last until they're separated. The devices loop, sending messages back and forth with or without data (as available.)
422 lines
16 KiB
Groovy
422 lines
16 KiB
Groovy
def INITIAL_CLIENT_VERS = 9
|
|
def VERSION_CODE_BASE = 146
|
|
def VERSION_NAME = '4.4.150'
|
|
def FABRIC_API_KEY = System.getenv("FABRIC_API_KEY")
|
|
def BUILD_INFO_NAME = "build-info.txt"
|
|
|
|
// AID must start with F (first 4 bits) and be at from 5 to 16 bytes long
|
|
def NFC_AID_XW4 = "FC8FF510B360"
|
|
def NFC_AID_XW4d = "FDDA0A3EB5E5"
|
|
|
|
boolean forFDroid = hasProperty('forFDroid')
|
|
|
|
// Get the git revision we're using. Since fdroid modifies files as
|
|
// part of its build process -dirty will always be added, confusing
|
|
// users. So add that for the non-fdroid case.
|
|
def GITREV = "git describe --tags"
|
|
if (! forFDroid) {
|
|
GITREV += " --dirty"
|
|
}
|
|
GITREV = GITREV.execute().text.trim()
|
|
|
|
// Make CURTAG non-empty IFF we're at a tag (release build)
|
|
def CURTAG = "git describe --exact-match".execute().text.trim()
|
|
// print "CURTAG: " + CURTAG + "\n"
|
|
|
|
apply plugin: 'com.android.application'
|
|
|
|
|
|
if ( FABRIC_API_KEY && hasProperty('useCrashlytics') ) { // rm-for-fdroid
|
|
apply plugin: 'io.fabric' // rm-for-fdroid
|
|
} // rm-for-fdroid
|
|
repositories {
|
|
google()
|
|
maven { url 'https://maven.fabric.io/public' } // rm-for-fdroid
|
|
}
|
|
|
|
android {
|
|
// Specify buildToolsVersion so gradle will inform when the
|
|
// default changes and .travis.yml can be kept in sync
|
|
buildToolsVersion '27.0.3'
|
|
defaultConfig {
|
|
// HostApduService requires 19. But is it a problem?
|
|
minSdkVersion 14
|
|
targetSdkVersion 28 // must match ../build.gradle
|
|
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\""
|
|
variant.buildConfigField "String", "FABRIC_API_KEY", "\"$FABRIC_API_KEY\""
|
|
|
|
// We need both of these because xwprefs.xml can't reference
|
|
// the BuildConfig constant
|
|
resValue "string", "git_rev", "$GITREV"
|
|
variant.buildConfigField "String", "GIT_REV", "\"$GITREV\""
|
|
|
|
// 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\""
|
|
|
|
variant.buildConfigField "short", "CLIENT_VERS_RELAY", "$INITIAL_CLIENT_VERS"
|
|
|
|
variant.buildConfigField "boolean", "FOR_FDROID", "$forFDroid"
|
|
}
|
|
|
|
flavorDimensions "variant"//, "abi"
|
|
productFlavors {
|
|
all {
|
|
buildConfigField "String", "DB_NAME", "\"xwdb\""
|
|
buildConfigField "String", "BUILD_INFO_NAME", "\"${BUILD_INFO_NAME}\""
|
|
buildConfigField "boolean", "IS_TAGGED_BUILD", "${CURTAG}" == '' ? "false" : "true"
|
|
resValue "string", "invite_prefix", "/and/"
|
|
buildConfigField "boolean", "UDP_ENABLED", "true"
|
|
buildConfigField "boolean", "REPORT_LOCKS", "false"
|
|
buildConfigField "boolean", "LOG_LIFECYLE", "false"
|
|
buildConfigField "boolean", "MOVE_VIA_NFC", "false"
|
|
buildConfigField "boolean", "ATTACH_SUPPORTED", "false"
|
|
}
|
|
|
|
xw4NoSMS {
|
|
dimension "variant"
|
|
applicationId "org.eehouse.android.xw4"
|
|
manifestPlaceholders = [ APP_ID: applicationId ]
|
|
resValue "string", "app_name", "CrossWords"
|
|
resValue "string", "nbs_port", "3344"
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
|
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "false"
|
|
buildConfigField "String", "VARIANT_NAME", "\"Google Play Store\""
|
|
buildConfigField "int", "VARIANT_CODE", "1"
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4"
|
|
}
|
|
|
|
xw4fdroid {
|
|
dimension "variant"
|
|
applicationId "org.eehouse.android.xw4"
|
|
manifestPlaceholders = [ APP_ID: applicationId ]
|
|
resValue "string", "app_name", "CrossWords"
|
|
resValue "string", "nbs_port", "3344"
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
|
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "false"
|
|
buildConfigField "String", "VARIANT_NAME", "\"F-Droid\""
|
|
buildConfigField "int", "VARIANT_CODE", "2"
|
|
buildConfigField "boolean", "FOR_FDROID", "true"
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4"
|
|
}
|
|
xw4d {
|
|
dimension "variant"
|
|
buildConfigField "String", "DB_NAME", "\"xwddb\""
|
|
applicationId "org.eehouse.android.xw4dbg"
|
|
manifestPlaceholders = [ FABRIC_API_KEY: "$FABRIC_API_KEY", APP_ID: applicationId, ]
|
|
resValue "string", "app_name", "CrossDbg"
|
|
resValue "string", "nbs_port", "3345"
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "true"
|
|
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "true"
|
|
buildConfigField "String", "VARIANT_NAME", "\"Dev/Debug\""
|
|
buildConfigField "int", "VARIANT_CODE", "3"
|
|
buildConfigField "boolean", "REPORT_LOCKS", "true"
|
|
buildConfigField "boolean", "MOVE_VIA_NFC", "true"
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4d}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4d"
|
|
}
|
|
|
|
xw4dNoSMS {
|
|
dimension "variant"
|
|
buildConfigField "String", "DB_NAME", "\"xwddb\""
|
|
applicationId "org.eehouse.android.xw4dbg"
|
|
manifestPlaceholders = [ FABRIC_API_KEY: "$FABRIC_API_KEY", APP_ID: applicationId, ]
|
|
resValue "string", "app_name", "CrossDbg"
|
|
resValue "string", "nbs_port", "3345"
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "true"
|
|
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "true"
|
|
buildConfigField "String", "VARIANT_NAME", "\"Dev/Debug NoSMS\""
|
|
buildConfigField "int", "VARIANT_CODE", "4"
|
|
buildConfigField "boolean", "REPORT_LOCKS", "true"
|
|
buildConfigField "boolean", "MOVE_VIA_NFC", "true"
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4d}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4d"
|
|
}
|
|
|
|
xw4SMS {
|
|
dimension "variant"
|
|
applicationId "org.eehouse.android.xw4"
|
|
manifestPlaceholders = [ APP_ID: applicationId ]
|
|
resValue "string", "app_name", "CrossWords"
|
|
resValue "string", "nbs_port", "3344"
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
|
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "false"
|
|
buildConfigField "String", "VARIANT_NAME", "\"FOSS\""
|
|
buildConfigField "int", "VARIANT_CODE", "5"
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4"
|
|
}
|
|
|
|
// 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 {
|
|
debug {
|
|
def path = System.getenv("DEBUG_KEYSTORE_PATH")
|
|
if (! path) {
|
|
path = "./debug.keystore"
|
|
}
|
|
storeFile file(path)
|
|
keyAlias "androiddebugkey"
|
|
storePassword "android"
|
|
keyPassword "android"
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
debuggable false
|
|
minifyEnabled false // PENDING
|
|
// proguard crashes when I do this (the optimize part)
|
|
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
resValue "bool", "DEBUG", "false"
|
|
}
|
|
debug {
|
|
debuggable true
|
|
resValue "bool", "DEBUG", "true"
|
|
minifyEnabled true // for testing
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
// 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.
|
|
xw4NoSMS {
|
|
release {
|
|
jniLibs.srcDir "../libs-xw4NoSMSRelease"
|
|
}
|
|
debug {
|
|
jniLibs.srcDir "../libs-xw4NoSMSDebug"
|
|
}
|
|
}
|
|
xw4d {
|
|
release {
|
|
jniLibs.srcDir "../libs-xw4dRelease"
|
|
}
|
|
debug {
|
|
jniLibs.srcDir "../libs-xw4dDebug"
|
|
}
|
|
}
|
|
xw4dNoSMS {
|
|
release {
|
|
jniLibs.srcDir "../libs-xw4dNoSMSRelease"
|
|
}
|
|
debug {
|
|
jniLibs.srcDir "../libs-xw4dNoSMSDebug"
|
|
}
|
|
}
|
|
xw4SMS {
|
|
release {
|
|
jniLibs.srcDir "../libs-xw4SMSRelease"
|
|
}
|
|
debug {
|
|
jniLibs.srcDir "../libs-xw4SMSDebug"
|
|
}
|
|
}
|
|
xw4fdroid {
|
|
release {
|
|
jniLibs.srcDir "../libs-xw4fdroidRelease"
|
|
}
|
|
debug {
|
|
jniLibs.srcDir "../libs-xw4fdroidDebug"
|
|
}
|
|
}
|
|
}
|
|
|
|
lintOptions {
|
|
abortOnError false
|
|
}
|
|
|
|
applicationVariants.all { variant ->
|
|
variant.outputs.each { output ->
|
|
def newName = output.outputFile.name
|
|
newName = newName.replace(".apk","-${GITREV}.apk")
|
|
newName = newName.replace("app-","")
|
|
output.outputFileName = newName
|
|
}
|
|
}
|
|
}
|
|
|
|
ext {
|
|
SUPPORT_LIB_VERSION = '28.0.0'
|
|
}
|
|
|
|
dependencies {
|
|
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
|
|
implementation "com.android.support:support-compat:$SUPPORT_LIB_VERSION"
|
|
|
|
implementation "android.arch.lifecycle:extensions:1.1.1"
|
|
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
|
|
|
|
// 2.6.8 is probably as far forward as I can go without upping my
|
|
// min-supported SDK version
|
|
xw4dImplementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') { // rm-for-fdroid
|
|
transitive = true // rm-for-fdroid
|
|
} // rm-for-fdroid
|
|
xw4dNoSMSImplementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') { // rm-for-fdroid
|
|
transitive = true // rm-for-fdroid
|
|
} // rm-for-fdroid
|
|
|
|
implementation 'com.google.firebase:firebase-messaging:17.3.4' // rm-for-fdroid
|
|
implementation 'com.google.firebase:firebase-core:16.0.6' // rm-for-fdroid
|
|
|
|
implementation 'com.github.eehouse:nbsproxy:v0.2.2'
|
|
}
|
|
|
|
task mkImages(type: Exec) {
|
|
workingDir '../'
|
|
commandLine './scripts/mkimages.sh'
|
|
}
|
|
|
|
task copyStrings(type: Exec) {
|
|
workingDir '../'
|
|
commandLine './scripts/copy-strings.py'
|
|
}
|
|
|
|
task ndkSetupDebug(type: Exec) {
|
|
workingDir '../'
|
|
// remove ', "--arm-only"' for Genymotion builds
|
|
|
|
// I'm putting ARM back for a while. It's too much trouble having
|
|
// builds, including those built by travis, that don't run on the
|
|
// emulator. Maybe remove this change before each release?
|
|
commandLine "./scripts/ndksetup.sh", "--with-clang"
|
|
// commandLine "./scripts/ndksetup.sh", "--with-clang", "--arm-only"
|
|
}
|
|
|
|
task ndkSetupRelease(type: Exec) {
|
|
workingDir '../'
|
|
commandLine "./scripts/ndksetup.sh", "--with-clang", "--arm-only"
|
|
}
|
|
|
|
task myPreBuild(dependsOn: ['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 {
|
|
ArrayList<String> cleanCmdLst = new ArrayList<>(["rm", "-rf"])
|
|
android.applicationVariants.all { variant ->
|
|
// print "variant: " + variant.name + "\n"
|
|
String BUILD = variant.getBuildType().getName()
|
|
// println "type: " + BUILD
|
|
String FLAVOR = variant.getFlavorName()
|
|
// print "flavor: " + variant.getFlavorName() + "\n"
|
|
// print "variant: " + variant + "\n"
|
|
|
|
String ndkSetup = "ndkSetup" + BUILD.capitalize()
|
|
// println "ndkSetup: " + ndkSetup
|
|
|
|
String variantCaps = variant.name.capitalize()
|
|
String nameLC = variant.getBuildType().getName().toLowerCase()
|
|
String lib = "libs-${variant.name}"
|
|
String ndkBuildTask = "ndkBuild${variantCaps}"
|
|
task "$ndkBuildTask"(type: Exec) {
|
|
workingDir '../'
|
|
commandLine './scripts/ndkbuild.sh', '-j3',
|
|
"BUILD_TARGET=${nameLC}", "INITIAL_CLIENT_VERS=$INITIAL_CLIENT_VERS",
|
|
"VARIANT=${FLAVOR}", "NDK_LIBS_OUT=${lib}",
|
|
"NDK_OUT=./obj-${variant.name}"
|
|
}
|
|
|
|
String compileTask = "compile${variantCaps}Ndk"
|
|
tasks.getByName(ndkBuildTask).dependsOn ndkSetup
|
|
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"
|
|
task "$copyStringsTask"(type: Exec) {
|
|
workingDir './'
|
|
environment.put('APPNAME', 'CrossDbg')
|
|
commandLine 'make', '-f', '../scripts/Variant.mk',
|
|
"src/xw4d/res/values/strings.xml"
|
|
}
|
|
preBuild.dependsOn copyStringsTask
|
|
|
|
String copyStringsTaskNoSMS = "copyStringsXw4DNoSMS"
|
|
task "$copyStringsTaskNoSMS"(type: Exec) {
|
|
workingDir './'
|
|
environment.put('APPNAME', 'CrossDbg')
|
|
commandLine 'make', '-f', '../scripts/Variant.mk',
|
|
"src/xw4dNoSMS/res/values/strings.xml"
|
|
}
|
|
preBuild.dependsOn copyStringsTaskNoSMS
|
|
}
|
|
|
|
task makeBuildAssets() {
|
|
def assetsDir = android.sourceSets.main.assets.srcDirs.toArray()[0]
|
|
String path = new File(assetsDir, BUILD_INFO_NAME).getAbsolutePath()
|
|
String out = "git_describe: ${GITREV}\n"
|
|
|
|
String HEAD = "git rev-parse HEAD".execute().text.trim()
|
|
out += "HEAD: ${HEAD}\n"
|
|
|
|
String date = "date".execute().text.trim()
|
|
out += "date: ${date}\n"
|
|
|
|
// I want the variant, but that's harder. Here's a quick hack from SO.
|
|
// String target = gradle.startParameter.taskNames[0]
|
|
// out += "target: ${target}\n"
|
|
|
|
String diff = "git diff".execute().text.trim()
|
|
if (diff) {
|
|
out += "\n" + diff
|
|
}
|
|
new File(path).write(out)
|
|
}
|
|
|
|
gradle.projectsEvaluated {
|
|
build.dependsOn(makeBuildAssets)
|
|
}
|
|
|
|
apply plugin: 'com.google.gms.google-services' // rm-for-fdroid
|