From c83bde135315e636031e0de729eaee7f295fca92 Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Wed, 11 Nov 2015 15:11:13 +0300 Subject: [PATCH 1/6] [android] Added tasks to generate obb-s to gradle script. --- android/build.gradle | 87 ++++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 77c6dfc419..76bfde4025 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -47,6 +47,8 @@ def getDate() { return formattedDate } +project.ext.versionCodes = ['armeabi-v7a':1, 'x86':2] + android { // All properties are read from gradle.properties file compileSdkVersion propTargetSdkVersion.toInteger() @@ -176,13 +178,11 @@ android { // Currently (as of 1.2.3 gradle plugin) ABI filters aren't supported inside of product flavors, so we cannot generate splitted builds only for Google build. // TODO check that feature when new gradle plugins will appear // connected bugreport https://code.google.com/p/android/issues/detail?id=178606 - splits { - abi { - enable true - reset() - include 'x86', 'armeabi-v7a' - universalApk true - } + splits.abi { + enable true + reset() + include 'x86', 'armeabi-v7a' + universalApk true } // TODO: Fix a lot of lint errors in our code @@ -200,6 +200,17 @@ android { executable "sh" args "-c", "adb shell am start -n ${component}" } + + variant.outputs.each { output -> + if (output.outputFile != null && output.outputFile.name.endsWith('.apk')) { + def file = output.outputFile + // version at the end of each built apk + output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + android.defaultConfig.versionName + "-" + getDate() + ".apk")) + // set different versionCodes for different ABIs + int abiVersionCode = project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI)) ?: 0 + output.versionCodeOverride = (abiVersionCode * 1000) + android.defaultConfig.versionCode + } + } } } @@ -259,22 +270,6 @@ android { } } -import com.android.build.OutputFile -project.ext.versionCodes = ['armeabi-v7a':1, 'x86':2] - -android.applicationVariants.all { variant -> - variant.outputs.each { output -> - if (output.outputFile != null && output.outputFile.name.endsWith('.apk')) { - def file = output.outputFile - // version at the end of each built apk - output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + android.defaultConfig.versionName + "-" + getDate() + ".apk")) - // set different versionCodes for different ABIs - int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0 - output.versionCodeOverride = (abiVersionCode * 1000) + android.defaultConfig.versionCode - } - } -} - //@{ Below are tasks needed to compile our NDK part apply plugin: 'base' @@ -352,4 +347,48 @@ tasks.withType(JavaCompile) { compileTask -> } } -clean.dependsOn 'ndkBuildClean' +clean.dependsOn ndkBuildClean + +// tasks for generating obb files for Google Play +task obbClean(type: Exec) { + def obbOutput = 'build/distributions/'; + commandLine 'rm', '-rf', obbOutput +} + +def fonts = ['../data/01_dejavusans.ttf', + '../data/02_droidsans-fallback.ttf', + '../data/03_jomolhari-id-a3d.ttf', + '../data/04_padauk.ttf', + '../data/05_khmeros.ttf', + '../data/06_code2000.ttf'] +def worlds = ['../data/World.mwm', '../data/WorldCoasts.mwm'] + +task obbGenerate() { + createObbGenerateTask('Main', fonts, 'fonts') + createObbGenerateTask('Patch', worlds, 'worlds') + + createObbAlignTask('Main', 'build/distributions/fonts.obb', 'build/distributions/fonts_aligned.obb') + createObbAlignTask('Patch','build/distributions/worlds.obb','build/distributions/worlds_aligned.obb') +} + +obbGenerate.dependsOn obbClean, obbMainGenerate, obbPatchGenerate, obbMainAlign, obbPatchAlign + +def createObbGenerateTask(type, data, name) { + return tasks.create(name: "obb${type}Generate", type: Zip, description: 'Generate obb files') { + from data + into 'build' + baseName name + extension 'obb' + entryCompression ZipEntryCompression.STORED + } +} + +def createObbAlignTask(type, rawObb, alignedObb) { + def sdkDir = "${android.getSdkDirectory().getAbsolutePath()}" + def zipalignPath = sdkDir + File.separator + "build-tools" + File.separator + + propBuildToolsVersion + File.separator + "zipalign"; + + return tasks.create(name: "obb${type}Align", dependsOn: "obb${type}Generate", type: Exec, description: 'Align obb files') { + commandLine zipalignPath, '-v', '8', rawObb, alignedObb + } +} \ No newline at end of file From 861af8c90e493829280a43a587c95d2f86615e3e Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Wed, 11 Nov 2015 15:14:41 +0300 Subject: [PATCH 2/6] [android] Removed obsolete bash scripts for obb creation. --- tools/android/obb_make.sh | 3 --- tools/android/obb_make_and_push.sh | 8 -------- 2 files changed, 11 deletions(-) delete mode 100755 tools/android/obb_make.sh delete mode 100755 tools/android/obb_make_and_push.sh diff --git a/tools/android/obb_make.sh b/tools/android/obb_make.sh deleted file mode 100755 index 2537c71f19..0000000000 --- a/tools/android/obb_make.sh +++ /dev/null @@ -1,3 +0,0 @@ -cd ../../data -zip -0 ../tools/android/fonts.obb 01_dejavusans.ttf 02_droidsans-fallback.ttf 03_jomolhari-id-a3d.ttf 04_padauk.ttf 05_khmeros.ttf 06_code2000.ttf -zip -0 ../tools/android/world.obb World.mwm WorldCoasts.mwm diff --git a/tools/android/obb_make_and_push.sh b/tools/android/obb_make_and_push.sh deleted file mode 100755 index 7dcf790d07..0000000000 --- a/tools/android/obb_make_and_push.sh +++ /dev/null @@ -1,8 +0,0 @@ -./obb_make.sh - -adb shell "mkdir /mnt/sdcard/Android/obb/com.mapswithme.maps.pro" -adb push fonts.obb /mnt/sdcard/Android/obb/com.mapswithme.maps.pro/fonts.obb -adb push world.obb /mnt/sdcard/Android/obb/com.mapswithme.maps.pro/world.obb - -rm fonts.obb -rm world.obb From b12d449db78c2f87a15d3f1d7e364be33486c07b Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Wed, 11 Nov 2015 17:11:37 +0300 Subject: [PATCH 3/6] [android] Refactored duplicating gradle tasks for native libs assembling. --- android/build.gradle | 93 ++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 60 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 76bfde4025..f8b96c223c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -47,7 +47,7 @@ def getDate() { return formattedDate } -project.ext.versionCodes = ['armeabi-v7a':1, 'x86':2] +project.ext.versionCodes = ['armeabi-v7a': 1, 'x86': 2] android { // All properties are read from gradle.properties file @@ -270,73 +270,46 @@ android { } } -//@{ Below are tasks needed to compile our NDK part +// Tasks needed to compile NDK part apply plugin: 'base' -task cppLibsBuildDebug(type: Exec, description: 'Building DEBUG version of static C++ libraries') { - commandLine 'bash', '../tools/autobuild/android.sh', 'debug' -} - -task cppLibsBuildDebugArm(type: Exec, description: 'Building DEBUG version of static C++ libraries (ARM only)') { - commandLine 'bash', '../tools/autobuild/android.sh', 'debug', 'armeabi-v7a-hard' -} - -task cppLibsBuildDebugIntel(type: Exec, description: 'Building DEBUG version of static C++ libraries (x86 only)') { - commandLine 'bash', '../tools/autobuild/android.sh', 'debug', 'x86' -} - -task cppLibsBuildRelease(type: Exec, description: 'Building RELEASE/PRODUCTION version of static C++ libraries') { - commandLine 'bash', '../tools/autobuild/android.sh', 'production' -} - -task cppLibsBuildReleaseArm(type: Exec, description: 'Building RELEASE/PRODUCTION version of static C++ libraries (ARM only)') { - commandLine 'bash', '../tools/autobuild/android.sh', 'production', 'armeabi-v7a-hard' -} - -task cppLibsBuildReleaseIntel(type: Exec, description: 'Building RELEASE/PRODUCTION version of static C++ libraries (x86 only)') { - commandLine 'bash', '../tools/autobuild/android.sh', 'production', 'x86' -} - -def PARAM_PARALLEL_TASK_COUNT = '-j' + (Runtime.runtime.availableProcessors() + 1) -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) -def NDK_BUILD = properties.getProperty('ndk.dir') + '/ndk-build' - +project.ext.PARAM_PARALLEL_TASK_COUNT = '-j' + (Runtime.runtime.availableProcessors() + 1) +project.ext.NDK_BUILD = android.getNdkDirectory().toString() + '/ndk-build' if (System.properties['os.name'].toLowerCase().contains('windows')) - NDK_BUILD += ".cmd" + project.ext.NDK_BUILD += ".cmd" -task ndkBuildDebug(type: Exec, dependsOn: 'cppLibsBuildDebug', description: 'Building DEBUG jni sources') { - def clArgs = ([NDK_BUILD, PARAM_PARALLEL_TASK_COUNT] + propDebugNdkFlags.split(' ')).flatten() - commandLine clArgs +def archs = ['x86', 'armeabi-v7a-hard'] +def buildTypes = [[ndkType: 'release', cppType: "production", flags : propReleaseNdkFlags], [ndkType: 'debug', cppType: "debug", flags : propDebugNdkFlags]] + +buildTypes.each { type -> + def suffix = type.ndkType.capitalize() + createCppBuildTask(type.cppType, '', suffix) + createNdkBuildTask(type.ndkType, '', suffix, type.flags) + + archs.each { arch -> + suffix = type.ndkType.capitalize() + arch.capitalize() + createCppBuildTask(type.cppType, arch, suffix) + createNdkBuildTask(type.ndkType, arch, suffix, type.flags) + } } -task ndkBuildDebugArm(type: Exec, dependsOn: 'cppLibsBuildDebugArm', description: 'Building DEBUG jni sources (ARM only)') { - def clArgs = ([NDK_BUILD, PARAM_PARALLEL_TASK_COUNT, 'NDK_ABI_TO_BUILD=armeabi-v7a-hard'] + propDebugNdkFlags.split(' ')).flatten() - commandLine clArgs +def createCppBuildTask(buildType, arch, suffix) { + return tasks.create(name: "cppBuild${suffix}", type: Exec, description: "Building ${buildType} version of static C++ libraries. Arch : ${arch}") { + commandLine 'bash', '../tools/autobuild/android.sh', buildType, arch + } } -task ndkBuildDebugIntel(type: Exec, dependsOn: 'cppLibsBuildDebugIntel', description: 'Building DEBUG jni sources (x86 only)') { - def clArgs = ([NDK_BUILD, PARAM_PARALLEL_TASK_COUNT, 'NDK_ABI_TO_BUILD=x86'] + propDebugNdkFlags.split(' ')).flatten() - commandLine clArgs +def createNdkBuildTask(buildType, arch, suffix, flags) { + return tasks.create(name: "ndkBuild${suffix}", dependsOn: "cppBuild${suffix}", type: Exec, description: "Building ${buildType} version of jni. Arch : ${arch}") { + def ndkParams = ([project.ext.NDK_BUILD, project.ext.PARAM_PARALLEL_TASK_COUNT] + flags.split(' ')).flatten() + if (!arch.isEmpty()) + ndkParams += "NDK_ABI_TO_BUILD=${arch}" + commandLine ndkParams + } } -task ndkBuildRelease(type: Exec, dependsOn: 'cppLibsBuildRelease', description: 'Building RELEASE/PRODUCTION jni sources') { - def clArgs = ([NDK_BUILD, PARAM_PARALLEL_TASK_COUNT] + propReleaseNdkFlags.split(' ')).flatten() - commandLine clArgs -} - -task ndkBuildReleaseArm(type: Exec, dependsOn: 'cppLibsBuildReleaseArm', description: 'Building RELEASE/PRODUCTION jni sources (ARM only)') { - def clArgs = ([NDK_BUILD, PARAM_PARALLEL_TASK_COUNT, 'NDK_ABI_TO_BUILD=armeabi-v7a-hard'] + propReleaseNdkFlags.split(' ')).flatten() - commandLine clArgs -} - -task ndkBuildReleaseIntel(type: Exec, dependsOn: 'cppLibsBuildReleaseIntel', description: 'Building RELEASE/PRODUCTION jni sources (x86 only)') { - def clArgs = ([NDK_BUILD, PARAM_PARALLEL_TASK_COUNT, 'NDK_ABI_TO_BUILD=x86'] + propReleaseNdkFlags.split(' ')).flatten() - commandLine clArgs -} - -task ndkBuildClean(type: Exec, description: 'Clean native libraries') { - commandLine NDK_BUILD, 'clean' +task ndkBuildClean(type: Exec, description: 'Clean native jni libraries') { + commandLine project.ext.NDK_BUILD, 'clean' } tasks.withType(JavaCompile) { compileTask -> @@ -349,7 +322,7 @@ tasks.withType(JavaCompile) { compileTask -> clean.dependsOn ndkBuildClean -// tasks for generating obb files for Google Play +// Tasks for generating obb files for Google Play task obbClean(type: Exec) { def obbOutput = 'build/distributions/'; commandLine 'rm', '-rf', obbOutput @@ -368,7 +341,7 @@ task obbGenerate() { createObbGenerateTask('Patch', worlds, 'worlds') createObbAlignTask('Main', 'build/distributions/fonts.obb', 'build/distributions/fonts_aligned.obb') - createObbAlignTask('Patch','build/distributions/worlds.obb','build/distributions/worlds_aligned.obb') + createObbAlignTask('Patch', 'build/distributions/worlds.obb', 'build/distributions/worlds_aligned.obb') } obbGenerate.dependsOn obbClean, obbMainGenerate, obbPatchGenerate, obbMainAlign, obbPatchAlign From 6ca22db1b6f2cd99db7ae519ab8bbbc0fea2a102 Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Thu, 12 Nov 2015 19:48:06 +0300 Subject: [PATCH 4/6] [android] Added gradle tasks to push obb on device and to clean built native libs. Modified zip task since 'Zip' gradle task zips obbs wrongly. --- android/build.gradle | 67 +++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index f8b96c223c..8193377038 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -48,6 +48,7 @@ def getDate() { } project.ext.versionCodes = ['armeabi-v7a': 1, 'x86': 2] +project.ext.appId = 'com.mapswithme.maps.pro' android { // All properties are read from gradle.properties file @@ -60,7 +61,7 @@ android { versionName propVersionName minSdkVersion propMinSdkVersion.toInteger() targetSdkVersion propTargetSdkVersion.toInteger() - applicationId 'com.mapswithme.maps.pro' + applicationId project.ext.appId buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'int', 'RATING_THRESHOLD', '5' @@ -193,12 +194,8 @@ android { gradle.projectsEvaluated { android.applicationVariants.all { variant -> def task = variant.name.capitalize() - def runTask = "run$task" - def installTask = "install$task" - project.task(type: Exec, "${runTask}", dependsOn: "${installTask}") { - def component = "$applicationId/com.mapswithme.maps.DownloadResourcesActivity" - executable "sh" - args "-c", "adb shell am start -n ${component}" + project.task(type: Exec, "run${task}", dependsOn: "install${task}") { + commandLine android.getAdbExe(), 'shell', 'am', 'start', '-n', "${applicationId}/com.mapswithme.maps.DownloadResourcesActivity" } variant.outputs.each { output -> @@ -295,7 +292,10 @@ buildTypes.each { type -> def createCppBuildTask(buildType, arch, suffix) { return tasks.create(name: "cppBuild${suffix}", type: Exec, description: "Building ${buildType} version of static C++ libraries. Arch : ${arch}") { - commandLine 'bash', '../tools/autobuild/android.sh', buildType, arch + def args = ['bash', '../tools/autobuild/android.sh', buildType] + if (!arch.isEmpty()) + args += arch + commandLine args } } @@ -320,12 +320,21 @@ tasks.withType(JavaCompile) { compileTask -> } } +// NOTE : it does NOT clean built cpp static libs. cppClean does. clean.dependsOn ndkBuildClean +// Cleans built native static libs. +task cppClean(type: Delete) { + buildTypes.each { type -> + archs.each { arch -> + delete "../../omim-android-${type.cppType}-${arch}" + } + } +} + // Tasks for generating obb files for Google Play -task obbClean(type: Exec) { - def obbOutput = 'build/distributions/'; - commandLine 'rm', '-rf', obbOutput +task obbClean(type: Delete) { + delete fileTree(dir: 'build', include: '**/*.obb') } def fonts = ['../data/01_dejavusans.ttf', @@ -336,23 +345,24 @@ def fonts = ['../data/01_dejavusans.ttf', '../data/06_code2000.ttf'] def worlds = ['../data/World.mwm', '../data/WorldCoasts.mwm'] -task obbGenerate() { - createObbGenerateTask('Main', fonts, 'fonts') - createObbGenerateTask('Patch', worlds, 'worlds') +def rawFonts = 'build/fonts.obb' +def rawWorlds = 'build/worlds.obb' +def alignedFonts = 'build/worlds_aligned.obb' +def alignedWorlds = 'build/fonts_aligned.obb' - createObbAlignTask('Main', 'build/distributions/fonts.obb', 'build/distributions/fonts_aligned.obb') - createObbAlignTask('Patch', 'build/distributions/worlds.obb', 'build/distributions/worlds_aligned.obb') +task obbGenerate() { + createObbGenerateTask('Main', fonts, rawFonts) + createObbGenerateTask('Patch', worlds, rawWorlds) + + createObbAlignTask('Main', rawFonts, alignedWorlds) + createObbAlignTask('Patch', rawWorlds, alignedFonts) } obbGenerate.dependsOn obbClean, obbMainGenerate, obbPatchGenerate, obbMainAlign, obbPatchAlign def createObbGenerateTask(type, data, name) { - return tasks.create(name: "obb${type}Generate", type: Zip, description: 'Generate obb files') { - from data - into 'build' - baseName name - extension 'obb' - entryCompression ZipEntryCompression.STORED + return tasks.create(name: "obb${type}Generate", type: Exec, description: 'Generate obb files') { + commandLine ((['zip', '-0', '-j', name, data]).flatten()) } } @@ -364,4 +374,17 @@ def createObbAlignTask(type, rawObb, alignedObb) { return tasks.create(name: "obb${type}Align", dependsOn: "obb${type}Generate", type: Exec, description: 'Align obb files') { commandLine zipalignPath, '-v', '8', rawObb, alignedObb } +} + +task obbPush(dependsOn: ['obbGenerate', 'obbPushMain', 'obbPushPatch']) { + tasks.create(type: Exec, name: 'obbPushMain') { + commandLine android.getAdbExe(), 'push', alignedFonts, obbGetFullPath('main') + } + tasks.create(type: Exec, name: 'obbPushPatch') { + commandLine android.getAdbExe(), 'push', alignedWorlds, obbGetFullPath('patch') + } +} + +def obbGetFullPath(name) { + return "/mnt/sdcard/Android/obb/${project.ext.appId}/${name}.obb" } \ No newline at end of file From 85bb232656dc06c62ae43025784b60016683155b Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Fri, 13 Nov 2015 13:53:52 +0300 Subject: [PATCH 5/6] [android] Moved list of files to include in obb to gradle.properties; added old obb removal to obbPush task. --- android/build.gradle | 41 +++++++++++++++------------------------ android/gradle.properties | 5 +++++ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 8193377038..8eaf84843f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -324,7 +324,7 @@ tasks.withType(JavaCompile) { compileTask -> clean.dependsOn ndkBuildClean // Cleans built native static libs. -task cppClean(type: Delete) { +task cppClean(type: Delete) << { buildTypes.each { type -> archs.each { arch -> delete "../../omim-android-${type.cppType}-${arch}" @@ -333,27 +333,18 @@ task cppClean(type: Delete) { } // Tasks for generating obb files for Google Play -task obbClean(type: Delete) { +task obbClean(type: Delete) << { delete fileTree(dir: 'build', include: '**/*.obb') } -def fonts = ['../data/01_dejavusans.ttf', - '../data/02_droidsans-fallback.ttf', - '../data/03_jomolhari-id-a3d.ttf', - '../data/04_padauk.ttf', - '../data/05_khmeros.ttf', - '../data/06_code2000.ttf'] -def worlds = ['../data/World.mwm', '../data/WorldCoasts.mwm'] - -def rawFonts = 'build/fonts.obb' -def rawWorlds = 'build/worlds.obb' -def alignedFonts = 'build/worlds_aligned.obb' -def alignedWorlds = 'build/fonts_aligned.obb' +def rawFonts = 'build/fonts_unaligned.obb' +def rawWorlds = 'build/worlds_unaligned.obb' +def alignedFonts = 'build/worlds.obb' +def alignedWorlds = 'build/fonts.obb' task obbGenerate() { - createObbGenerateTask('Main', fonts, rawFonts) - createObbGenerateTask('Patch', worlds, rawWorlds) - + createObbGenerateTask('Main', propObbFonts.split(' '), rawFonts) + createObbGenerateTask('Patch', propObbWorlds.split(' '), rawWorlds) createObbAlignTask('Main', rawFonts, alignedWorlds) createObbAlignTask('Patch', rawWorlds, alignedFonts) } @@ -377,14 +368,14 @@ def createObbAlignTask(type, rawObb, alignedObb) { } task obbPush(dependsOn: ['obbGenerate', 'obbPushMain', 'obbPushPatch']) { - tasks.create(type: Exec, name: 'obbPushMain') { - commandLine android.getAdbExe(), 'push', alignedFonts, obbGetFullPath('main') + def obbPath = "/mnt/sdcard/Android/obb/${project.ext.appId}/" + tasks.create(type: Exec, name: 'obbRemoveOnDevice') { + commandLine android.getAdbExe(), 'shell', 'rm', "${obbPath}*.obb" } - tasks.create(type: Exec, name: 'obbPushPatch') { - commandLine android.getAdbExe(), 'push', alignedWorlds, obbGetFullPath('patch') + tasks.create(type: Exec, name: 'obbPushMain', dependsOn: 'obbRemoveOnDevice') { + commandLine android.getAdbExe(), 'push', alignedFonts, "${obbPath}fonts.obb" + } + tasks.create(type: Exec, name: 'obbPushPatch', dependsOn: 'obbRemoveOnDevice') { + commandLine android.getAdbExe(), 'push', alignedWorlds, "${obbPath}worlds.obb" } } - -def obbGetFullPath(name) { - return "/mnt/sdcard/Android/obb/${project.ext.appId}/${name}.obb" -} \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index 15ee2eb9f8..fc8805dc1a 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -7,3 +7,8 @@ propVersionCode=515 propVersionName=5.1.5 propDebugNdkFlags=V=1 NDK_DEBUG=1 DEBUG=1 propReleaseNdkFlags=V=1 NDK_DEBUG=0 PRODUCTION=1 + +# list of files for obb-s +propObbFonts ../data/01_dejavusans.ttf ../data/02_droidsans-fallback.ttf ../data/03_jomolhari-id-a3d.ttf \ + ../data/04_padauk.ttf ../data/05_khmeros.ttf ../data/06_code2000.ttf +propObbWorlds ../data/World.mwm ../data/WorldCoasts.mwm From 150102b59cbd3289134a29640de2c572cb9e5d3d Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Mon, 16 Nov 2015 13:05:03 +0300 Subject: [PATCH 6/6] [android] Moved obb outputs definition to properties. --- android/build.gradle | 22 ++++++++++------------ android/gradle.properties | 10 ++++++++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 8eaf84843f..ea808b69b9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -333,20 +333,18 @@ task cppClean(type: Delete) << { } // Tasks for generating obb files for Google Play +def unalignedFonts = "${propObbFontsOutput}.unaligned" +def unalignedWorlds = "${propObbWorldsOutput}.unaligned" + task obbClean(type: Delete) << { - delete fileTree(dir: 'build', include: '**/*.obb') + delete propObbFontsOutput, propObbWorldsOutput, unalignedFonts, unalignedWorlds } -def rawFonts = 'build/fonts_unaligned.obb' -def rawWorlds = 'build/worlds_unaligned.obb' -def alignedFonts = 'build/worlds.obb' -def alignedWorlds = 'build/fonts.obb' - task obbGenerate() { - createObbGenerateTask('Main', propObbFonts.split(' '), rawFonts) - createObbGenerateTask('Patch', propObbWorlds.split(' '), rawWorlds) - createObbAlignTask('Main', rawFonts, alignedWorlds) - createObbAlignTask('Patch', rawWorlds, alignedFonts) + createObbGenerateTask('Main', propObbFonts.split(' '), unalignedFonts) + createObbGenerateTask('Patch', propObbWorlds.split(' '), unalignedWorlds) + createObbAlignTask('Main', unalignedFonts, propObbFontsOutput) + createObbAlignTask('Patch', unalignedWorlds, propObbWorldsOutput) } obbGenerate.dependsOn obbClean, obbMainGenerate, obbPatchGenerate, obbMainAlign, obbPatchAlign @@ -373,9 +371,9 @@ task obbPush(dependsOn: ['obbGenerate', 'obbPushMain', 'obbPushPatch']) { commandLine android.getAdbExe(), 'shell', 'rm', "${obbPath}*.obb" } tasks.create(type: Exec, name: 'obbPushMain', dependsOn: 'obbRemoveOnDevice') { - commandLine android.getAdbExe(), 'push', alignedFonts, "${obbPath}fonts.obb" + commandLine android.getAdbExe(), 'push', propObbWorldsOutput, "${obbPath}fonts.obb" } tasks.create(type: Exec, name: 'obbPushPatch', dependsOn: 'obbRemoveOnDevice') { - commandLine android.getAdbExe(), 'push', alignedWorlds, "${obbPath}worlds.obb" + commandLine android.getAdbExe(), 'push', propObbFontsOutput, "${obbPath}worlds.obb" } } diff --git a/android/gradle.properties b/android/gradle.properties index fc8805dc1a..22995c60ef 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -9,6 +9,12 @@ propDebugNdkFlags=V=1 NDK_DEBUG=1 DEBUG=1 propReleaseNdkFlags=V=1 NDK_DEBUG=0 PRODUCTION=1 # list of files for obb-s -propObbFonts ../data/01_dejavusans.ttf ../data/02_droidsans-fallback.ttf ../data/03_jomolhari-id-a3d.ttf \ - ../data/04_padauk.ttf ../data/05_khmeros.ttf ../data/06_code2000.ttf +propObbFonts ../data/01_dejavusans.ttf \ + ../data/02_droidsans-fallback.ttf \ + ../data/03_jomolhari-id-a3d.ttf \ + ../data/04_padauk.ttf \ + ../data/05_khmeros.ttf \ + ../data/06_code2000.ttf propObbWorlds ../data/World.mwm ../data/WorldCoasts.mwm +propObbWorldsOutput build/worlds.obb +propObbFontsOutput build/fonts.obb