Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
27a4ea4
feat: Add ET library for direct use in C++
JakubGonera Apr 11, 2025
012486f
fix: Revert change development team change
JakubGonera Apr 11, 2025
20478a3
fix: remove ifs for old architecture in cmake
JakubGonera Apr 14, 2025
00e60e2
fix: remove ETInstaller module wrapper
JakubGonera Apr 14, 2025
9b507bb
fix: omit new arch checks in cmake
JakubGonera Apr 14, 2025
be7d5b8
fix: remove new arch checks from gradle
JakubGonera Apr 14, 2025
63b1183
chore: remove additional executorch archive
JakubGonera Apr 17, 2025
94443d0
chore: resolve et 0.6.0 conflict
JakubGonera Apr 17, 2025
504faf4
chore: update c++/ios ET libs
JakubGonera Apr 17, 2025
5d8a5a0
fix: remove unnecessary export
JakubGonera Apr 30, 2025
45a390b
Increase log messages and add ellipsis
JakubGonera May 14, 2025
d38a1df
feat: port style transfer implementation to C++ (#229)
JakubGonera May 20, 2025
792607b
fix: fix exception handling in C++ native code (#244)
JakubGonera May 20, 2025
4d8e2c9
fix: refactor C++ JSI promises (#286)
JakubGonera May 20, 2025
64eb709
fix: generic loading of host functions in C++ (#315)
JakubGonera May 21, 2025
6f94aae
fix: make the host function installation generic (#327)
JakubGonera May 23, 2025
f7fcf64
feat: port image segmentation native code to C++ (#313)
JakubGonera May 27, 2025
092d677
fix: move third-party and fix ET static libs paths
JakubGonera May 28, 2025
cd44c0b
fix: add return type information to forward methods
JakubGonera May 28, 2025
5193a0d
fix: typo
JakubGonera May 29, 2025
19a1373
fix: fix build.gradle
JakubGonera May 29, 2025
116c415
fix: duplicate .so in gradle resolution
JakubGonera May 29, 2025
36a4f64
fix: fix android .so conflict
JakubGonera May 29, 2025
7ec4592
fix: exclude x86 from podspec builds
JakubGonera Jun 3, 2025
3535293
fix: remove a dangling reference exception handling (#357)
JakubGonera Jun 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 10 additions & 4 deletions apps/computer-vision/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ PODS:
- hermes-engine (0.79.2):
- hermes-engine/Pre-built (= 0.79.2)
- hermes-engine/Pre-built (0.79.2)
- opencv-rne (0.1.0)
- opencv-rne (4.11.0)
- RCT-Folly (2024.11.18.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -1399,7 +1399,7 @@ PODS:
- DoubleConversion
- glog
- hermes-engine
- opencv-rne (~> 0.1.0)
- opencv-rne (~> 4.11.0)
- RCT-Folly (= 2024.11.18.00)
- RCTRequired
- RCTTypeSafety
Expand All @@ -1419,6 +1419,7 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- sqlite3
- Yoga
- react-native-image-picker (7.2.3):
- DoubleConversion
Expand Down Expand Up @@ -2041,6 +2042,9 @@ PODS:
- ReactCommon/turbomodule/core
- Yoga
- SocketRocket (0.7.1)
- sqlite3 (3.49.2):
- sqlite3/common (= 3.49.2)
- sqlite3/common (3.49.2)
- Yoga (0.0.0)

DEPENDENCIES:
Expand Down Expand Up @@ -2134,6 +2138,7 @@ SPEC REPOS:
trunk:
- opencv-rne
- SocketRocket
- sqlite3

EXTERNAL SOURCES:
boost:
Expand Down Expand Up @@ -2319,7 +2324,7 @@ SPEC CHECKSUMS:
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
hermes-engine: 314be5250afa5692b57b4dd1705959e1973a8ebe
opencv-rne: 63e933ae2373fc91351f9a348dc46c3f523c2d3f
opencv-rne: 2305807573b6e29c8c87e3416ab096d09047a7a0
RCT-Folly: e78785aa9ba2ed998ea4151e314036f6c49e6d82
RCTDeprecation: 83ffb90c23ee5cea353bd32008a7bca100908f8c
RCTRequired: eb7c0aba998009f47a540bec9e9d69a54f68136e
Expand Down Expand Up @@ -2351,7 +2356,7 @@ SPEC CHECKSUMS:
React-logger: 8edfcedc100544791cd82692ca5a574240a16219
React-Mapbuffer: c3f4b608e4a59dd2f6a416ef4d47a14400194468
React-microtasksnativemodule: 054f34e9b82f02bd40f09cebd4083828b5b2beb6
react-native-executorch: 6939375a7c6c4095724675cfd86a7f9c2efdbaa2
react-native-executorch: 30047a5076fa3c91119618147627d895d87af51b
react-native-image-picker: 8a3f16000e794f5381a7fe47bb48fd8d06741e47
react-native-safe-area-context: 562163222d999b79a51577eda2ea8ad2c32b4d06
react-native-skia: b6cb66e99a953dae6880348c92cfb20a76d90b4f
Expand Down Expand Up @@ -2389,6 +2394,7 @@ SPEC CHECKSUMS:
RNReanimated: afd6a269a47d6f13ba295c46c6c0e14e3cbd0d8a
RNSVG: 794f269526df9ddc1f79b3d1a202b619df0368e3
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
sqlite3: 3c950dc86011117c307eb0b28c4a7bb449dce9f1
Yoga: c758bfb934100bb4bf9cbaccb52557cee35e8bdf

PODFILE CHECKSUM: 12be54799a0524303b792fe9e93fedb70ce87ef7
Expand Down
2 changes: 1 addition & 1 deletion apps/computer-vision/screens/ImageSegmentationScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BottomBar } from '../components/BottomBar';
import { getImage } from '../utils';
import {
useImageSegmentation,
DeeplabLabel,
DEEPLAB_V3_RESNET50,
DeeplabLabel,
} from 'react-native-executorch';
import {
Canvas,
Expand Down
482 changes: 244 additions & 238 deletions apps/llm/ios/Podfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/llm/ios/llm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
Expand Down Expand Up @@ -528,7 +528,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
Expand Down
486 changes: 246 additions & 240 deletions apps/speech-to-text/ios/Podfile.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
Expand Down Expand Up @@ -515,7 +515,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
Expand Down
444 changes: 225 additions & 219 deletions apps/text-embeddings/ios/Podfile.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
Expand Down Expand Up @@ -509,7 +509,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
Expand Down
Binary file added ios/libs/libbackend_coreml-ios-release.a
Binary file not shown.
Binary file added ios/libs/libbackend_coreml-simulator-release.a
Binary file not shown.
Binary file added ios/libs/libbackend_mps-ios-release.a
Binary file not shown.
Binary file added ios/libs/libbackend_mps-simulator-release.a
Binary file not shown.
Binary file added ios/libs/libbackend_xnnpack-ios-release.a
Binary file not shown.
Binary file added ios/libs/libbackend_xnnpack-simulator-release.a
Binary file not shown.
Binary file added ios/libs/libexecutorch-ios-release.a
Binary file not shown.
Binary file added ios/libs/libexecutorch-simulator-release.a
Binary file not shown.
Binary file added ios/libs/libkernels_custom-ios-release.a
Binary file not shown.
Binary file added ios/libs/libkernels_custom-simulator-release.a
Binary file not shown.
Binary file added ios/libs/libkernels_optimized-ios-release.a
Binary file not shown.
Binary file added ios/libs/libkernels_optimized-simulator-release.a
Binary file not shown.
Binary file added ios/libs/libkernels_portable-ios-release.a
Binary file not shown.
Binary file added ios/libs/libkernels_portable-simulator-release.a
Binary file not shown.
Binary file added ios/libs/libkernels_quantized-ios-release.a
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions packages/react-native-executorch/android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.13)
project(RnExecutorch)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 20)

include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
add_compile_options(${folly_FLAGS})

string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")

set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../common")
set(LIBS_DIR "${CMAKE_SOURCE_DIR}/../third-party/android/libs")
set(INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../third-party/include")

add_subdirectory("${ANDROID_CPP_DIR}")
91 changes: 81 additions & 10 deletions packages/react-native-executorch/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.apache.tools.ant.taskdefs.condition.Os

buildscript {
ext {
agp_version = '8.4.2'
Expand All @@ -21,19 +23,20 @@ buildscript {

def reactNativeArchitectures() {
def value = rootProject.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
// react-native-executorch supports only these architectures. This is due to
// Executorch not supporting anything else.
def defaultArchitectures = ["x86_64", "arm64-v8a"]
if(!value) {
return defaultArchitectures
}
def architectures = value.split(",")
return architectures.findAll { it in defaultArchitectures }
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "com.facebook.react"

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RnExecutorch_" + name]
Expand All @@ -52,6 +55,38 @@ def supportsNamespace() {
return (major == 7 && minor >= 3) || major >= 8
}

def safeAppExtGet(prop, fallback) {
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
}

def toPlatformFileString(String path) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
path = path.replace(File.separatorChar, '/' as char)
}
return path
}

def resolveReactNativeDirectory() {
def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)

if (reactNativeLocation !== null) {
return file(reactNativeLocation)
}

// Fallback to node resolver for custom directory structures like monorepos.
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
if(reactNativePackage.exists()) {
return reactNativePackage.parentFile
}

throw new GradleException(
"[RnExecutorch] Unable to resolve react-native location in node_modules. You should project extension property (in `app/build.gradle`) `REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
)
}

def reactNativeRootDir = resolveReactNativeDirectory()

android {
if (supportsNamespace()) {
namespace "com.swmansion.rnexecutorch"
Expand All @@ -63,12 +98,46 @@ android {
}
}

buildFeatures {
prefab true
prefabPublishing true
buildConfig true
}

prefab {
"react-native-executorch" {
headers "src/main/cpp"
}
}

packagingOptions {
excludes = [
"**/libexecutorch.so"
]
}

compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
externalNativeBuild {
cmake {
cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all -fopenmp -static-openmp"
abiFilters (*reactNativeArchitectures())
arguments "-DANDROID_STL=c++_shared",
"-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
"-DBUILD_DIR=${project.buildDir}",
"-DANDROID_TOOLCHAIN=clang"
}
}
}


externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}

buildTypes {
Expand All @@ -85,6 +154,7 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

repositories {
Expand All @@ -101,7 +171,8 @@ dependencies {
//noinspection GradleDynamicVersion
implementation 'com.github.wendykierp:JTransforms:3.1'
implementation "com.facebook.react:react-android:+"
implementation 'org.opencv:opencv:4.10.0'
implementation "com.facebook.react:react-native:+"
implementation 'com.facebook.fbjni:fbjni:0.6.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation("com.github.software-mansion:react-native-executorch:main-SNAPSHOT")
implementation 'org.opencv:opencv:4.10.0'
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
cmake_minimum_required(VERSION 3.13)

file(GLOB_RECURSE ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/*.cpp")
file(GLOB_RECURSE COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/*.cpp" "${COMMON_CPP_DIR}/*.c")

add_library(react-native-executorch SHARED ${ANDROID_CPP_SOURCES} ${COMMON_CPP_SOURCES})

find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)

target_include_directories(
react-native-executorch
PUBLIC
"${COMMON_CPP_DIR}"
"${ANDROID_CPP_DIR}"
"${INCLUDE_DIR}"
"${REACT_NATIVE_DIR}/ReactCommon"
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
)

set(LINK_LIBRARIES
ReactAndroid::jsi
fbjni::fbjni
android
log
)

set(RN_VERSION_LINK_LIBRARIES
ReactAndroid::reactnative
)

# Dependencies:
# ------- Executorch -------

add_library(executorch SHARED IMPORTED)

set_target_properties(executorch PROPERTIES
IMPORTED_LOCATION "${LIBS_DIR}/executorch/${ANDROID_ABI}/libexecutorch.so")

# ------- OpenCV -------

set(OPENCV_LIBS
"${LIBS_DIR}/opencv/${ANDROID_ABI}/libopencv_core.a"
"${LIBS_DIR}/opencv/${ANDROID_ABI}/libopencv_features2d.a"
"${LIBS_DIR}/opencv/${ANDROID_ABI}/libopencv_highgui.a"
"${LIBS_DIR}/opencv/${ANDROID_ABI}/libopencv_imgproc.a"
"${LIBS_DIR}/opencv/${ANDROID_ABI}/libopencv_photo.a"
"${LIBS_DIR}/opencv/${ANDROID_ABI}/libopencv_video.a"
)

if(ANDROID_ABI STREQUAL "arm64-v8a")
set(OPENCV_THIRD_PARTY_LIBS
"${LIBS_DIR}/opencv-third-party/${ANDROID_ABI}/libkleidicv_hal.a"
"${LIBS_DIR}/opencv-third-party/${ANDROID_ABI}/libkleidicv_thread.a"
"${LIBS_DIR}/opencv-third-party/${ANDROID_ABI}/libkleidicv.a"
)
elseif(ANDROID_ABI STREQUAL "x86_64")
set(OPENCV_THIRD_PARTY_LIBS "")
endif()

# --------------

target_link_libraries(
react-native-executorch
${LINK_LIBRARIES}
${RN_VERSION_LINK_LIBRARIES}
${OPENCV_LIBS}
${OPENCV_THIRD_PARTY_LIBS}
executorch
)
Loading
Loading