Bug 1519325 - Move D3D compiler DLL detection to python configure. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 11 Jan 2019 22:21:24 +0000
changeset 510672 e69490bbd056d1fd3516cc44f1b2d88700b6d647
parent 510671 0355f47af6ceab050018e9c27fc9d9c4bb944662
child 510673 daf50f25895db073e44d50fecf2e4f6fe873865d
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1519325
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1519325 - Move D3D compiler DLL detection to python configure. r=froydnj MOZ_D3D_CPU_SUFFIX and MOZ_HAS_WINSDK_WITH_D3D are not used in the build, and nothing includes d3d10.h except some angle code in a preprocessed branch that is only taken for a macro we never define, so we don't move the code corresponding to those. We also simplify the detection code, which is convoluted now that it doesn't search for multiple different DLLs. Differential Revision: https://phabricator.services.mozilla.com/D16295
build/moz.configure/windows.configure
old-configure.in
toolkit/moz.configure
--- a/build/moz.configure/windows.configure
+++ b/build/moz.configure/windows.configure
@@ -151,25 +151,16 @@ def valid_windows_sdk_dir(compiler, wind
     return namespace(
         path=sdk.path,
         include=sdk.include,
         lib=sdk.lib,
         version=biggest_version,
     )
 
 
-add_old_configure_assignment(
-    'WINDOWSSDKDIR',
-    valid_windows_sdk_dir.path)
-add_old_configure_assignment(
-    'MOZ_WINSDK_MAXVER',
-    depends(valid_windows_sdk_dir)(
-        lambda x: '0x%04X0000' % x.version if x else None))
-
-
 @imports(_from='mozbuild.shellutil', _import='quote')
 def valid_ucrt_sdk_dir_result(value):
     if value:
         return '%s in %s' % (value.version, quote(value.path))
 
 
 @depends(windows_sdk_dir, 'WINDOWSSDKDIR', c_compiler)
 @checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result)
--- a/old-configure.in
+++ b/old-configure.in
@@ -2160,132 +2160,20 @@ dnl = Universalchardet
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(universalchardet,
 [  --disable-universalchardet
                           Disable universal encoding detection],
   MOZ_UNIVERSALCHARDET=,
   MOZ_UNIVERSALCHARDET=1 )
 
 dnl ========================================================
-dnl = ANGLE OpenGL->D3D translator for WebGL
-dnl = * only applies to win32 (and then, not MINGW)
+dnl Gamepad support
 dnl ========================================================
 
-MOZ_ANGLE_RENDERER=
-MOZ_D3D_CPU_SUFFIX=
-MOZ_HAS_WINSDK_WITH_D3D=
-MOZ_D3DCOMPILER_VISTA_DLL=
-MOZ_D3DCOMPILER_VISTA_DLL_PATH=
-
 if test "$COMPILE_ENVIRONMENT" ; then
