]> granicus.if.org Git - libx264/commitdiff
Windows: Add support for MSVC compilation with WSL
authorHenrik Gramner <henrik@gramner.com>
Wed, 12 Apr 2017 21:26:32 +0000 (23:26 +0200)
committerHenrik Gramner <henrik@gramner.com>
Sun, 21 May 2017 20:41:06 +0000 (22:41 +0200)
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.

configure
tools/msvsdepend.sh

index 9f3ea11dbeeb5caf5cda77cf35cd386e9c021e4b..07de5fa86426bf6f63f12fb6a7b14a5f7f89876c 100755 (executable)
--- 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
index 568f6112fabaf37e8a44559a886d3cfebd4fd449..5d267ab75e6c8b0f6c373112968610de59bb69bb 100755 (executable)
@@ -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