Skip to content

Commit 6ab7a99

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Pass react build dir to cmake (facebook#33736)
Summary: The ReactAndroid cmake build assumes that the build directory is ReactAndroid/build, but this is not always the case if gradle is configured with a different build location. Instead of assuming the build location in cmake, pass it from gradle. ## Changelog [Android] [Fixed] - Pass react build dir to cmake Pull Request resolved: facebook#33736 Test Plan: Tested in an app with a custom build dir that RN now builds properly after this change. In build.gradle add: ```groovy allprojects { buildDir = "${System.getProperty("user.home")}/.gradle/builds/${rootProject.name}/${project.name}" } ``` Reviewed By: christophpurrer Differential Revision: D36128556 Pulled By: cortinico fbshipit-source-id: cdb8283c93ea7c384ec94cd3e24012220965b6dc
1 parent 93b50be commit 6ab7a99

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ReactAndroid/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ android {
283283
cmake {
284284
arguments "-DREACT_COMMON_DIR=${reactNativeRootDir}/ReactCommon",
285285
"-DREACT_ANDROID_DIR=$projectDir",
286+
"-DREACT_BUILD_DIR=$buildDir",
286287
"-DANDROID_STL=c++_shared",
287288
"-DANDROID_TOOLCHAIN=clang",
288289
"-DANDROID_PLATFORM=android-21"

ReactAndroid/src/main/jni/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ function(add_react_android_subdir relative_path)
1616
add_subdirectory(${REACT_ANDROID_DIR}/${relative_path} ReactAndroid/${relative_path})
1717
endfunction()
1818

19+
function(add_react_build_subdir relative_path)
20+
add_subdirectory(${REACT_BUILD_DIR}/${relative_path} build/${relative_path})
21+
endfunction()
22+
1923
function(add_react_third_party_ndk_subdir relative_path)
20-
add_react_android_subdir(build/third-party-ndk/${relative_path})
24+
add_react_build_subdir(third-party-ndk/${relative_path})
2125
endfunction()
2226

2327
function(add_react_common_subdir relative_path)
@@ -84,7 +88,7 @@ add_react_common_subdir(react/renderer/mapbuffer)
8488
add_react_common_subdir(react/nativemodule/core)
8589

8690
# ReactAndroid JNI targets
87-
add_react_android_subdir(build/generated/source/codegen/jni)
91+
add_react_build_subdir(generated/source/codegen/jni)
8892
add_react_android_subdir(src/main/java/com/facebook/hermes/reactexecutor)
8993
add_react_android_subdir(src/main/jni/first-party/fbjni)
9094
add_react_android_subdir(src/main/jni/first-party/fb)

0 commit comments

Comments
 (0)