Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Tests Experiment #1252

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2baddd3
fetch content
CedricGuillemet Jul 3, 2023
7745490
moved cmake fetch command
CedricGuillemet Jul 3, 2023
69a97a1
ios toolchain
CedricGuillemet Jul 3, 2023
059aaf4
arc
CedricGuillemet Jul 3, 2023
3e00929
Google Tests Experiment
CedricGuillemet Jul 5, 2023
bc4e5f6
x11, apple, uwp
CedricGuillemet Jul 5, 2023
754b953
uwp, x11
CedricGuillemet Jul 5, 2023
de4aa2a
uwp
CedricGuillemet Jul 5, 2023
d4b0f2b
gtest android
CedricGuillemet Jul 6, 2023
18e67c4
v8
CedricGuillemet Jul 6, 2023
0c81dde
JSE name consistency with JSR
CedricGuillemet Jul 6, 2023
ce42e9f
shared source
CedricGuillemet Jul 6, 2023
7a215d4
fix include
CedricGuillemet Jul 6, 2023
162a33b
libs
CedricGuillemet Jul 6, 2023
f163c8b
arcore
CedricGuillemet Jul 6, 2023
1d7afdb
gradle var name
CedricGuillemet Jul 6, 2023
30e8d46
natives
CedricGuillemet Jul 6, 2023
15e6192
jse copy
CedricGuillemet Jul 6, 2023
4117d20
jse copy
CedricGuillemet Jul 6, 2023
ac9c5f3
remove nativexr
CedricGuillemet Jul 6, 2023
c54d9b6
test with androidextensions
CedricGuillemet Jul 6, 2023
44bb19f
android sdk
CedricGuillemet Jul 6, 2023
042a08c
fetch for android
CedricGuillemet Jul 6, 2023
37c3693
android-extensions
CedricGuillemet Jul 6, 2023
dc42f0a
Merge branch 'V8Consistency' of https://github.com/cedricguillemet/Ba…
CedricGuillemet Jul 6, 2023
765b578
clean cmake, fix VT
CedricGuillemet Jul 6, 2023
2b4310a
AndroidExtensions
CedricGuillemet Jul 6, 2023
2f4ebf7
capsule
CedricGuillemet Jul 6, 2023
4c99dfd
npm i test
CedricGuillemet Jul 6, 2023
9777d0e
readme update
CedricGuillemet Jul 6, 2023
d85ba4d
android
CedricGuillemet Jul 7, 2023
b069d6b
yaml condition
CedricGuillemet Jul 7, 2023
efb9c88
js engine name
CedricGuillemet Jul 7, 2023
38a8b69
debug artifacts
CedricGuillemet Jul 7, 2023
c397d8b
Merge branch 'FetchContent' of https://github.com/CedricGuillemet/Bab…
CedricGuillemet Jul 7, 2023
78d5e38
xr
CedricGuillemet Jul 7, 2023
20772d2
android full run
CedricGuillemet Jul 7, 2023
b80ef25
connectedAndroidTest
CedricGuillemet Jul 7, 2023
e0e2792
win32 tests
CedricGuillemet Jul 7, 2023
bc86da6
install script
CedricGuillemet Jul 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/jobs/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ jobs:
parameters:
vmImage: ${{ parameters.vmImage }}

- script: |
cd Apps/Playground/Android
npm install
displayName: 'Install JS engine NPMs'

- task: Gradle@2
inputs:
workingDirectory: 'Apps/Playground/Android'
Expand Down
60 changes: 60 additions & 0 deletions .github/jobs/android_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
parameters:
name: ''
vmImage: ''
JSEngine: ''
macOSCodename: ''

jobs:
- job: ${{ parameters.name }}
timeoutInMinutes: 45
pool:
vmImage: ${{ parameters.vmImage }}

steps:
- script: |
git submodule update --init --recursive
displayName: 'Checkout dependencies'

- template: cmake.yml
parameters:
vmImage: ${{ parameters.vmImage }}

- script: |
echo Install Android image
echo 'y' | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-27;default;x86_64'
echo 'y' | $ANDROID_HOME/tools/bin/sdkmanager --licenses
echo Create AVD
$ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_API_27 -d pixel -k 'system-images;android-27;default;x86_64'
displayName: 'Install Android Emulator'

- script: |
echo Start emulator
nohup $ANDROID_HOME/emulator/emulator -avd Pixel_API_27 -gpu host -no-window 2>&1 &
echo Wait for emulator
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do echo '.'; sleep 1; done'
$ANDROID_HOME/platform-tools/adb devices
displayName: 'Start Android Emulator'

