Skip to content

Commit

Permalink
Make sure the -DANDROID compilation flag is always included.
Browse files Browse the repository at this point in the history
Summary:
It seems like starting from AGP 7.4, Android is not including the `-DANDROID` flag
anymore from the NDK toolchain.

As we do have several `#ifdef` logic that takes care of having this macro set,
I'm going to make sure it's always set for both ReactAndroid, hermes-engine
and the template.

Changelog:
[Android] [Fixed] - Make sure the -DANDROID compilation flag is always included

Differential Revision: D45908787

fbshipit-source-id: 04155ddf3bbb58b776c60b6ceb5226b2528bc441
  • Loading branch information
cortinico authored and facebook-github-bot committed May 16, 2023
1 parent 2b932c3 commit fa82c3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ internal object NdkConfiguratorUtils {
// Parameters should be provided in an additive manner (do not override what
// the user provided, but allow for sensible defaults).
val cmakeArgs = ext.defaultConfig.externalNativeBuild.cmake.arguments
if ("-DPROJECT_BUILD_DIR" !in cmakeArgs) {
if ("-DANDROID" !in cmakeArgs) {
cmakeArgs.add("-DANDROID")
}
if (cmakeArgs.none { it.startsWith("-DPROJECT_BUILD_DIR") }) {
cmakeArgs.add("-DPROJECT_BUILD_DIR=${project.buildDir}")
}
if ("-DREACT_ANDROID_DIR" !in cmakeArgs) {
if (cmakeArgs.none { it.startsWith("-DREACT_ANDROID_DIR") }) {
cmakeArgs.add(
"-DREACT_ANDROID_DIR=${extension.reactNativeDir.file("ReactAndroid").get().asFile}")
}
if ("-DANDROID_STL" !in cmakeArgs) {
if (cmakeArgs.none { it.startsWith("-DANDROID_STL") }) {
cmakeArgs.add("-DANDROID_STL=c++_shared")
}

Expand Down
3 changes: 2 additions & 1 deletion packages/react-native/ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ android {
"-DREACT_BUILD_DIR=$buildDir",
"-DANDROID_STL=c++_shared",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_PLATFORM=android-21"
"-DANDROID_PLATFORM=android-21",
"-DANDROID"

targets "jsijniprofiler",
"reactnativeblob",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ android {
arguments "-DHERMES_IS_ANDROID=True"
arguments "-DANDROID_STL=c++_shared"
arguments "-DANDROID_PIE=True"
arguments "-DANDROID"
arguments "-DIMPORT_HERMESC=${new File(hermesBuildDir, "ImportHermesc.cmake").toString()}"
arguments "-DJSI_DIR=${jsiDir}"
arguments "-DHERMES_SLOW_DEBUG=False"
Expand Down

0 comments on commit fa82c3f

Please sign in to comment.