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

Fix merge-archives.sh Android build under Windows WSL2 #575

Merged
merged 2 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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