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

Commit 821a72b

Browse files
prothendjee-ms
authored andcommitted
Fix merge-archives.sh Android build under Windows WSL2 (#575)
(cherry picked from commit cd69986)
1 parent b305347 commit 821a72b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

tools/build/android/webrtc-native/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@ dependencies {
7878
// Merge the libwebrtc.aar containing the Java interop classes for WebRTC
7979
// into the mrwebrtc.aar archive containing the native JNI library.
8080
task mergeLibwebrtcArchive(type: Exec) {
81-
workingDir "$projectDir"
82-
commandLine 'bash','./merge-archives.sh','-m',"$projectDir/build/outputs/aar/mrwebrtc.aar",'-o','./build/outputs/aar/merged/mrwebrtc.aar'
81+
workingDir "$projectDir"
82+
println "Merge-archive.sh: Current working directory is $projectDir"
83+
84+
// For a Windows based path amount of backslashes is irrelevant, adding some more to escape
85+
String WslRobustPath = "$projectDir".replaceAll("\\\\","\\\\\\\\")
86+
87+
commandLine 'bash','./merge-archives.sh','-m',
88+
"$WslRobustPath/build/outputs/aar/mrwebrtc.aar",'-o',
89+
'./build/outputs/aar/merged/mrwebrtc.aar'
8390
}
8491

8592
// Copy the final AAR archive to the Plugins folder of the Unity library.

tools/build/android/webrtc-native/merge-archives.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ while getopts l:m:o:vh OPTION; do
131131
esac
132132
done
133133

134+
# Update path for libwebrtc build under WSL2
135+
if grep -q microsoft /proc/version; then
136+
echo "WSL-path-adaption: Detected WSL, adapting path now ..."
137+
echo "Raw: ${MRWEBRTC_AAR}"
138+
echo "Adapt to format: /mnt/\$driveletter\\windows_subdir\\..."
139+
MRWEBRTC_AAR="$(sed -r 's/(^\w):/\/mnt\/\L\1/' <<< ${MRWEBRTC_AAR})"
140+
echo "Intermediate path adaption result: ${MRWEBRTC_AAR}"
141+
echo "Now adapt to format: /mnt/\$driveletter/windows_subdir/..."
142+
MRWEBRTC_AAR="$(sed -r 's/\\/\//g' <<< ${MRWEBRTC_AAR})"
143+
echo "Final path adaption result: ${MRWEBRTC_AAR}"
144+
else
145+
echo "WSL-path-adaption: Detected native Linux, skipping path adaption!"
146+
fi
147+
134148
# Ensure all arguments have reasonable values
135149
verify-arguments
136150

0 commit comments

Comments
 (0)