mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
066c4a90bf
Invitations will now only allow opening the game (Dbg or not) that created them. Should prevent bogus warnings that games have been deleted. Impacts only developers and friends running CrossDbg and CrossWords on the same device. Can still get games going between the two using room names or invite-by-devid.
400 lines
14 KiB
Groovy
400 lines
14 KiB
Groovy
def INITIAL_CLIENT_VERS = 10
|
|
def VERSION_CODE_BASE = 162
|
|
def VERSION_NAME = '4.4.166'
|
|
def BUILD_INFO_NAME = "build-info.txt"
|
|
|
|
// Not all variants use the same BT_UUID. Those with the same talk to
|
|
// each other
|
|
def XW_UUID = '"7be0d084-ff89-4d6d-9c78-594773a6f963"' // from comms.h
|
|
def XWD_UUID = '"b079b640-35fe-11e5-a432-0002a5d5c51b"' // from comms.h
|
|
|
|
// AID must start with F (first 4 bits) and be 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'
|
|
|
|
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
}
|
|
|
|
android {
|
|
// Specify buildToolsVersion so gradle will inform when the
|
|
// default changes and .travis.yml can be kept in sync
|
|
buildToolsVersion '28.0.3'
|
|
ndkVersion '21.3.6528147'
|
|
defaultConfig {
|
|
// HostApduService requires 19. But is it a problem?
|
|
minSdkVersion 14
|
|
targetSdkVersion 29 // 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\""
|
|
|
|
// 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", "JNI_LIB_NAME", "\"xwjni\""
|
|
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 "String", "KEY_FCMID", "\"FBMService_fcmid\""
|
|
buildConfigField "boolean", "ATTACH_SUPPORTED", "false"
|
|
buildConfigField "boolean", "OFFER_MQTT", "true"
|
|
buildConfigField "boolean", "NON_RELEASE", "DEBUG || !IS_TAGGED_BUILD"
|
|
}
|
|
|
|
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 "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"
|
|
externalNativeBuild.ndkBuild.cFlags += ['-DVARIANT_xw4NoSMS']
|
|
externalNativeBuild.ndkBuild.arguments += ['XW_BT_UUID=' + XW_UUID]
|
|
}
|
|
|
|
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 "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"
|
|
externalNativeBuild.ndkBuild.cFlags += ['-DVARIANT_xw4fdroid']
|
|
externalNativeBuild.ndkBuild.arguments += ['XW_BT_UUID=' + XW_UUID]
|
|
}
|
|
|
|
xw4d {
|
|
dimension "variant"
|
|
buildConfigField "String", "DB_NAME", "\"xwddb\""
|
|
applicationId "org.eehouse.android.xw4dbg"
|
|
resValue "string", "app_name", "CrossDbg"
|
|
resValue "string", "nbs_port", "3345"
|
|
resValue "string", "invite_prefix", "/andd/"
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "true"
|
|
buildConfigField "String", "VARIANT_NAME", "\"Dev/Debug\""
|
|
buildConfigField "int", "VARIANT_CODE", "3"
|
|
buildConfigField "boolean", "REPORT_LOCKS", "true"
|
|
buildConfigField "String", "KEY_FCMID", "\"FBMService_fcmid1\""
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4d}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4d"
|
|
externalNativeBuild.ndkBuild.cFlags += ['-DVARIANT_xw4d']
|
|
externalNativeBuild.ndkBuild.arguments += ['XW_BT_UUID=' + XWD_UUID]
|
|
}
|
|
|
|
xw4dNoSMS {
|
|
dimension "variant"
|
|
applicationId "org.eehouse.android.xw4dbg"
|
|
buildConfigField "String", "DB_NAME", "\"xwddb\""
|
|
resValue "string", "app_name", "CrossDbg"
|
|
resValue "string", "nbs_port", "3345"
|
|
resValue "string", "invite_prefix", "/andd/"
|
|
buildConfigField "boolean", "WIDIR_ENABLED", "true"
|
|
buildConfigField "String", "VARIANT_NAME", "\"Dev/Debug NoSMS\""
|
|
buildConfigField "int", "VARIANT_CODE", "4"
|
|
buildConfigField "boolean", "REPORT_LOCKS", "true"
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4d}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4d"
|
|
externalNativeBuild.ndkBuild.cFlags += ['-DVARIANT_xw4dNoSMS']
|
|
externalNativeBuild.ndkBuild.arguments += ['XW_BT_UUID=' + XWD_UUID]
|
|
}
|
|
|
|
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 "String", "VARIANT_NAME", "\"FOSS\""
|
|
buildConfigField "int", "VARIANT_CODE", "5"
|
|
buildConfigField "String", "NFC_AID", "\"${NFC_AID_XW4}\""
|
|
resValue "string", "nfc_aid", "$NFC_AID_XW4"
|
|
externalNativeBuild.ndkBuild.cFlags += ['-DVARIANT_xw4SMS']
|
|
externalNativeBuild.ndkBuild.arguments += ['XW_BT_UUID=' + XW_UUID]
|
|
}
|
|
|
|
// 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 {
|
|
all {
|
|
externalNativeBuild {
|
|
ndkBuild.arguments += ["INITIAL_CLIENT_VERS=" + INITIAL_CLIENT_VERS]
|
|
}
|
|
}
|
|
|
|
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"
|
|
externalNativeBuild {
|
|
ndkBuild.arguments += ['BUILD_TARGET=release']
|
|
}
|
|
ndk {
|
|
abiFilters 'armeabi-v7a', 'arm64-v8a'
|
|
}
|
|
}
|
|
debug {
|
|
debuggable true
|
|
resValue "bool", "DEBUG", "true"
|
|
// Drop this. Takes too long to build
|
|
// minifyEnabled true // for testing
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
// This doesn't work on marshmallow: duplicate permission error
|
|
// applicationIdSuffix ".debug"
|
|
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
cFlags += ['-DDEBUG']
|
|
arguments += ['BUILD_TARGET=debug']
|
|
}
|
|
}
|
|
|
|
ndk {
|
|
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
|
}
|
|
}
|
|
}
|
|
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
path "../jni/Android.mk"
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
|
implementation 'androidx.core:core:1.0.0'
|
|
|
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
|
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.0.0'
|
|
|
|
|
|
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'
|
|
|
|
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.+"
|
|
}
|
|
|
|
task mkImages(type: Exec) {
|
|
workingDir '../'
|
|
commandLine './scripts/mkimages.sh'
|
|
}
|
|
|
|
task copyLocStrings(type: Exec) {
|
|
workingDir '../'
|
|
commandLine 'make', '-f', './scripts/copy-strings.mk'
|
|
}
|
|
|
|
task cleanLocStrings(type: Exec) {
|
|
workingDir '../'
|
|
commandLine 'make', '-f', './scripts/copy-strings.mk', 'clean'
|
|
}
|
|
clean.dependsOn cleanLocStrings
|
|
|
|
task myPreBuild(dependsOn: ['mkImages',
|
|
'copyLocStrings',
|
|
'mkXml',
|
|
'copyStringsXw4D',
|
|
'copyStringsXw4DNoSMS']) {
|
|
}
|
|
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"
|
|
}
|
|
|
|
task copyStringsXw4D(type: Exec) {
|
|
workingDir './'
|
|
environment.put('APPNAME', 'CrossDbg')
|
|
commandLine 'make', '-f', '../scripts/Variant.mk',
|
|
"src/xw4d/res/values/strings.xml"
|
|
}
|
|
|
|
task copyStringsXw4DNoSMS(type: Exec) {
|
|
workingDir './'
|
|
environment.put('APPNAME', 'CrossDbg')
|
|
commandLine 'make', '-f', '../scripts/Variant.mk',
|
|
"src/xw4dNoSMS/res/values/strings.xml"
|
|
}
|
|
|
|
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
|