-case "$target_os" in
-*mingw*)
-    MOZ_ANGLE_RENDERER=1
-    ;;
-esac
-
-# The DirectX SDK libraries are split into x86 and x64 sub-directories
-case "${target_cpu}" in
-i*86)
-  MOZ_D3D_CPU_SUFFIX=x86
-  ;;
-x86_64)
-  MOZ_D3D_CPU_SUFFIX=x64
-  ;;
-aarch64)
-  MOZ_D3D_CPU_SUFFIX=arm
-  ;;
-esac
-
-dnl ========================================================
-dnl D3D compiler DLL
-dnl ========================================================
-MOZ_FOUND_D3D_COMPILERS=
-
-if test -n "$MOZ_ANGLE_RENDERER"; then
-  if test -z "$MOZ_D3D_CPU_SUFFIX"; then
-    AC_MSG_ERROR([Couldn't determine MOZ_D3D_CPU_SUFFIX.])
-  fi
-
-  ######################################
-  # Find _46+ for use by Vista+.
-
-  # Find a D3D compiler DLL in a Windows SDK.
-  MOZ_D3DCOMPILER_VISTA_DLL=
-  if test "$OS_ARCH" != "$HOST_OS_ARCH"; then
-    MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_47.dll
-    AC_MSG_RESULT([Assuming D3D compiler will be in fxc2.])
-  else
-    case "$MOZ_WINSDK_MAXVER" in
-    0x0603*|0x0A00*)
-      MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_47.dll
-      AC_MSG_RESULT([Found D3D compiler in Windows SDK.])
-    ;;
-    esac
-  fi
-
-  if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
-    # We have a name, now track down the path.
-    if test -n "$WINDOWSSDKDIR"; then
-      MOZ_D3DCOMPILER_VISTA_DLL_PATH="$WINDOWSSDKDIR/Redist/D3D/$MOZ_D3D_CPU_SUFFIX/$MOZ_D3DCOMPILER_VISTA_DLL"
-      if test -f "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
-        AC_MSG_RESULT([Found MOZ_D3DCOMPILER_VISTA_DLL_PATH: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
-        MOZ_HAS_WINSDK_WITH_D3D=1
-      elif test "$target_cpu" = "aarch64" -a "$MOZ_D3DCOMPILER_VISTA_DLL" = "d3dcompiler_47.dll"; then
-        AC_MSG_RESULT([AArch64 Windows includes d3dcompiler DLLs])
-        MOZ_D3DCOMPILER_VISTA_DLL_PATH=
-      else
-        AC_MSG_RESULT([MOZ_D3DCOMPILER_VISTA_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
-        AC_MSG_ERROR([Windows SDK at "$WINDOWSSDKDIR" appears broken. Try updating to MozillaBuild 1.9 final or higher.])
-        MOZ_D3DCOMPILER_VISTA_DLL_PATH=
-      fi
-    else
-      MOZ_D3DCOMPILER_VISTA_DLL_PATH="$(dirname $FXC)/$MOZ_D3DCOMPILER_VISTA_DLL"
-      if test -f "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
-        AC_MSG_RESULT([Found MOZ_D3DCOMPILER_VISTA_DLL_PATH: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
-      else
-        AC_MSG_RESULT([MOZ_D3DCOMPILER_VISTA_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
-        AC_MSG_ERROR([fxc2 or "$MOZ_D3DCOMPILER_VISTA_DLL" seem to be missing from the expected location.])
-        MOZ_D3DCOMPILER_VISTA_DLL_PATH=
-      fi
-    fi
-  else
-    if test "$OS_ARCH" = "$HOST_OS_ARCH"; then
-      AC_MSG_ERROR([Couldn't find Windows SDK 8.1 or higher needed for ANGLE.])
-    else
-      AC_MSG_ERROR([We should need "$MOZ_D3DCOMPILER_VISTA_DLL" for ANGLE in Linux MinGW build, but we didn't look for it.])
-    fi
-  fi
-
-  if test -z "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
-    MOZ_D3DCOMPILER_VISTA_DLL=
-  fi
-
-  # On mingw, check if headers are provided by toolchain.
-  if test -n "$GNU_CC"; then
-    MOZ_CHECK_HEADER(d3d10.h, MOZ_HAS_WINSDK_WITH_D3D=1)
-  fi
-
-  ######################################
-  # Check that we found what we needed.
-  MOZ_FOUND_A_D3D_COMPILER=
-
-  if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
-    MOZ_FOUND_A_D3D_COMPILER=1
-    AC_MSG_RESULT([Found d3dcompiler DLL for Vista+: $MOZ_D3DCOMPILER_VISTA_DLL])
-  fi
-
-  if test -z "MOZ_FOUND_A_D3D_COMPILER"; then
-    AC_MSG_ERROR([Couldn't find an acceptable D3D compiler DLL.])
-  fi
-fi # MOZ_ANGLE_RENDERER
-
-dnl ========================================================
-dnl Gamepad support
-dnl ========================================================
 
 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
 if test "$OS_TARGET" = "Linux"; then
     MOZ_CHECK_HEADER([linux/joystick.h])
     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
     fi
 fi
@@ -3379,22 +3267,16 @@ AC_SUBST(MOZ_UNIVERSALCHARDET)
 AC_SUBST(MOZ_SPELLCHECK)
 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
 AC_SUBST(MOZ_CRASHREPORTER)
 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
 AC_SUBST(MOZ_STUB_INSTALLER)
 AC_SUBST(MOZ_ENABLE_SIGNMAR)
 AC_SUBST(MOZ_UPDATER)
 
-AC_SUBST(MOZ_ANGLE_RENDERER)
-AC_SUBST(MOZ_D3D_CPU_SUFFIX)
-AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
-AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL)
-AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL_PATH)
-
 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
 AC_SUBST(ENABLE_STRIP)
 AC_SUBST(PKG_SKIP_STRIP)
 AC_SUBST(STRIP_FLAGS)
 AC_SUBST(INCREMENTAL_LINKER)
 
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -1298,17 +1298,16 @@ set_config('MOZ_LAYOUT_DEBUGGER', depend
 
 # Shader Compiler for Windows (and MinGW Cross Compile)
 # ==============================================================
 
 with only_when(compile_environment):
     fxc = check_prog('FXC', ('fxc.exe', 'fxc2.exe'), when=depends(target)
                      (lambda t: t.kernel == 'WINNT'),
                      paths=sdk_bin_path)
-    add_old_configure_assignment('FXC', fxc)
     wine = check_prog('WINE', ['wine'], when=depends(target, host)
                       (lambda t, h: t.kernel == 'WINNT' and h.kernel == 'Linux'))
 
 
 # VPX
 # ===
 
 with only_when(compile_environment):
@@ -1536,8 +1535,49 @@ def valid_yasm_version(yasm_version, for
 
     versioned = {k: v for (k, v) in requires.items() if v is not True}
     by_version = sorted(versioned.items(), key=lambda x: x[1])
     if by_version:
         what, version = by_version[-1]
         if yasm_version < version:
             die('Yasm version %s or greater is required to build with %s.'
                 % (version, what))
+
+
+# ANGLE OpenGL->D3D translator for WebGL
+# ==============================================================
+
+with only_when(compile_environment & target_is_windows):
+    def d3d_compiler_dll_result(value):
+        if not value.path:
+            return 'provided by the OS'
+        return value.path
+
+    @depends(target, valid_windows_sdk_dir, fxc)
+    @checking('for D3D compiler DLL', d3d_compiler_dll_result)
+    @imports('os.path')
+    def d3d_compiler_dll(target, windows_sdk_dir, fxc):
+        suffix = {
+            'x86_64': 'x64',
+        }.get(target.cpu, target.cpu)
+
+        name = 'd3dcompiler_47.dll'
+
+        if target.cpu == 'aarch64':
+            # AArch64 Windows comes with d3dcompiler_47.dll installed
+            return namespace(name=name, path=None)
+
+        if windows_sdk_dir:
+            path = os.path.join(windows_sdk_dir.path, 'Redist', 'D3D', suffix, name)
+            error_extra = 'in Windows SDK at {}'.format(windows_sdk_dir.path)
+        else:
+            path = os.path.join(os.path.dirname(fxc), name)
+            error_extra = 'alongside FXC at {}'.format(fxc)
+
+        if os.path.exists(path):
+            return namespace(name=name, path=path)
+        die('Could not find {} {}'.format(name, error_extra))
+
+
+    set_config('MOZ_ANGLE_RENDERER', True)
+    set_config('MOZ_D3DCOMPILER_VISTA_DLL', d3d_compiler_dll.name,
+               when=d3d_compiler_dll.path)
+    set_config('MOZ_D3DCOMPILER_VISTA_DLL_PATH', d3d_compiler_dll.path)