From 5d8ce70ff7b476b2cf7438e97af10f8ebb108a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Fri, 1 Nov 2019 17:59:38 +0100 Subject: [PATCH] Grep Android Version from CMake --- android/.gitignore | 2 ++ android/app/build.gradle | 20 +++++++++++++++++--- android/app/proguard-rules.pro | 2 ++ android/build.gradle | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/android/.gitignore b/android/.gitignore index 603b140..a0bf76f 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -12,3 +12,5 @@ /captures .externalNativeBuild .cxx +/app/release +keystore.jks diff --git a/android/app/build.gradle b/android/app/build.gradle index 9af2a5b..189438b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -3,6 +3,20 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' +def rootCMakeLists = "../../CMakeLists.txt" +def rootCMakeListsContent = file(rootCMakeLists).text +static def grepVersionComponent(content, varname) { + def match = content =~ /set\($varname ([0-9]+)\)/ + if(!match.find()) + throw new GradleException("Failed to find $varname in CMakeLists.txt") + return match.group(1) +} +def chiakiVersionMajor = grepVersionComponent(rootCMakeListsContent, "CHIAKI_VERSION_MAJOR") +def chiakiVersionMinor = grepVersionComponent(rootCMakeListsContent, "CHIAKI_VERSION_MINOR") +def chiakiVersionPatch = grepVersionComponent(rootCMakeListsContent, "CHIAKI_VERSION_PATCH") +def chiakiVersion = "$chiakiVersionMajor.$chiakiVersionMinor.$chiakiVersionPatch" +println("Determined Chiaki Version: $chiakiVersion") + android { compileSdkVersion 29 buildToolsVersion "29.0.2" @@ -11,7 +25,7 @@ android { minSdkVersion 21 targetSdkVersion 29 versionCode 1 - versionName "1.0" + versionName chiakiVersion externalNativeBuild { cmake { arguments "-DCHIAKI_ENABLE_TESTS=OFF", @@ -26,12 +40,12 @@ android { externalNativeBuild { cmake { version "3.10.2+" - path "../../CMakeLists.txt" + path rootCMakeLists } } buildTypes { release { - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index f1b4245..f5fb65b 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -19,3 +19,5 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +-dontobfuscate \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index df8fe1b..e3245e7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { google() jcenter()