- task: Gradle@3
inputs:
gradleWrapperFile: 'Apps/UnitTests/Android/gradlew'
workingDirectory: 'Apps/UnitTests/Android'
options: '-PabiFilters=x86_64 -PjsEngine=${{parameters.jsEngine}}'
tasks: 'connectedAndroidTest'
jdkVersionOption: 1.11
displayName: 'Run Connected Android Test'

- script: |
export results=$(find ./app/build/outputs/androidTest-results -name "*.txt")
echo cat "$results"
cat "$results"
workingDirectory: 'Apps/UnitTests/Android'
condition: succeededOrFailed()
displayName: 'Dump logcat from Test Results'

- task: PublishBuildArtifacts@1
inputs:
pathToPublish: 'Apps/UnitTests/Android/app/build/outputs/androidTest-results/connected'
artifactName: 'AndroidTestResults_${{parameters.jsEngine}}'
condition: succeededOrFailed()
displayName: 'Publish Test Results'
8 changes: 7 additions & 1 deletion .github/jobs/win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ jobs:
cd RelWithDebInfo
Playground app:///Scripts/validation_native.js
displayName: 'Validation Tests'


- script: |
cmake --build build${{ variables.solutionName }} --target INSTALL --config RelWithDebInfo
cd Install/Test
cmake . -DBINARY_DIR=../../build${{ variables.solutionName }} ${{ variables.jsEngineDefine }} && cmake --build . --config RelWithDebInfo
displayName: 'Install'

- task: PublishBuildArtifacts@1
inputs:
artifactName: '${{ variables.solutionName }} - ${{ parameters.graphics_api }} Rendered Pictures'
Expand Down
8 changes: 0 additions & 8 deletions Apps/Playground/Android/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(BABYLON_NATIVE_PLATFORM "Android")
set(CMAKE_CXX_STANDARD 17)

if (${ANDROID_JSENGINE_LIBNAME} STREQUAL "jsc")
set(NAPI_JAVASCRIPT_ENGINE "JavaScriptCore" CACHE STRING "JavaScript engine for N-API.")
elseif (${ANDROID_JSENGINE_LIBNAME} STREQUAL "v8android")
set(NAPI_JAVASCRIPT_ENGINE "V8" CACHE STRING "JavaScript engine for N-API.")
else()
message(FATAL_ERROR "Unrecognized JS engine: ${ANDROID_JSENGINE_LIBNAME}")
endif()

add_library(javascript_engine SHARED IMPORTED GLOBAL)
set_target_properties(javascript_engine PROPERTIES IMPORTED_LOCATION "${ANDROID_JSENGINE_LIBPATH}/${ANDROID_ABI}/lib${ANDROID_JSENGINE_LIBNAME}.so")
target_include_directories(javascript_engine INTERFACE "${ANDROID_JSENGINE_INCPATH}")
Expand Down
103 changes: 8 additions & 95 deletions Apps/Playground/Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
apply plugin: 'com.android.application'

// When no project property is set for Gradle ('-PJSEngine=')
// default JS engine is set to v8android
// JSEngine property can be:
// - jsc for JavaScriptCore
// - v8android for V8

def jsEngineBaseDir = "${buildDir}/JS"
def jsEngineIncDir = "${jsEngineBaseDir}/include/V8"
def jsEngineLibDir = "${rootDir}/app/src/main/jniLibs"

def jsEngineLibName = "v8android"
if (project.hasProperty("JSEngine")) {
jsEngineLibName = project.property("JSEngine")
if ("${jsEngineLibName}" == "jsc" ) {
jsEngineIncDir = "${jsEngineBaseDir}/include"
}
def jsEngine = "V8"
if (project.hasProperty("jsEngine")) {
jsEngine = project.property("jsEngine")
}

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

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
applicationId "com.android.babylonnative.playground"
minSdkVersion "${platformVersion}"
targetSdkVersion 28
targetSdkVersion 29
ndkVersion "23.1.7779620"
if (project.hasProperty("NDK_VERSION")) {
def NDKVersion = project.property("NDK_VERSION")
Expand All @@ -54,9 +41,8 @@ android {
"-DENABLE_PCH=OFF",
"-DGRAPHICS_API=${graphics_api}",
"-DARCORE_LIBPATH=${arcore_libpath}/jni",
"-DANDROID_JSENGINE_LIBPATH=${jsEngineLibDir}",
"-DANDROID_JSENGINE_LIBNAME=${jsEngineLibName}",
"-DANDROID_JSENGINE_INCPATH=${jsEngineIncDir}",
"-DNAPI_JAVASCRIPT_ENGINE=${jsEngine}",
"-DJSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR=ON"
"-DCMAKE_UNITY_BUILD=${unity_build}"
}
}
Expand Down Expand Up @@ -162,78 +148,5 @@ task copyFiles {
}
}

