Skip to content

Commit

Permalink
fix: work-around long path issues on windows (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwgray authored Apr 16, 2024
1 parent f98971e commit 4468f9e
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/android/build.gradle b/android/build.gradle
index 88ea6a5b7b32dca55eeedc5b4bf255157742abdf..c1ba2dd18f2b1af7d880f5cf9c27d08638ac0221 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,5 +1,6 @@
import java.nio.file.Paths
import com.android.Version
+import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform

def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
def androidManifestPath = agpVersion >= 7 ? 'src/main/AndroidManifest.xml' : 'src/hasNamespace/AndroidManifest.xml'
@@ -72,11 +73,27 @@ static def findNodeModules(baseDir) {

def nodeModules = findNodeModules(projectDir)

+static def findTools(baseDir) {
+ def basePath = baseDir.toPath().normalize()
+ while (basePath) {
+ def toolsPath = Paths.get(basePath.toString(), "tools")
+ if (toolsPath.toFile().exists()) {
+ return toolsPath.toString()
+ }
+ basePath = basePath.getParent()
+ }
+ throw new GradleException("react-native-vision-camera: Failed to find tools/ path!")
+}
+
+def toolsDir = findTools(projectDir)
+
def hasWorklets = !safeExtGetBool('VisionCamera_disableFrameProcessors', false) && findProject(":react-native-worklets-core") != null
logger.warn("[VisionCamera] react-native-worklets-core ${hasWorklets ? "found" : "not found"}, Frame Processors ${hasWorklets ? "enabled" : "disabled"}!")

def enableCodeScanner = safeExtGetBool('VisionCamera_enableCodeScanner', false)

+def os = DefaultNativePlatform.currentOperatingSystem;
+
repositories {
google()
mavenCentral()
@@ -118,9 +135,17 @@ android {
externalNativeBuild {
cmake {
cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all"
- arguments "-DANDROID_STL=c++_shared",
- "-DNODE_MODULES_DIR=${nodeModules}",
- "-DENABLE_FRAME_PROCESSORS=${hasWorklets ? "ON" : "OFF"}"
+ if (os.isWindows()) {
+ arguments "-DANDROID_STL=c++_shared",
+ "-DNODE_MODULES_DIR=${nodeModules}",
+ "-DENABLE_FRAME_PROCESSORS=${hasWorklets ? "ON" : "OFF"}",
+ "-DCMAKE_MAKE_PROGRAM=${toolsDir}\\windows\\ninja.exe",
+ "-DCMAKE_OBJECT_PATH_MAX=1024"
+ } else {
+ arguments "-DANDROID_STL=c++_shared",
+ "-DNODE_MODULES_DIR=${nodeModules}",
+ "-DENABLE_FRAME_PROCESSORS=${hasWorklets ? "ON" : "OFF"}"
+ }
abiFilters (*reactNativeArchitectures())
}
}
2 changes: 1 addition & 1 deletion examples/objectdetection/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
6 changes: 3 additions & 3 deletions examples/objectdetection/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ PODS:
- React-jsi (= 0.73.6)
- React-logger (= 0.73.6)
- React-perflogger (= 0.73.6)
- ReactNativeMediaPipe (0.1.0):
- ReactNativeMediaPipe (0.2.0):
- glog
- MediaPipeTasksVision (= 0.10.5)
- RCT-Folly (= 2022.05.16.00)
Expand Down Expand Up @@ -1406,11 +1406,11 @@ SPEC CHECKSUMS:
React-runtimescheduler: 9636eee762c699ca7c85751a359101797e4c8b3b
React-utils: d16c1d2251c088ad817996621947d0ac8167b46c
ReactCommon: 2aa35648354bd4c4665b9a5084a7d37097b89c10
ReactNativeMediaPipe: 094adc68f6cdcdbe1fd52a9917ca8fb4f5b0ef28
ReactNativeMediaPipe: 92850eb7623b4bb0d6e8fe90c5e5781b42ccba00
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
VisionCamera: 6c8ca7d04fc62fafccd8f8ad584e96f5303671f5
Yoga: 805bf71192903b20fc14babe48080582fee65a80

PODFILE CHECKSUM: 106c37d775a4ea3a9fa9744362f0af5ba16aac0e

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,7 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down Expand Up @@ -658,11 +654,7 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
"typescript": "^5.2.2"
},
"resolutions": {
"@types/react": "^18.2.44"
"@types/react": "^18.2.44",
"react-native-vision-camera@^3.8.2": "patch:react-native-vision-camera@npm%3A3.9.2#./.yarn/patches/react-native-vision-camera-npm-3.9.2-3b35d90475.patch",
"react-native-vision-camera@^3.9.2": "patch:react-native-vision-camera@npm%3A3.9.2#./.yarn/patches/react-native-vision-camera-npm-3.9.2-3b35d90475.patch"
},
"peerDependencies": {
"react": "*",
Expand Down
Binary file added tools/windows/ninja.exe
Binary file not shown.
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17456,31 +17456,31 @@ __metadata:
languageName: unknown
linkType: soft

"react-native-vision-camera@npm:^3.8.2":
version: 3.9.1
resolution: "react-native-vision-camera@npm:3.9.1"
"react-native-vision-camera@npm:3.9.2":
version: 3.9.2
resolution: "react-native-vision-camera@npm:3.9.2"
peerDependencies:
react: "*"
react-native: "*"
react-native-worklets-core: "*"
peerDependenciesMeta:
react-native-worklets-core:
optional: true
checksum: c700931932fa09437687bb8165091121677e79e0525730b65fc7ca5dbc526ea4f24916f255261e1d212ad82a020a1f00585c7f9aafe9c720b2f0ea52c25261a2
checksum: b69beca5bcc486c6e4f9b11199ba46cc8552be2bb46a8b1f74851c9563f88eedf851d9c61299e2d3e507029398281a7fcbc4e2183af3ee39d75a6194bcfaf757
languageName: node
linkType: hard

"react-native-vision-camera@npm:^3.9.2":
"react-native-vision-camera@patch:react-native-vision-camera@npm%3A3.9.2#./.yarn/patches/react-native-vision-camera-npm-3.9.2-3b35d90475.patch::locator=react-native-mediapipe%40workspace%3A.":
version: 3.9.2
resolution: "react-native-vision-camera@npm:3.9.2"
resolution: "react-native-vision-camera@patch:react-native-vision-camera@npm%3A3.9.2#./.yarn/patches/react-native-vision-camera-npm-3.9.2-3b35d90475.patch::version=3.9.2&hash=71d0d6&locator=react-native-mediapipe%40workspace%3A."
peerDependencies:
react: "*"
react-native: "*"
react-native-worklets-core: "*"
peerDependenciesMeta:
react-native-worklets-core:
optional: true
checksum: b69beca5bcc486c6e4f9b11199ba46cc8552be2bb46a8b1f74851c9563f88eedf851d9c61299e2d3e507029398281a7fcbc4e2183af3ee39d75a6194bcfaf757
checksum: b0d758c5b13b9cc9083fb6db4db0da8eb7d454bad6adbc332467326635c91ed2238bc83460b1bfe840579710c5fb954e01eeb40daf67f661485a9e3b761af838
languageName: node
linkType: hard

Expand Down

0 comments on commit 4468f9e

Please sign in to comment.