Skip to content

Commit

Permalink
Provide alternatives to adding ndk-build to $PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Gregorczyk authored and tyronen committed Apr 1, 2015
1 parent fbf06ff commit a86516d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions imagepipeline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
compile "com.android.support:support-v4:${SUPPORT_V4_VERSION}"
compile "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"
compile project(':fbcore')

androidTestCompile "com.google.guava:guava:${GUAVA_VERSION}"
androidTestCompile "junit:junit:${JUNIT_VERSION}"
androidTestCompile "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"
Expand Down Expand Up @@ -125,11 +125,28 @@ task copyLibWebp(dependsOn: cloneWebp, type: Copy) {
into "${nativemerge}/libwebp-0.4.2"
}

def getNdkBuildCommand() {
// we allow to provide full path to ndk-build tool
if (hasProperty('ndk.command')) {
return property('ndk.command')
}
// or just a path to the containing directiry
if (hasProperty('ndk.path')) {
def path = property('ndk.path')
if (!path.endsWith(File.separator)) {
path += File.separator
}
return path + 'ndk-build'
}
// if none of above is provided, we assume ndk-build is already in $PATH
return 'ndk-build'
}

def makeNdkTasks(String name) {
task "ndk_build_$name"(type: Exec) {
inputs.file("src/main/jni/$name")
outputs.dir("$buildDir/$name")
commandLine 'ndk-build',
commandLine getNdkBuildCommand(),
'NDK_APPLICATION_MK=../Application.mk',
'NDK_OUT=' + temporaryDir,
"NDK_LIBS_OUT=$buildDir/$name",
Expand All @@ -138,7 +155,7 @@ def makeNdkTasks(String name) {
}

task "ndk_clean_$name"(type: Exec) {
commandLine 'ndk-build',
commandLine getNdkBuildCommand(),
'NDK_APPLICATION_MK=../Application.mk',
'NDK_OUT=' + temporaryDir,
"NDK_LIBS_OUT=$buildDir/$name",
Expand Down

0 comments on commit a86516d

Please sign in to comment.