forked from BabylonJS/BabylonNative
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
124 lines (110 loc) · 3.7 KB
/
Copy pathbuild.gradle
File metadata and controls
124 lines (110 loc) · 3.7 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
plugins {
id 'com.android.library'
}
def jsEngine = "V8"
if (project.hasProperty("jsEngine")) {
jsEngine = project.property("jsEngine")
}
def graphics_api = "OpenGL"
def platformVersion = 21
if (project.hasProperty("GRAPHICS_API")) {
graphics_api = project.property("GRAPHICS_API")
if ("${graphics_api}" == "Vulkan" ) {
platformVersion = 24 // minimal version to get Vulkan
}
}
def arcore_libpath = layout.buildDirectory.dir("arcore-native").get().asFile.absolutePath
def cmakeArguments = [
"-DANDROID_STL=c++_shared",
"-DENABLE_PCH=OFF",
"-DGRAPHICS_API=${graphics_api}",
"-DARCORE_LIBPATH=${arcore_libpath}/jni",
"-DNAPI_JAVASCRIPT_ENGINE=${jsEngine}",
"-DBABYLON_NATIVE_BUILD_APPS=ON",
"-DBABYLON_DEBUG_TRACE=ON"
]
if (project.hasProperty("importHostCompilers")) {
cmakeArguments.add("-DIMPORT_HOST_COMPILERS=${project.property('importHostCompilers')}")
}
configurations { natives }
android {
namespace = 'com.android.library.babylonnative'
compileSdk = 34
defaultConfig {
minSdk = 25
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
ndkVersion = "29.0.14206865"
if (project.hasProperty("NDK_VERSION")) {
ndkVersion = project.property("NDK_VERSION")
}
externalNativeBuild {
cmake {
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
arguments(*cmakeArguments)
cppFlags += ["-Wno-deprecated-literal-operator"]
}
}
ndk {
if (project.hasProperty("ARM64Only")) {
abiFilters "arm64-v8a"
} else {
abiFilters "arm64-v8a", "armeabi-v7a", "x86"
}
}
packaging {
exclude '**/libarcore_sdk_c.so'
}
}
externalNativeBuild {
cmake {
version = '3.19.6+'
path = 'CMakeLists.txt'
buildStagingDirectory = "../../../../Build/Android"
}
}
packaging {
jniLibs {
pickFirsts += ['lib/*/libv8android.so', 'lib/*/libjsc.so']
}
}
buildTypes {
release {
minifyEnabled = false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
dependencies {
// ARCore library
implementation 'com.google.ar:core:1.52.0'
natives 'com.google.ar:core:1.52.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
// Extracts the shared libraries from aars in the natives configuration.
// This is done so that NDK builds can access these libraries.
tasks.register('extractNativeLibraries') {
// Always extract, this insures the native libs are updated if the version changes.
outputs.upToDateWhen { false }
doFirst {
configurations.natives.files.each { f ->
copy {
from zipTree(f)
into arcore_libpath
include "jni/**/*"
}
}
}
}
tasks.configureEach { task ->
if ((task.name.contains("buildCMake") || task.name.contains("configureCMake")) && !task.name.contains("Clean")) {
task.dependsOn('extractNativeLibraries')
}
}