repositories {
mavenLocal()
maven {
// Android JSC is installed from npm
url "$rootDir/../../node_modules/jsc-android/dist"
}
maven {
// Android V8 is installed from npm
url "$rootDir/../../node_modules/v8-android/dist"
}
google()
jcenter()
}

configurations
{
jscAndroid
v8Android
}

dependencies {
jscAndroid 'org.webkit:android-jsc:+'
v8Android 'org.chromium:v8-android:+'
}

// Extracts the shared libraries from aars in the natives configuration.
// This is done so that NDK builds can access these libraries.
task extractJSEngineLibraries() {
// Always extract, this insures the native libs are updated if the version changes.
outputs.upToDateWhen { false }
def jsconfig
if ("${jsEngineLibName}" == "jsc" ) {
jsconfig = configurations.jscAndroid
} else {
jsconfig = configurations.v8Android
}
doFirst {
jsconfig.files.each { f ->
copy {
from zipTree(f)
into jsEngineLibDir
include "jni/**/*"
// remove 'jni/'
eachFile { fcd ->
fcd.relativePath = new RelativePath(true, fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
}
}
}

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

task copyFilesJSHeaders {
copy
{
from "${rootDir}/../../node_modules/jsc-android/dist/include"
include "*"
into "${jsEngineBaseDir}/include/JavaScriptCore"
}
copy
{
from "${rootDir}/../../node_modules/v8-android/dist/include"
include "**/*"
into "${jsEngineIncDir}"
}
}

preBuild.dependsOn(copyFiles)
preBuild.dependsOn(copyFilesJSHeaders)

4 changes: 2 additions & 2 deletions Apps/Playground/Scripts/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
{
"title": "LightFalloff",
"playgroundId": "#20OAV9#201",
"playgroundId": "#20OAV9#11218",
"referenceImage": "lightFalloff.png"
},
{
Expand All @@ -207,7 +207,7 @@
{
"title": "Capsule",
"renderCount": 10,
"playgroundId": "#JAFIIU#2",
"playgroundId": "#JAFIIU#4",
"referenceImage": "CreateCapsule.png"
},
{
Expand Down
10 changes: 10 additions & 0 deletions Apps/UnitTests/Android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle/
.idea/
local.properties

app/.cxx/
app/build/
app/src/main/assets

build/
110 changes: 110 additions & 0 deletions Apps/UnitTests/Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
plugins {
id 'com.android.application'
}

def jsEngine = "V8"
if (project.hasProperty("jsEngine")) {
jsEngine = project.property("jsEngine")
}

configurations { natives }

android {
namespace 'com.babylonnative.unittests'
compileSdk 33
ndkVersion = "21.4.7075529"

defaultConfig {
applicationId "com.babylonnative.unittests"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

externalNativeBuild {
cmake {
arguments (
"-DANDROID_STL=c++_shared",
"-DNAPI_JAVASCRIPT_ENGINE=${jsEngine}",
"-DJSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR=ON",
)
}
}

if (project.hasProperty("abiFilters")) {
ndk {
abiFilters project.getProperty("abiFilters")
}
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
buildStagingDirectory '../../../../Build/Android'
version '3.22.1+'
}
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation 'com.google.ar:core:1.16.0'
natives 'com.google.ar:core:1.16.0'
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

task copyScripts {
doLast {
// run copy at execution phase because npm command is not done at configuration phase
copy
{
from "../../../node_modules/chai"
include "chai.js"
into 'src/main/assets/Scripts'
}
copy
{
from "../../../node_modules/mocha"
include "mocha.js"
into 'src/main/assets/Scripts'
}
copy
{
from '../../Scripts'
include "*.js"
into 'src/main/assets/Scripts'
}
}
}

// Run copyScripts task after CMake external build
// And make sure merging assets into output is performed after the scripts copy
tasks.whenTaskAdded { task ->
if (task.name == 'mergeDebugNativeLibs') {
task.finalizedBy(copyScripts)
}
if (task.name == 'mergeDebugAssets') {
task.dependsOn(copyScripts)
}
}
21 changes: 21 additions & 0 deletions Apps/UnitTests/Android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading