Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Fix merge-archives.sh Android build under Windows WSL2 (#575)
Browse files Browse the repository at this point in the history
(cherry picked from commit cd69986)
  • Loading branch information
prothen authored and djee-ms committed Sep 30, 2020
1 parent b305347 commit 821a72b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/build/android/webrtc-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,15 @@ dependencies {
// Merge the libwebrtc.aar containing the Java interop classes for WebRTC
// into the mrwebrtc.aar archive containing the native JNI library.
task mergeLibwebrtcArchive(type: Exec) {
workingDir "$projectDir"
commandLine 'bash','./merge-archives.sh','-m',"$projectDir/build/outputs/aar/mrwebrtc.aar",'-o','./build/outputs/aar/merged/mrwebrtc.aar'
workingDir "$projectDir"
println "Merge-archive.sh: Current working directory is $projectDir"

// For a Windows based path amount of backslashes is irrelevant, adding some more to escape
String WslRobustPath = "$projectDir".replaceAll("\\\\","\\\\\\\\")

commandLine 'bash','./merge-archives.sh','-m',
"$WslRobustPath/build/outputs/aar/mrwebrtc.aar",'-o',
'./build/outputs/aar/merged/mrwebrtc.aar'
}

// Copy the final AAR archive to the Plugins folder of the Unity library.
Expand Down
14 changes: 14 additions & 0 deletions tools/build/android/webrtc-native/merge-archives.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ while getopts l:m:o:vh OPTION; do
esac
done

# Update path for libwebrtc build under WSL2
if grep -q microsoft /proc/version; then
echo "WSL-path-adaption: Detected WSL, adapting path now ..."
echo "Raw: ${MRWEBRTC_AAR}"
echo "Adapt to format: /mnt/\$driveletter\\windows_subdir\\..."
MRWEBRTC_AAR="$(sed -r 's/(^\w):/\/mnt\/\L\1/' <<< ${MRWEBRTC_AAR})"
echo "Intermediate path adaption result: ${MRWEBRTC_AAR}"
echo "Now adapt to format: /mnt/\$driveletter/windows_subdir/..."
MRWEBRTC_AAR="$(sed -r 's/\\/\//g' <<< ${MRWEBRTC_AAR})"
echo "Final path adaption result: ${MRWEBRTC_AAR}"
else
echo "WSL-path-adaption: Detected native Linux, skipping path adaption!"
fi

# Ensure all arguments have reasonable values
verify-arguments

Expand Down

0 comments on commit 821a72b

Please sign in to comment.