From 08b830054812f4011becbbacdf1525701225df39 Mon Sep 17 00:00:00 2001 From: Fouad Magdy Date: Mon, 18 Nov 2024 02:38:32 -0800 Subject: [PATCH] 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](https://github.com/expo/expo/issues/32955) and [This](https://github.com/expo/expo/issues/32957) ## Changelog: [INTERNAL] [FIXED] - Corrected invalid escape character in CMake path handling Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- .../cmake-utils/ReactNative-application.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake b/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake index 805ef1111ded66..1ff4c4fc533e24 100644 --- a/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake +++ b/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake @@ -32,13 +32,19 @@ endif(CCACHE_FOUND) set(BUILD_DIR ${PROJECT_BUILD_DIR}) if(CMAKE_HOST_WIN32) - string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR}) + string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR}) + string(REPLACE "\\" "/" REACT_ANDROID_DIR ${REACT_ANDROID_DIR}) endif() file(GLOB input_SRC CONFIGURE_DEPENDS ${REACT_ANDROID_DIR}/cmake-utils/default-app-setup/*.cpp ${BUILD_DIR}/generated/autolinking/src/main/jni/*.cpp) +# Ensure that `input_SRC` paths use forward slashes +foreach(path IN LISTS input_SRC) + string(REPLACE "\\" "/" path "${path}") +endforeach() + add_library(${CMAKE_PROJECT_NAME} SHARED ${input_SRC}) target_include_directories(${CMAKE_PROJECT_NAME}