Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .github/jobs/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,34 @@ jobs:
parameters:
vmImage: ${{ parameters.vmImage }}

- script: |
set -euo pipefail
ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-}}"
if [ -z "$ANDROID_SDK_ROOT" ]; then
echo "ANDROID_SDK_ROOT or ANDROID_HOME must be set" >&2
exit 1
fi

if [ -x "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
elif [ -x "$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager" ]; then
SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager"
elif [ -x "$ANDROID_SDK_ROOT/tools/bin/sdkmanager" ]; then
SDKMANAGER="$ANDROID_SDK_ROOT/tools/bin/sdkmanager"
else
echo "Unable to locate sdkmanager under $ANDROID_SDK_ROOT" >&2
exit 1
fi

echo "Installing Android NDK version $(NDK_VERSION) using $SDKMANAGER"
SDK_ARGS=("--sdk_root=$ANDROID_SDK_ROOT")

set +o pipefail
yes | "$SDKMANAGER" "${SDK_ARGS[@]}" --licenses >/dev/null
yes | "$SDKMANAGER" "${SDK_ARGS[@]}" --install "ndk;$(NDK_VERSION)"
set -o pipefail
displayName: 'Install Android NDK $(NDK_VERSION)'

- task: JavaToolInstaller@0
inputs:
versionSpec: '17'
Expand Down
28 changes: 28 additions & 0 deletions .github/jobs/android_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,34 @@ jobs:
parameters:
vmImage: ${{ parameters.vmImage }}

- script: |
set -euo pipefail
ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-}}"
if [ -z "$ANDROID_SDK_ROOT" ]; then
echo "ANDROID_SDK_ROOT or ANDROID_HOME must be set" >&2
exit 1
fi

