Skip to content

Commit 923fa6d

Browse files
JSR Integration Take 2 (#1260)
- Disabling ARC by default here because of PG and bgfx calls retain/release - clean up PG gradle - JSE names to be same as JSR - update 2 VT PGs - remove `npm i` for android ci - removed `npm i` in readme - replaced `target_link_to_dependencies` with `target_link_libraries` 95% same PR as #1238 --------- Co-authored-by: Gary Hsu <[email protected]>
1 parent bdec2b2 commit 923fa6d

File tree

143 files changed

+157
-27539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+157
-27539
lines changed

.github/jobs/android.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ jobs:
1919
parameters:
2020
vmImage: ${{ parameters.vmImage }}
2121

22-
- script: |
23-
cd Apps/Playground/Android
24-
npm install
25-
displayName: 'Install JS engine NPMs'
26-
2722
- task: Gradle@2
2823
inputs:
2924
workingDirectory: 'Apps/Playground/Android'

.github/jobs/ios.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- script: |
2828
mkdir buildiOS
2929
cd buildiOS
30-
cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../Dependencies/ios-cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED -DENABLE_ARC=0 -DDEPLOYMENT_TARGET=${{ parameters.deploymentTarget }} -DENABLE_GLSLANG_BINARIES=OFF -DSPIRV_CROSS_CLI=OFF -DCMAKE_UNITY_BUILD=${UNITY_BUILD}
30+
cmake .. -G Xcode -D IOS=ON -D DEPLOYMENT_TARGET=${{ parameters.deploymentTarget }} -D CMAKE_UNITY_BUILD=${UNITY_BUILD}
3131
displayName: 'Generate iOS solution'
3232
3333
- task: Xcode@5

.github/jobs/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- script: |
3333
mkdir build
3434
cd build
35-
cmake .. -GNinja -DJSCORE_LIBRARY=/usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so -DNAPI_JAVASCRIPT_ENGINE=${{ parameters.JSEngine }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBGFX_CONFIG_DEBUG=ON -DCMAKE_UNITY_BUILD=${UNITY_BUILD}
35+
cmake .. -G Ninja -D JAVASCRIPTCORE_LIBRARY=/usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so -D NAPI_JAVASCRIPT_ENGINE=${{ parameters.JSEngine }} -D CMAKE_BUILD_TYPE=RelWithDebInfo -D BGFX_CONFIG_DEBUG=ON -D CMAKE_UNITY_BUILD=${UNITY_BUILD}
3636
ninja
3737
displayName: 'Build X11'
3838

.github/jobs/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- script: |
2727
mkdir buildmacOS
2828
cd buildmacOS
29-
cmake .. -GXcode -DCMAKE_UNITY_BUILD=${UNITY_BUILD}
29+
cmake .. -G Xcode -D CMAKE_UNITY_BUILD=${UNITY_BUILD}
3030
displayName: 'Generate macOS solution'
3131
3232
- task: Xcode@5

.github/jobs/uwp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- script: |
3535
mkdir build${{ variables.solutionName }}
3636
cd build${{ variables.solutionName }}
37-
cmake .. -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 ${{ variables.jsEngineDefine }} -A ${{ parameters.platform }} -DCMAKE_UNITY_BUILD=${UNITY_BUILD}
37+
cmake .. -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 ${{ variables.jsEngineDefine }} -A ${{ parameters.platform }} -D CMAKE_UNITY_BUILD=${UNITY_BUILD}
3838
displayName: 'Generate ${{ variables.solutionName }} solution'
3939
4040
- task: VSBuild@1

.github/jobs/win32.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ parameters:
1111
values:
1212
- direct
1313
- jsi
14+
- V8
1415
- name: graphics_api
1516
type: string
1617
default: D3D11
@@ -24,7 +25,10 @@ jobs:
2425
${{ if eq(parameters.napiType, 'jsi') }}:
2526
napiSuffix: '_JSI'
2627
jsEngineDefine: '-DNAPI_JAVASCRIPT_ENGINE=JSI'
27-
${{ if ne(parameters.napiType, 'jsi') }}:
28+
${{ elseif eq(parameters.napiType, 'V8') }}:
29+
napiSuffix: '_V8'
30+
jsEngineDefine: '-DNAPI_JAVASCRIPT_ENGINE=V8'
31+
${{ else }}:
2832
napiSuffix: ''
2933
jsEngineDefine: ''
3034
solutionName: 'Win32_${{ parameters.platform }}${{variables.napiSuffix}}'
@@ -37,7 +41,8 @@ jobs:
3741
- script: |
3842
mkdir build${{ variables.solutionName }}
3943
cd build${{ variables.solutionName }}
40-
cmake -A ${{ parameters.platform }} ${{ variables.jsEngineDefine }} -DBGFX_CONFIG_DEBUG=ON -DGRAPHICS_API=${{ parameters.graphics_api }} -DCMAKE_UNITY_BUILD=${UNITY_BUILD} ..
44+
# BGFX_CONFIG_MAX_FRAME_BUFFERS is set so enough Framebuffers are available before V8 starts disposing unused ones
45+
cmake -A ${{ parameters.platform }} ${{ variables.jsEngineDefine }} -D BGFX_CONFIG_DEBUG=ON -D GRAPHICS_API=${{ parameters.graphics_api }} -D CMAKE_UNITY_BUILD=${UNITY_BUILD} -D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 ..
4146
displayName: 'Generate ${{ variables.solutionName }} solution'
4247
4348
- task: MSBuild@1
@@ -52,14 +57,19 @@ jobs:
5257
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\Playground.exe" /v DumpType /t REG_DWORD /d 2
5358
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\Playground.exe" /v DumpCount /t REG_DWORD /d 1
5459
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\Playground.exe" /v DumpFolder /t REG_SZ /d "$(Build.ArtifactStagingDirectory)/Dumps"
60+
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\UnitTests.exe"
61+
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\UnitTests.exe" /v DumpType /t REG_DWORD /d 2
62+
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\UnitTests.exe" /v DumpCount /t REG_DWORD /d 1
63+
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\UnitTests.exe" /v DumpFolder /t REG_SZ /d "$(Build.ArtifactStagingDirectory)/Dumps"
64+
5565
displayName: 'Enable Crash Dumps'
5666
5767
- script: |
5868
cd build${{ variables.solutionName }}\Apps\Playground
5969
cd RelWithDebInfo
6070
Playground app:///Scripts/validation_native.js
6171
displayName: 'Validation Tests'
62-
72+
6373
- task: PublishBuildArtifacts@1
6474
inputs:
6575
artifactName: '${{ variables.solutionName }} - ${{ parameters.graphics_api }} Rendered Pictures'
@@ -82,16 +92,25 @@ jobs:
8292
cleanTargetFolder: false
8393
displayName: 'Stage test app exe/pdb for publishing'
8494
condition: failed()
95+
96+
- script: |
97+
cd build${{ variables.solutionName }}\Apps\UnitTests
98+
cd RelWithDebInfo
99+
UnitTests
100+
displayName: 'Unit Tests'
101+
102+
- task: CopyFiles@2
103+
inputs:
104+
sourceFolder: 'build${{ variables.solutionName }}/Apps/UnitTests/RelWithDebInfo'
105+
contents: UnitTests.*
106+
targetFolder: '$(Build.ArtifactStagingDirectory)/Dumps'
107+
cleanTargetFolder: false
108+
displayName: 'Stage test app exe/pdb for publishing'
109+
condition: failed()
85110

86111
- task: PublishBuildArtifacts@1
87112
inputs:
88113
artifactName: '${{ variables.solutionName }} - ${{ parameters.graphics_api }} Crash Dumps'
89114
pathtoPublish: '$(Build.ArtifactStagingDirectory)/Dumps'
90115
displayName: 'Publish Tests ${{ variables.solutionName }} Dumps'
91-
condition: failed()
92-
93-
- script: |
94-
cd build${{ variables.solutionName }}\Apps\UnitTests
95-
cd RelWithDebInfo
96-
UnitTests
97-
displayName: 'Unit Tests'
116+
condition: failed()

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[submodule "base-n"]
22
path = Dependencies/base-n
33
url = https://github.com/azawadzki/base-n
4-
[submodule "arcana.cpp"]
5-
path = Dependencies/arcana.cpp
6-
url = https://github.com/microsoft/arcana.cpp
74
[submodule "glslang"]
85
path = Dependencies/glslang
96
url = https://github.com/KhronosGroup/glslang
@@ -13,9 +10,6 @@
1310
[submodule "bgfx.cmake"]
1411
path = Dependencies/bgfx.cmake
1512
url = https://github.com/BabylonJS/bgfx.cmake
16-
[submodule "Dependencies/ios-cmake"]
17-
path = Dependencies/ios-cmake
18-
url = https://github.com/leetal/ios-cmake.git
1913
[submodule "Dependencies/xr/Dependencies/OpenXR-SDK"]
2014
path = Dependencies/xr/Dependencies/OpenXR-SDK
2115
url = https://github.com/KhronosGroup/OpenXR-SDK

Apps/Playground/Android/app/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
2323
set(BABYLON_NATIVE_PLATFORM "Android")
2424
set(CMAKE_CXX_STANDARD 17)
2525

26-
if (${ANDROID_JSENGINE_LIBNAME} STREQUAL "jsc")
27-
set(NAPI_JAVASCRIPT_ENGINE "JavaScriptCore" CACHE STRING "JavaScript engine for N-API.")
28-
elseif (${ANDROID_JSENGINE_LIBNAME} STREQUAL "v8android")
29-
set(NAPI_JAVASCRIPT_ENGINE "V8" CACHE STRING "JavaScript engine for N-API.")
30-
else()
31-
message(FATAL_ERROR "Unrecognized JS engine: ${ANDROID_JSENGINE_LIBNAME}")
32-
endif()
33-
3426
add_library(javascript_engine SHARED IMPORTED GLOBAL)
3527
set_target_properties(javascript_engine PROPERTIES IMPORTED_LOCATION "${ANDROID_JSENGINE_LIBPATH}/${ANDROID_ABI}/lib${ANDROID_JSENGINE_LIBNAME}.so")
3628
target_include_directories(javascript_engine INTERFACE "${ANDROID_JSENGINE_INCPATH}")
@@ -56,7 +48,6 @@ target_link_libraries(BabylonNativeJNI
5648
AppRuntime
5749
Canvas
5850
Console
59-
ChromeDevTools
6051
GraphicsDevice
6152
NativeCamera
6253
NativeEngine

Apps/Playground/Android/app/build.gradle

Lines changed: 8 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
apply 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

218
def graphics_api = "OpenGL"
@@ -36,12 +23,12 @@ def arcore_libpath = "${buildDir}/arcore-native"
3623
configurations { natives }
3724

3825
android {
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-
238151
preBuild.dependsOn(copyFiles)
239-
preBuild.dependsOn(copyFilesJSHeaders)
152+

Apps/Playground/Android/app/src/main/cpp/BabylonNativeJNI.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <Babylon/Plugins/NativeXr.h>
1919
#include <Babylon/Plugins/NativeCamera.h>
2020
#include <Babylon/Plugins/NativeOptimizations.h>
21-
#include <Babylon/Plugins/ChromeDevTools.h>
2221
#include <Babylon/Polyfills/Console.h>
2322
#include <Babylon/Polyfills/Window.h>
2423
#include <Babylon/Polyfills/XMLHttpRequest.h>
@@ -29,7 +28,6 @@ namespace
2928
std::optional<Babylon::Graphics::Device> device{};
3029
std::optional<Babylon::Graphics::DeviceUpdate> deviceUpdate{};
3130
std::optional<Babylon::AppRuntime> runtime{};
32-
std::optional<Babylon::Plugins::ChromeDevTools> chromeDevTools{};
3331
std::optional<Babylon::Plugins::NativeXr> nativeXr{};
3432
Babylon::Plugins::NativeInput* nativeInput{};
3533
std::optional<Babylon::Polyfills::Canvas> nativeCanvas{};
@@ -58,7 +56,6 @@ extern "C"
5856
scriptLoader.reset();
5957

6058
nativeInput = {};
61-
chromeDevTools.reset();
6259
nativeXr.reset();
6360
scriptLoader.reset();
6461
runtime.reset();
@@ -126,12 +123,6 @@ extern "C"
126123

127124
Babylon::Polyfills::XMLHttpRequest::Initialize(env);
128125
nativeCanvas.emplace(Babylon::Polyfills::Canvas::Initialize(env));
129-
130-
chromeDevTools.emplace(Babylon::Plugins::ChromeDevTools::Initialize(env));
131-
if (chromeDevTools->SupportsInspector())
132-
{
133-
chromeDevTools->StartInspector(5643, "BabylonNative Playground");
134-
}
135126
});
136127

137128
scriptLoader.emplace(*runtime);

0 commit comments

Comments
 (0)