aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools/android/apps/arcore/build.gradle
blob: 0e82ab88312efc6b786f5ed3a04220bfc5eaae98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
apply plugin: 'com.android.application'

/*
The arcore aar library contains the native shared libraries.  These are
extracted before building to a temporary directory.
 */
def arcore_libpath = "${buildDir}/arcore-native"

// Create a configuration to mark which aars to extract .so files from
configurations { natives }

android {
    sourceSets.main.jni.srcDirs = [] //disable automatic ndk-build call
    sourceSets.main.jniLibs.srcDir "src/main/libs"
    productFlavors { arm64 {} }

    setupSkiaLibraryBuild(project, applicationVariants, "libarcore")

    compileSdkVersion 27
    defaultConfig {
        applicationId "org.skia.viewer"
        // 24 is the minimum since ARCore only works with 24 and higher.
        minSdkVersion 24
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11", "-Wall"
                arguments "-DANDROID_STL=c++_static",
                        "-DARCORE_LIBPATH=${arcore_libpath}/jni",
                        "-DARCORE_INCLUDE=${project.rootDir}/../../libraries/include",
                        "-DSKIA_INCLUDE_PATH=${project.rootDir}/../../../include"
            }
        }
        ndk {
            abiFilters "arm64-v8a"
        }
    }
    flavorDimensions "base"
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }

}

dependencies {
    // ARCore library
    implementation 'com.google.ar:core:1.2.0'
    natives 'com.google.ar:core:1.2.0'

    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.0.2'
}

// Extracts the shared libraries from aars in the natives configuration.
// This is done so that NDK builds can access these libraries.
task extractNativeLibraries() {
    doFirst {
        configurations.natives.files.each { f ->
            copy {
                from zipTree(f)
                into arcore_libpath
                include "jni/**/*"
            }
        }
    }
}


tasks.whenTaskAdded {
    task-> if (task.name.contains("external") && !task.name.contains("Clean")) {
        task.dependsOn(extractNativeLibraries)

        //make sure skia lib is built and copied in the correct directory before building arcore
        tasks.whenTaskAdded {
            t-> if (t.name.contains("CopySkiaLib")) {
                task.dependsOn(t)
            }
        }
    }
}