[x264-devel] Windows: Add support for MSVC compilation with WSL

Henrik Gramner git at videolan.org
Mon May 22 00:01:16 CEST 2017


x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Wed Apr 12 23:26:32 2017 +0200| [bec87ba69421572282e473cf8f2e11c77285ed88] | committer: Henrik Gramner

Windows: Add support for MSVC compilation with WSL

In Windows 10 version 1703 (Creators Update) WSL supports calling native
Windows binaries from the Bash shell, but it requires using full file
names including extension, e.g. `cl.exe` instead of `cl`.

We also don't have access to `cygpath`, so use a simple regex for
converting the dependencies to Unix paths that `make` can understand.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=bec87ba69421572282e473cf8f2e11c77285ed88
---

 configure           | 8 ++++----
 tools/msvsdepend.sh | 6 ++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 9f3ea11d..07de5fa8 100755
--- a/configure
+++ b/configure
@@ -634,7 +634,7 @@ case $host_os in
             SYS="WINDOWS"
             DEVNULL="NUL"
             LDFLAGSCLI="$LDFLAGSCLI -lshell32"
-            [ $compiler = GNU ] && RC="${RC-${cross_prefix}windres}" || RC="${RC-rc}"
+            [ $compiler = GNU ] && RC="${RC-${cross_prefix}windres}" || RC="${RC-rc.exe}"
         fi
         ;;
     sunos*|solaris*)
@@ -1316,13 +1316,13 @@ fi
 DEPMM="${QPRE}MM"
 DEPMT="${QPRE}MT"
 if [ $compiler_style = MS ]; then
-    AR="lib -nologo -out:"
-    LD="link -out:"
+    AR="lib.exe -nologo -out:"
+    LD="link.exe -out:"
     if [ $compiler = ICL ]; then
         AR="xi$AR"
         LD="xi$LD"
     else
-        mslink="$(dirname "$(command -v cl 2>/dev/null)")/link"
+        mslink="$(dirname "$(command -v cl.exe 2>/dev/null)")/link.exe"
         [ -x "$mslink" ] && LD="\"$mslink\" -out:"
     fi
     HAVE_GETOPT_LONG=0
diff --git a/tools/msvsdepend.sh b/tools/msvsdepend.sh
index 568f6112..5d267ab7 100755
--- a/tools/msvsdepend.sh
+++ b/tools/msvsdepend.sh
@@ -23,6 +23,12 @@ if command -v cygpath >/dev/null 2>&1 ; then
     IFS='
 '
     deps="$(cygpath -u -- $deps)"
+elif grep -q 'Microsoft' /proc/sys/kernel/osrelease 2>/dev/null ; then
+    # Running under WSL. We don't have access to cygpath but since the Windows
+    # file system resides under "/mnt/<drive_letter>/" we can simply replace
+    # "C:" with "/mnt/c". This command uses a GNU extension to sed but that's
+    # available on WSL so we don't need to limit ourselves by what POSIX says.
+    deps="$(printf '%s' "$deps" | sed 's/^\([a-zA-Z]\):/\/mnt\/\L\1/')"
 fi
 
 # Escape characters as required to create valid Makefile file names



More information about the x264-devel mailing list