Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
195 lines (175 sloc) 6.38 KB
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion VCMI_COMPILE_SDK
buildToolsVersion VCMI_BUILD_TOOLS
signingConfigs {
releaseSigning
LoadSigningConfig(PROJECT_PATH_BASE)
}
defaultConfig {
applicationId "is.xyz.vcmi"
minSdkVersion VCMI_PLATFORM
targetSdkVersion VCMI_COMPILE_SDK
versionCode Integer.parseInt(APP_VERSION_CODE)
versionName APP_VERSION
setProperty("archivesBaseName", "vcmi")
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=${VCMI_STL_VERSION}",
"-DANDROID_NATIVE_API_LEVEL=${VCMI_PLATFORM}",
"-DANDROID_TOOLCHAIN=clang",
"-DVCMI_ROOT=${PROJECT_PATH_BASE}"
cppFlags "-std=c++11", "-frtti", "-fexceptions", "-Wno-switch"
}
}
ndk {
abiFilters = new HashSet<>()
abiFilters.addAll(VCMI_ABIS)
}
}
externalNativeBuild {
cmake {
path 'cmake-scripts/CMakeLists.txt'
}
}
sourceSets {
main {
jniLibs.srcDirs = ["${PROJECT_PATH_BASE}/ext-output"]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
vcmiOnly {
externalNativeBuild {
cmake {
targets "vcmi",
"vcmiserver",
"vcmiclient"
}
}
}
libsOnly {
externalNativeBuild {
cmake {
targets "boost-datetime",
"boost-system",
"boost-filesystem",
"boost-locale",
"boost-program-options",
"boost-thread",
"fl-shared",
"minizip"
}
}
}
allTargets {
externalNativeBuild {
cmake {
targets "boost-datetime",
"boost-system",
"boost-filesystem",
"boost-locale",
"boost-program-options",
"boost-thread",
"fl-shared",
"minizip",
"vcmi",
"vcmiserver",
"vcmiclient"
}
}
}
}
buildTypes {
release {
signingConfig signingConfigs.releaseSigning
}
}
applicationVariants.all { final variant -> RenameOutput(project.archivesBaseName, variant) }
}
def RenameOutput(final baseName, final variant) {
final def apkPath = variant.outputs[0].outputFile.parent
final def travisId = System.getenv("TRAVIS_JOB_ID")
ResolveGitInfo()
def name = baseName + "-" + ext.gitInfoLauncher + "-" + ext.gitInfoVcmi
if (travisId != null && !travisId.isEmpty()) {
name = travisId + "-" + name
}
if (!variant.buildType.name != "release") {
name += "-" + variant.buildType.name
}
variant.outputs*.outputFile = new File(apkPath, name + ".apk")
}
def CommandOutput(final cmd, final arguments, final cwd) {
try {
new ByteArrayOutputStream().withStream { final os ->
exec {
executable cmd
args arguments
workingDir cwd
standardOutput os
}
return os.toString().trim()
}
}
catch (final Exception ex) {
print("Broken: " + cmd + " " + arguments + " in " + cwd + " :: " + ex.toString())
return ""
}
}
def ResolveGitInfo() {
if (ext.gitInfoLauncher != "none" && ext.gitInfoVcmi != "none") {
return
}
ext.gitInfoLauncher = CommandOutput("git", ["describe", "--match=", "--always", "--abbrev=7"], PROJECT_PATH_BASE)
ext.gitInfoVcmi =
CommandOutput("git", ["rev-parse", "--abbrev-ref", "HEAD"], PROJECT_PATH_BASE + "/ext/vcmi").replaceAll("[^a-zA-Z0-9\\-_]", "_") +
"-" +
CommandOutput("git", ["describe", "--match=", "--always", "--abbrev=7"], PROJECT_PATH_BASE + "/ext/vcmi")
}
def SigningPropertiesPath(final basePath) {
final def travis = System.getenv("TRAVIS")
if (travis != null && !travis.isEmpty()) {
return file(basePath + "/CI/signing.properties")
}
return file(basePath + "/../signing.properties")
}
def SigningKeystorePath(final basePath, final keystoreFileName) {
final def travis = System.getenv("TRAVIS")
if (travis != null && !travis.isEmpty()) {
return file(basePath + "/CI/" + keystoreFileName)
}
return file(basePath + "/../" + keystoreFileName)
}
def LoadSigningConfig(final basePath) {
final def props = new Properties()
final def propFile = SigningPropertiesPath(basePath)
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null
&& props.containsKey('STORE_FILE')
&& props.containsKey('STORE_PASSWORD')
&& props.containsKey('KEY_ALIAS')
&& props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.releaseSigning.storeFile = SigningKeystorePath(basePath, props['STORE_FILE'])
android.signingConfigs.releaseSigning.storePassword = props['STORE_PASSWORD']
android.signingConfigs.releaseSigning.keyAlias = props['KEY_ALIAS']
android.signingConfigs.releaseSigning.keyPassword = props['KEY_PASSWORD']
} else {
println("Some props from signing file are missing")
android.buildTypes.release.signingConfig = null
}
} else {
println("file with signing properties is missing")
android.buildTypes.release.signingConfig = null
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.annimon:stream:1.1.4'
}