11apply plugin : ' com.android.application'
22
3- // When no project property is set for Gradle ('-PJSEngine=')
4- // default JS engine is set to v8android
5- // JSEngine property can be:
6- // - jsc for JavaScriptCore
7- // - v8android for V8
8-
9- def jsEngineBaseDir = " ${ buildDir} /JS"
10- def jsEngineIncDir = " ${ jsEngineBaseDir} /include/V8"
11- def jsEngineLibDir = " ${ rootDir} /app/src/main/jniLibs"
12-
13- def jsEngineLibName = " v8android"
14- if (project. hasProperty(" JSEngine" )) {
15- jsEngineLibName = project. property(" JSEngine" )
16- if (" ${ jsEngineLibName} " == " jsc" ) {
17- jsEngineIncDir = " ${ jsEngineBaseDir} /include"
18- }
3+ def jsEngine = " V8"
4+ if (project. hasProperty(" jsEngine" )) {
5+ jsEngine = project. property(" jsEngine" )
196}
207
218def graphics_api = " OpenGL"
@@ -36,12 +23,12 @@ def arcore_libpath = "${buildDir}/arcore-native"
3623configurations { natives }
3724
3825android {
39- compileSdkVersion 28
26+ compileSdkVersion 29
4027
4128 defaultConfig {
4229 applicationId " com.android.babylonnative.playground"
4330 minSdkVersion " ${ platformVersion} "
44- targetSdkVersion 28
31+ targetSdkVersion 29
4532 ndkVersion " 23.1.7779620"
4633 if (project. hasProperty(" NDK_VERSION" )) {
4734 def NDKVersion = project. property(" NDK_VERSION" )
@@ -54,9 +41,8 @@ android {
5441 " -DENABLE_PCH=OFF" ,
5542 " -DGRAPHICS_API=${ graphics_api} " ,
5643 " -DARCORE_LIBPATH=${ arcore_libpath} /jni" ,
57- " -DANDROID_JSENGINE_LIBPATH=${ jsEngineLibDir} " ,
58- " -DANDROID_JSENGINE_LIBNAME=${ jsEngineLibName} " ,
59- " -DANDROID_JSENGINE_INCPATH=${ jsEngineIncDir} " ,
44+ " -DNAPI_JAVASCRIPT_ENGINE=${ jsEngine} " ,
45+ " -DJSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR=ON"
6046 " -DCMAKE_UNITY_BUILD=${ unity_build} "
6147 }
6248 }
@@ -162,78 +148,5 @@ task copyFiles {
162148 }
163149}
164150
165- repositories {
166- mavenLocal()
167- maven {
168- // Android JSC is installed from npm
169- url " $rootDir /../../node_modules/jsc-android/dist"
170- }
171- maven {
172- // Android V8 is installed from npm
173- url " $rootDir /../../node_modules/v8-android/dist"
174- }
175- google()
176- jcenter()
177- }
178-
179- configurations
180- {
181- jscAndroid
182- v8Android
183- }
184-
185- dependencies {
186- jscAndroid ' org.webkit:android-jsc:+'
187- v8Android ' org.chromium:v8-android:+'
188- }
189-
190- // Extracts the shared libraries from aars in the natives configuration.
191- // This is done so that NDK builds can access these libraries.
192- task extractJSEngineLibraries () {
193- // Always extract, this insures the native libs are updated if the version changes.
194- outputs. upToDateWhen { false }
195- def jsconfig
196- if (" ${ jsEngineLibName} " == " jsc" ) {
197- jsconfig = configurations. jscAndroid
198- } else {
199- jsconfig = configurations. v8Android
200- }
201- doFirst {
202- jsconfig. files. each { f ->
203- copy {
204- from zipTree(f)
205- into jsEngineLibDir
206- include " jni/**/*"
207- // remove 'jni/'
208- eachFile { fcd ->
209- fcd. relativePath = new RelativePath (true , fcd. relativePath. segments. drop(1 ))
210- }
211- includeEmptyDirs = false
212- }
213- }
214- }
215- }
216-
217- tasks. whenTaskAdded { task ->
218- if (task. name. contains(" external" ) && ! task. name. contains(" Clean" )) {
219- task. dependsOn(extractJSEngineLibraries)
220- }
221- }
222-
223- task copyFilesJSHeaders {
224- copy
225- {
226- from " ${ rootDir} /../../node_modules/jsc-android/dist/include"
227- include " *"
228- into " ${ jsEngineBaseDir} /include/JavaScriptCore"
229- }
230- copy
231- {
232- from " ${ rootDir} /../../node_modules/v8-android/dist/include"
233- include " **/*"
234- into " ${ jsEngineIncDir} "
235- }
236- }
237-
238151preBuild. dependsOn(copyFiles)
239- preBuild . dependsOn(copyFilesJSHeaders)
152+
0 commit comments