2016-12-13 15:14:38 +03:00
|
|
|
import de.undercouch.gradle.tasks.download.Download
|
2016-12-13 13:31:06 +03:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
|
2015-03-24 06:28:31 +03:00
|
|
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
classpath "com.android.tools.build:gradle:${ANDROID_GRADLE_PLUGIN_VERSION}"
|
2016-04-19 21:37:29 +03:00
|
|
|
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${GRADLE_BINTRAY_PLUGIN_VERSION}"
|
|
|
|
classpath "com.github.dcendents:android-maven-gradle-plugin:${ANDROID_MAVEN_GRADLE_PLUGIN_VERSION}"
|
2015-03-24 06:28:31 +03:00
|
|
|
|
|
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
|
|
// in the individual module build.gradle files
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-12 19:58:28 +03:00
|
|
|
plugins {
|
|
|
|
id "de.undercouch.download" version "3.1.2"
|
|
|
|
}
|
|
|
|
|
2015-08-26 20:51:12 +03:00
|
|
|
project.ext {
|
|
|
|
buildToolsVersion = "${BUILD_TOOLS_VERSION}"
|
|
|
|
compileSdkVersion = COMPILE_SDK_VERSION.toInteger()
|
2016-02-16 13:51:43 +03:00
|
|
|
minSdkVersion = MIN_SDK_VERSION;
|
|
|
|
targetSdkVersion = TARGET_SDK_VERSION;
|
2016-05-24 20:55:58 +03:00
|
|
|
preDexLibs = !project.hasProperty('disablePreDex');
|
2015-08-26 20:51:12 +03:00
|
|
|
}
|
|
|
|
|
2015-03-24 06:28:31 +03:00
|
|
|
subprojects {
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal()
|
|
|
|
jcenter()
|
|
|
|
mavenCentral()
|
|
|
|
}
|
2015-04-10 18:59:35 +03:00
|
|
|
|
|
|
|
task allclean {
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate { project ->
|
|
|
|
allclean.dependsOn(project.tasks.matching {it.name == 'clean'})
|
2015-05-14 13:39:13 +03:00
|
|
|
|
|
|
|
if (project.tasks.matching { it.name == 'assembleRelease'}) {
|
|
|
|
def jarList = new ArrayList()
|
|
|
|
task setJarList(dependsOn: assembleRelease) << {
|
|
|
|
configurations.compile.each {
|
|
|
|
jarList.add(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task copyDeps(dependsOn: setJarList, type: Copy) {
|
|
|
|
from jarList
|
|
|
|
into 'build/external'
|
|
|
|
}
|
|
|
|
}
|
2015-04-10 18:59:35 +03:00
|
|
|
}
|
2016-05-24 20:55:58 +03:00
|
|
|
|
|
|
|
project.plugins.whenPluginAdded { plugin ->
|
|
|
|
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
|
|
|
|
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
|
|
|
|
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
|
|
|
|
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
|
|
|
|
}
|
|
|
|
}
|
2016-12-13 13:31:06 +03:00
|
|
|
|
2016-12-13 15:14:38 +03:00
|
|
|
apply plugin: 'de.undercouch.download'
|
|
|
|
|
2016-12-14 00:44:42 +03:00
|
|
|
ext.makeNdkTasks = { name, deps ->
|
|
|
|
task "ndk_build_${name}"(dependsOn: deps, type: Exec) {
|
|
|
|
inputs.file("src/main/jni/${name}")
|
|
|
|
outputs.dir("$buildDir/${name}")
|
|
|
|
commandLine getNdkBuildFullPath(project),
|
|
|
|
'NDK_PROJECT_PATH=null',
|
|
|
|
'NDK_APPLICATION_MK=../Application.mk',
|
|
|
|
'NDK_OUT=' + temporaryDir,
|
|
|
|
"NDK_LIBS_OUT=$buildDir/${name}",
|
|
|
|
'-C', file("src/main/jni/${name}").absolutePath,
|
|
|
|
'--jobs', Runtime.getRuntime().availableProcessors()
|
|
|
|
}
|
|
|
|
|
|
|
|
task "ndk_clean_$name"(type: Exec) {
|
|
|
|
ignoreExitValue true
|
|
|
|
commandLine getNdkBuildFullPath(project),
|
|
|
|
'NDK_PROJECT_PATH=null',
|
|
|
|
'NDK_APPLICATION_MK=../Application.mk',
|
|
|
|
'NDK_OUT=' + temporaryDir,
|
|
|
|
"NDK_LIBS_OUT=$buildDir/${name}",
|
|
|
|
'-C', file("src/main/jni/${name}").absolutePath,
|
|
|
|
'clean'
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
compileTask -> compileTask.dependsOn "ndk_build_$name"
|
|
|
|
}
|
|
|
|
clean.dependsOn "ndk_clean_$name"
|
|
|
|
}
|
|
|
|
|
2016-12-13 13:31:06 +03:00
|
|
|
ext.getNdkBuildName = {
|
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
|
|
return "ndk-build.cmd"
|
|
|
|
} else {
|
|
|
|
return "ndk-build"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.getNdkBuildFullPath = { Project project ->
|
|
|
|
File propFile = project.rootProject.file('local.properties')
|
|
|
|
if (!propFile.exists()) {
|
|
|
|
return getNdkBuildName()
|
|
|
|
}
|
|
|
|
Properties properties = new Properties()
|
|
|
|
properties.load(propFile.newDataInputStream())
|
|
|
|
def ndkCommand = properties.getProperty('ndk.command')
|
|
|
|
if (ndkCommand != null) {
|
|
|
|
return ndkCommand
|
|
|
|
}
|
|
|
|
def path = null
|
|
|
|
def ndkPath = properties.getProperty('ndk.path')
|
|
|
|
if (ndkPath != null) {
|
|
|
|
path = ndkPath
|
|
|
|
} else {
|
|
|
|
def ndkDir = properties.getProperty('ndk.dir')
|
|
|
|
if (ndkDir != null) {
|
|
|
|
path = ndkDir
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (path != null) {
|
|
|
|
if (!path.endsWith(File.separator)) {
|
|
|
|
path += File.separator
|
|
|
|
}
|
|
|
|
return path + getNdkBuildName()
|
|
|
|
} else {
|
|
|
|
// if none of above is provided, we assume ndk-build is already in $PATH
|
|
|
|
return getNdkBuildName()
|
|
|
|
}
|
|
|
|
}
|
2016-12-13 13:58:22 +03:00
|
|
|
|
|
|
|
ext.nativeDepsDir = new File("${projectDir}/nativedeps")
|
|
|
|
ext.downloadsDir = new File("${nativeDepsDir}/downloads")
|
|
|
|
ext.mergeDir = new File("${nativeDepsDir}/merge")
|
|
|
|
|
|
|
|
task createNativeDepsDirectories {
|
|
|
|
nativeDepsDir.mkdirs()
|
|
|
|
downloadsDir.mkdirs()
|
|
|
|
mergeDir.mkdirs()
|
|
|
|
}
|
2016-12-13 15:14:38 +03:00
|
|
|
|
2016-12-14 00:09:27 +03:00
|
|
|
ext.createNativeLibrariesTasks = {name, libraryUrl, libraryFileName, libraryDestinationDir, sourceDir1, sourceDir2, includePaths, destinationDir ->
|
|
|
|
// We create the DownloadTask
|
|
|
|
tasks.create("download${name}", Download) {
|
|
|
|
src libraryUrl
|
|
|
|
onlyIfNewer true
|
|
|
|
overwrite false
|
|
|
|
dest downloadsDir
|
|
|
|
dependsOn createNativeDepsDirectories
|
|
|
|
}
|
|
|
|
// The unpack task
|
|
|
|
tasks.create("unpack${name}", Copy) {
|
|
|
|
from tarTree(resources.gzip("${downloadLibjpeg.dest}/${libraryFileName}"))
|
|
|
|
into "${downloadsDir}/${libraryDestinationDir}"
|
|
|
|
dependsOn "download${name}"
|
|
|
|
}
|
|
|
|
// The copy task
|
|
|
|
Task unpackTask = tasks.getByName("unpack${name}")
|
|
|
|
tasks.create("copy${name}", Copy) {
|
|
|
|
from "${unpackTask.destinationDir}/${sourceDir1}"
|
|
|
|
from "src/main/jni/third-party/${sourceDir2}"
|
|
|
|
include(includePaths)
|
|
|
|
into "${mergeDir}/${destinationDir}"
|
|
|
|
dependsOn "unpack${name}"
|
|
|
|
}
|
2016-12-13 23:44:38 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-12-14 00:09:27 +03:00
|
|
|
// Libjpeg-turbo
|
|
|
|
createNativeLibrariesTasks(
|
|
|
|
'Libjpeg', // Name for the tasks
|
|
|
|
'https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.0.tar.gz', // The Url for download
|
|
|
|
'1.5.0.tar.gz', // The downloaded file
|
|
|
|
'libjpeg', // The folder where the file is downloaded
|
|
|
|
'libjpeg-turbo-1.5.0', // The first dir where we have put our customisation
|
|
|
|
'libjpeg-turbo-1.5.x', // The folder for the merge
|
|
|
|
['**/*.c', '**/*.h','**/*.S', '**/*.asm', '**/*.inc', '*.mk'], // Files to compile
|
|
|
|
'libjpeg-turbo-1.5.x' // Final destination dir
|
|
|
|
)
|
|
|
|
|
|
|
|
// Libpng
|
|
|
|
createNativeLibrariesTasks(
|
|
|
|
'Libpng', // Name for the tasks
|
|
|
|
'https://github.com/glennrp/libpng/archive/v1.6.10.tar.gz', // The Url for download
|
|
|
|
'v1.6.10.tar.gz', // The downloaded file
|
|
|
|
'libpng', // The folder where the file is downloaded
|
|
|
|
'libpng-1.6.10', // The first dir where we have put our customisation
|
|
|
|
'libpng-1.6.10', // The folder for the merge
|
|
|
|
['**/*.c', '**/*.h', '**/*.S', '*.mk'], // Files to compile
|
|
|
|
'libpng-1.6.10' // Final destination dir
|
|
|
|
)
|
|
|
|
|
|
|
|
// Gif
|
|
|
|
createNativeLibrariesTasks(
|
|
|
|
'Giflib', // Name for the tasks
|
|
|
|
'http://kent.dl.sourceforge.net/project/giflib/giflib-5.1.1.tar.gz', // The Url for download
|
|
|
|
'giflib-5.1.1.tar.gz', // The downloaded file
|
|
|
|
'giflib', // The folder where the file is downloaded
|
|
|
|
'giflib-5.1.1/lib', // The first dir where we have put our customisation
|
|
|
|
'giflib', // The folder for the merge
|
|
|
|
['*.c', '*.h', '*.mk'], // Files to compile
|
|
|
|
'giflib' // Final destination dir
|
|
|
|
)
|
|
|
|
|
|
|
|
// Webp
|
|
|
|
createNativeLibrariesTasks(
|
|
|
|
'Libwebp', // Name for the tasks
|
|
|
|
'https://github.com/webmproject/libwebp/archive/v0.5.1.tar.gz', // The Url for download
|
|
|
|
'v0.5.1.tar.gz', // The downloaded file
|
|
|
|
'libwebp', // The folder where the file is downloaded
|
|
|
|
'libwebp-0.5.1', // The first dir where we have put our customisation
|
|
|
|
'libwebp-0.5.1', // The folder for the merge
|
|
|
|
['src/**/*.c', 'src/**/*.h', '*.mk'], // Files to compile
|
|
|
|
'libwebp-0.5.1' // Final destination dir
|
|
|
|
)
|
2015-03-24 06:28:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
}
|