Skip to content

Commit 794154e

Browse files
FouadMagdy01facebook-github-bot
authored andcommitted
fix build failure on windows in android (#47641)
Summary: This pull request addresses a CMake configuration issue where an invalid escape character in file paths caused the build process to fail. Specifically, it resolves the issue in the React Native CMake configuration file where the path separator was incorrectly handled, leading to an error in the build system. the issue is in [This Issue](expo/expo#32955) and [This](expo/expo#32957) ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [INTERNAL] [FIXED] - Corrected invalid escape character in CMake path handling Pull Request resolved: #47641 Test Plan: To test the changes, I performed the following steps: 1. Cloned the repository and checked out the `fix-cmake-invalid-escape-character` branch. 2. Ran the CMake build on a Windows environment where the issue was previously occurring. 3. Verified that the build process completed successfully without the "invalid character escape" error. 4. Ensured that the path handling now works correctly in CMake on Windows platforms. Reviewed By: rshest Differential Revision: D66073896 Pulled By: cipolleschi fbshipit-source-id: bd2a71bb00ce5c5509ed403842c995c32f58f91d
1 parent 89a7238 commit 794154e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ endif(CCACHE_FOUND)
3232

3333
set(BUILD_DIR ${PROJECT_BUILD_DIR})
3434
if(CMAKE_HOST_WIN32)
35-
string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR})
35+
string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR})
36+
string(REPLACE "\\" "/" REACT_ANDROID_DIR ${REACT_ANDROID_DIR})
3637
endif()
3738

3839
if (PROJECT_ROOT_DIR)
@@ -44,6 +45,11 @@ file(GLOB input_SRC CONFIGURE_DEPENDS
4445
${REACT_ANDROID_DIR}/cmake-utils/default-app-setup/*.cpp
4546
${BUILD_DIR}/generated/autolinking/src/main/jni/*.cpp)
4647

48+
# Ensure that `input_SRC` paths use forward slashes
49+
foreach(path IN LISTS input_SRC)
50+
string(REPLACE "\\" "/" path "${path}")
51+
endforeach()
52+
4753
add_library(${CMAKE_PROJECT_NAME} SHARED ${input_SRC})
4854

4955
target_include_directories(${CMAKE_PROJECT_NAME}

0 commit comments

Comments
 (0)