fix(android): resolve two Windows build failures — bash path and CMake/Ninja absolute path#1040
Open
kevinthelago wants to merge 1 commit intosoftware-mansion:mainfrom
Conversation
…solute path issue
On Windows, two problems block the Android build:
1. Gradle's downloadPrebuiltBinaries task calls 'bash' which resolves
to the WSL relay (C:\Windows\System32\bash.exe). If WSL has no
distro installed, this fails with:
execvpe(/bin/bash) failed: No such file or directory
Fix: detect Windows via Os.isFamily(Os.FAMILY_WINDOWS) and use
Git Bash (C:\Program Files\Git\usr\bin\bash.exe) instead.
2. CMake/Ninja generates object file paths from absolute source file
paths. On Windows, Ninja converts the drive letter colon (C:) to
an underscore (C_), producing a path like:
CMakeFiles/react-native-audio-api.dir/C_/Users/.../audioapi
which it cannot mkdir, failing with:
ninja: error: mkdir(...C_/Users/...): No such file or directory
Fix: convert absolute glob results to relative paths via
file(RELATIVE_PATH) before passing them to add_library, so Ninja
creates simple relative object directories with no drive letter.
Fixes software-mansion#784 (Ninja mkdir error on Windows)
Fixes software-mansion#1012 (bash not found on Windows)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Building the Android library on Windows fails in two distinct ways:
1.
downloadPrebuiltBinaries— bash not foundGradle calls
commandLine 'bash'which on Windows resolves toC:\Windows\System32\bash.exe, the WSL relay. If WSL has no distro installed this throws:Tracked in #1012.
2.
buildCMakeDebug— Ninja cannot mkdir object directoriesCMake/Ninja derives object file directories from absolute source paths. On Windows, Ninja converts the drive letter colon (
C:) to an underscore (C_), producing:That path cannot be
mkdir'd, so the build fails with:Tracked in #784.
Fix
android/build.gradle— detect Windows viaOs.isFamily(Os.FAMILY_WINDOWS)and use Git Bash (C:\Program Files\Git\usr\bin\bash.exe) instead of the systembash. The Unix path remains unchanged.android/src/main/cpp/audioapi/CMakeLists.txt— after globbing source files into*_ABSvariables, convert each absolute path to a path relative toCMAKE_CURRENT_SOURCE_DIRusingfile(RELATIVE_PATH). Ninja then creates simple relative object directories with no drive letter, and the build proceeds normally.Test plan