-
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 building Android on Windows #39190
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.
Amazing, thanks @alespergl for this.
I'm adding a suggestion as I'm a bit scared that this could break other pipelines otherwise.
What do you think?
# Convert input paths to CMake format (with forward slashes) | ||
file(TO_CMAKE_PATH "${REACT_ANDROID_DIR}" REACT_ANDROID_DIR) | ||
file(TO_CMAKE_PATH "${REACT_BUILD_DIR}" REACT_BUILD_DIR) | ||
file(TO_CMAKE_PATH "${REACT_COMMON_DIR}" REACT_COMMON_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.
@alespergl I'm not an expert of CMake, but can we wrap this change in a platform check?
Something like:
if(${CMAKE_SYSTEM_NAME} MATCHES "Win32")
file(TO_CMAKE_PATH "${REACT_ANDROID_DIR}" REACT_ANDROID_DIR)
file(TO_CMAKE_PATH "${REACT_BUILD_DIR}" REACT_BUILD_DIR)
file(TO_CMAKE_PATH "${REACT_COMMON_DIR}" REACT_COMMON_DIR)
endif
I'm scared this could cause harm on other systems, otherwise.
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.
using file(TO_CMAKE_PATH
should actually be correct on every platform.
As the CI is green, we can just merge it 👍
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.
Yes, this operation should be cross-platform.
Note: There is a similar function cmake_path which seems to be preferred, but requires CMake 3.20 or later, whereas the minimum specified in this CMakeLists.txt
is 3.13.
Base commit: b8bf393 |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cortinico merged this pull request in 054ab62. |
Summary: Currently Android fails to build on Windows, because CMake cannot work with native Windows paths that are passed to it as build arguments. This change converts the input paths to the CMake format. ## Changelog: [Android] [Fixed] - Fix building Android on Windows. Pull Request resolved: #39190 Test Plan: Build the React Native Android project on Windows. It should complete successfully. Reviewed By: NickGerleman Differential Revision: D48948140 Pulled By: cortinico fbshipit-source-id: 6d584c2a10e683cdb6df0dd6dcd5875da7e06e2b
Summary:
Currently Android fails to build on Windows, because CMake cannot work with
native Windows paths that are passed to it as build arguments. This change
converts the input paths to the CMake format.
Changelog:
[Android] [Fixed] - Fix building Android on Windows.
Test Plan:
Build the React Native Android project on Windows. It should complete successfully.