-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix build failure on windows in android #47641
fix build failure on windows in android #47641
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @FouadMagdy01, thank you so much to working on this problem and for trying to fix it.
The code looks good, but as a general rule, let's try to minimize the number of changes we are introducing.
In this PR there are some formatting and some comment changes that are not really needed, so it's better to revert those small changes and only keep the changes that are actually needed.
I also left a couple of questions because there are some changes that are not really clear to me.
Thank you again.
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) | ||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you revert this change? A good practice is to try and minimize the changes between the two files and this formatting is not necessary.
Plus it will probably requires us to reformatting because of different internal formatting setting.
# variable is defined if user need to access it. | ||
endif () | ||
|
||
# Glob input source files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing this if
?
-DFOLLY_NO_CONFIG=1 | ||
-Wall | ||
-Werror | ||
# Suppress cpp #error and #warning to prevent build failures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you put back the comment that got removed?
foreach(autolinked_library ${AUTOLINKED_LIBRARIES}) | ||
target_link_libraries(${autolinked_library} common_flags) | ||
endforeach() | ||
# Autolinked libraries if available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put back the removed comment?
if(EXISTS ${BUILD_DIR}/generated/autolinking/src/main/jni/Android-autolinking.cmake) | ||
include(${BUILD_DIR}/generated/autolinking/src/main/jni/Android-autolinking.cmake) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we moving from PROJECT_BUILD_DIR
to just BUILD_DIR
? Which issue does this solve?
target_link_libraries(${CMAKE_PROJECT_NAME} ${AUTOLINKED_LIBRARIES}) | ||
foreach(autolinked_library ${AUTOLINKED_LIBRARIES}) | ||
target_link_libraries(${autolinked_library} common_flags) | ||
endforeach() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please revert the formatting?
-DREACT_NATIVE_APP_COMPONENT_REGISTRATION=${APP_CODEGEN_HEADER}_registerComponentDescriptorsFromCodegen | ||
-DREACT_NATIVE_APP_MODULE_PROVIDER=${APP_CODEGEN_HEADER}_ModuleProvider | ||
) | ||
# Link and build the generated library for codegen if available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please keep the old comment?
target_link_libraries(${CMAKE_PROJECT_NAME} ${APP_CODEGEN_TARGET}) | ||
target_link_libraries(${APP_CODEGEN_TARGET} common_flags) | ||
|
||
# Pass generated header and module provider to OnLoad.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the old comment please
endif() | ||
|
||
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so | ||
# or link against a old prefab target (this is needed for React Native 0.76 on). | ||
# Set REACTNATIVE_MERGED_SO for libraries/apps to selectively link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the old comment please
Hello @cipolleschi thank you for your time and replies |
string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR}) | ||
string(REPLACE "\\" "/" REACT_ANDROID_DIR ${REACT_ANDROID_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Problem: The variables REACT_ANDROID_DIR and BUILD_DIR might also contain backslashes if they are set on a Windows system. These backslashes need to be replaced to avoid similar issues.
-
Solution: Check if the script is running on Windows using if(CMAKE_HOST_WIN32). If it is, replace backslashes with forward slashes for these variables as well:
# Ensure that `input_SRC` paths use forward slashes | ||
foreach(path IN LISTS input_SRC) | ||
string(REPLACE "\\" "/" path "${path}") | ||
endforeach() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Problem: On Windows, backslashes () in file paths are often interpreted by CMake as escape characters, which can lead to invalid sequences like \S. CMake and many other tools can understand forward slashes (/) as directory separators, even on Windows.
-
Solution: Use string(REPLACE "\" "/" path "${path}") to convert all backslashes in the input_SRC file paths to forward slashes. This ensures CMake correctly interprets the paths without treating them as escape sequences.
@cipolleschi Can you look into the changes in This new commit and i am sorry that the comments was removed unintentionally in my first commit this PR is tested on Android running on Windows 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good now! Thank you so much for applying the review's feedback.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in 794154e. |
This pull request was successfully merged by @FouadMagdy01 in 794154e When will my fix make it into a release? | How to file a pick request? |
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
This pull request was successfully merged by @FouadMagdy01 in 08b8300 When will my fix make it into a release? | How to file a pick request? |
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 and This
Changelog:
[INTERNAL] [FIXED] - Corrected invalid escape character in CMake path handling
Test Plan:
To test the changes, I performed the following steps:
fix-cmake-invalid-escape-character
branch.