if [ -x "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
elif [ -x "$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager" ]; then
SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager"
elif [ -x "$ANDROID_SDK_ROOT/tools/bin/sdkmanager" ]; then
SDKMANAGER="$ANDROID_SDK_ROOT/tools/bin/sdkmanager"
else
echo "Unable to locate sdkmanager under $ANDROID_SDK_ROOT" >&2
exit 1
fi

echo "Installing Android NDK version $(NDK_VERSION) using $SDKMANAGER"
SDK_ARGS=("--sdk_root=$ANDROID_SDK_ROOT")

set +o pipefail
yes | "$SDKMANAGER" "${SDK_ARGS[@]}" --licenses >/dev/null
yes | "$SDKMANAGER" "${SDK_ARGS[@]}" --install "ndk;$(NDK_VERSION)"
set -o pipefail
displayName: 'Install Android NDK $(NDK_VERSION)'

- script: |
echo Install Android image
echo 'y' | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-27;default;x86_64'
Expand Down
50 changes: 37 additions & 13 deletions Apps/Playground/Android/BabylonNative/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ if (project.hasProperty("UNITY_BUILD")) {
}
def arcore_libpath = "${buildDir}/arcore-native"

def deviceAbis = project.hasProperty("ARM64Only") ? ["arm64-v8a"] : ["arm64-v8a", "armeabi-v7a", "x86"]
def xrSimulatorAbis = ["arm64-v8a"]

configurations { natives }

android {
Expand All @@ -31,16 +34,15 @@ android {
defaultConfig {
minSdk 25

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
ndkVersion "23.1.7779620"
ndkVersion "28.2.13676358"
if (project.hasProperty("NDK_VERSION")) {
def NDKVersion = project.property("NDK_VERSION")
ndkVersion "${NDK_VERSION}"
}
externalNativeBuild {
cmake {
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
arguments "-DANDROID_STL=c++_shared",
"-DENABLE_PCH=OFF",
"-DGRAPHICS_API=${graphics_api}",
Expand All @@ -51,18 +53,39 @@ android {
"-DBABYLON_DEBUG_TRACE=ON"
}
}
ndk {
if (project.hasProperty("ARM64Only")) {
abiFilters "arm64-v8a"
} else {
abiFilters "arm64-v8a", "armeabi-v7a", "x86"
}
}
packagingOptions {
exclude '**/libarcore_sdk_c.so'
}
}

flavorDimensions "runtime"
productFlavors {
device {
dimension "runtime"
ndk {
abiFilters.addAll(deviceAbis)
}
externalNativeBuild {
cmake {
abiFilters.clear()
abiFilters.addAll(deviceAbis)
}
}
}
androidXrSimulator {
dimension "runtime"
ndk {
abiFilters.addAll(xrSimulatorAbis)
}
externalNativeBuild {
cmake {
abiFilters.clear()
abiFilters.addAll(xrSimulatorAbis)
}
}
}
}

externalNativeBuild {
cmake {
version '3.19.6+'
Expand Down Expand Up @@ -92,10 +115,11 @@ dependencies {
// ARCore library
implementation 'com.google.ar:core:1.14.0'
natives 'com.google.ar:core:1.14.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
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'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.babylonnative;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
31 changes: 25 additions & 6 deletions Apps/Playground/Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,41 @@ if (project.hasProperty("UNITY_BUILD")) {
}
def arcore_libpath = "${buildDir}/arcore-native"

def deviceAbis = project.hasProperty("ARM64Only") ? ["arm64-v8a"] : ["arm64-v8a", "armeabi-v7a", "x86"]
def xrSimulatorAbis = ["arm64-v8a"]

configurations { natives }

android {
compileSdkVersion 29
compileSdk 34

defaultConfig {
applicationId "com.android.babylonnative.playground"
minSdkVersion "${platformVersion}"
targetSdkVersion 29
ndkVersion "23.1.7779620"
minSdk platformVersion
targetSdk 34
ndkVersion "28.2.13676358"
if (project.hasProperty("NDK_VERSION")) {
def NDKVersion = project.property("NDK_VERSION")
ndkVersion "${NDK_VERSION}"
}
}

flavorDimensions "runtime"
productFlavors {
device {
dimension "runtime"
ndk {
abiFilters.addAll(deviceAbis)
}
}
androidXrSimulator {
dimension "runtime"
ndk {
abiFilters.addAll(xrSimulatorAbis)
}
}
}

packagingOptions {
jniLibs {
pickFirsts += ['lib/*/libv8android.so', 'lib/*/libjsc.so', 'lib/*/libBabylonNativeJNI.so', 'lib/*/libc++_shared.so']
Expand Down Expand Up @@ -62,8 +81,8 @@ dependencies {
implementation project(':BabylonNative')
natives 'com.google.ar:core:1.14.0'

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
}

// Extracts the shared libraries from aars in the natives configuration.
Expand Down
1 change: 1 addition & 0 deletions Apps/Playground/Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/playground_activity">
<activity android:name="PlaygroundActivity"
android:exported="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="orientation|keyboardHidden|screenSize">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.view.View;

import com.library.babylonnative.BabylonView;
Expand Down
2 changes: 2 additions & 0 deletions Apps/Playground/Android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# jsEngine=JavaScriptCore
android.useAndroidX=true
android.enableJetifier=true
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ FetchContent_Declare(ios-cmake
GIT_TAG 4.5.0)
FetchContent_Declare(JsRuntimeHost
GIT_REPOSITORY https://github.com/BabylonJS/JsRuntimeHost.git
GIT_TAG ef57990dc5533990b2bb194978a12f8c8d83565c)
GIT_TAG c726f284ab906f2f535ac17c3c49cc18c0ea5267
PATCH_COMMAND ${CMAKE_COMMAND}
-Dpatch_file=${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/Patches/JsRuntimeHost/v8inspector-utf16-vector.patch
-Dsource_dir=<SOURCE_DIR>
-P ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/Patches/JsRuntimeHost/apply_patch.cmake)
FetchContent_Declare(SPIRV-Cross
GIT_REPOSITORY https://github.com/BabylonJS/SPIRV-Cross.git
GIT_TAG 6abfcf066d171e9ade7604d91381ebebe4209edc)
Expand Down
36 changes: 36 additions & 0 deletions Dependencies/Patches/JsRuntimeHost/apply_patch.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.21)

if(NOT DEFINED source_dir)
message(FATAL_ERROR "source_dir not provided")
endif()

if(NOT DEFINED patch_file)
message(FATAL_ERROR "patch_file not provided")
endif()

execute_process(
COMMAND git -C "${source_dir}" apply --check "${patch_file}"
RESULT_VARIABLE check_result
OUTPUT_VARIABLE check_output
ERROR_VARIABLE check_error)
if(check_result EQUAL 0)
execute_process(
COMMAND git -C "${source_dir}" apply "${patch_file}"
RESULT_VARIABLE apply_result
OUTPUT_VARIABLE apply_output
ERROR_VARIABLE apply_error)
if(NOT apply_result EQUAL 0)
message(FATAL_ERROR "Failed to apply ${patch_file}: ${apply_error}")
endif()
else()
execute_process(
COMMAND git -C "${source_dir}" apply --reverse --check "${patch_file}"
RESULT_VARIABLE reverse_result
OUTPUT_VARIABLE reverse_output
ERROR_VARIABLE reverse_error)
if(reverse_result EQUAL 0)
message(STATUS "Patch ${patch_file} already applied")
else()
message(FATAL_ERROR "Failed to validate ${patch_file}: ${check_error}")
endif()
endif()
13 changes: 13 additions & 0 deletions Dependencies/Patches/JsRuntimeHost/v8inspector-utf16-vector.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/Core/AppRuntime/V8Inspector/Source/V8InspectorAgent.cpp
+++ b/Core/AppRuntime/V8Inspector/Source/V8InspectorAgent.cpp
@@ -426,8 +426,8 @@
}
v8::Local<v8::String> string_value = v8::Local<v8::String>::Cast(value);
int len = string_value->Length();
- std::basic_string<uint16_t> buffer(len, '\0');
- string_value->Write(v8::Isolate::GetCurrent(), &buffer[0], 0, len);
+ std::vector<uint16_t> buffer(len, 0);
+ string_value->Write(v8::Isolate::GetCurrent(), buffer.data(), 0, len);
return v8_inspector::StringBuffer::create(
v8_inspector::StringView(buffer.data(), len));
}
Loading
Loading