Bug 1519030 - Move libav-fft configuration to python configure. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 10 Jan 2019 22:00:41 +0000
changeset 453354 afe2372f339b1b157b8acbe42fa90c672f5bdda1
parent 453353 d74ea40968639bc1b69909554b27ffab0d754b88
child 453355 3f00314f0fe03d7b9166323326a136349b17b736
push id35352
push userdvarga@mozilla.com
push dateFri, 11 Jan 2019 04:12:48 +0000
treeherdermozilla-central@65326bd78f83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1519030
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 1519030 - Move libav-fft configuration to python configure. r=mshal Differential Revision: https://phabricator.services.mozilla.com/D16157
old-configure.in
python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
toolkit/moz.configure
--- a/old-configure.in
+++ b/old-configure.in
@@ -2344,83 +2344,16 @@ if test -n "$MOZ_CRASHREPORTER"; then
     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
       MOZ_CRASHREPORTER_INJECTOR=1
       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
     fi
   fi
 fi
 
 dnl ========================================================
-dnl = libav-fft configuration
-dnl ========================================================
-
-MOZ_LIBAV_FFT=
-
-dnl Turn on libav-fft for 32-bit windows, and all 64-bit supported platforms.
-dnl 32-bit linux/os x have text relocation issues.
-
-case "$OS_ARCH:$CPU_ARCH" in
-  WINNT:x86)
-      MOZ_LIBAV_FFT=1
-  ;;
-  *:x86_64)
-      MOZ_LIBAV_FFT=1
-  ;;
-esac
-
-dnl Detect if we can use yasm to compile libav's assembly
-
-if test -n "$MOZ_LIBAV_FFT" -a -n "$COMPILE_ENVIRONMENT"; then
-  AC_DEFINE(MOZ_LIBAV_FFT)
-  dnl Do we support libav-fft on this platform?
-  case "$OS_ARCH:$CPU_ARCH" in
-  Darwin:x86_64)
-    LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
-  ;;
-  WINNT:x86)
-    LIBAV_FFT_ASFLAGS="-DPIC -DWIN32"
-  ;;
-  WINNT:x86_64)
-    LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
-  ;;
-  *:x86_64)
-    if $CC -E -dM -</dev/null | grep -q __ELF__; then
-      LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DELF"
-    fi
-  ;;
-  *)
-    AC_MSG_ERROR([libav's FFT routines are only available for 32-bit windows or 64-bit x86 based platforms.])
-  ;;
-  esac
-fi
-
-if test -n "$LIBAV_FFT_ASFLAGS"; then
-  dnl If we're on an x86 or x64 system which supports libav-fft's asm routines
-  dnl check for Yasm, and error out if it doesn't exist or we have too old of a
-  dnl version.
-  if test -z "$YASM" ; then
-    AC_MSG_ERROR([Yasm is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed. See https://developer.mozilla.org/en/YASM for more details.])
-  fi
-  dnl Check that we have the right yasm version.  We require 1.0.1 or newer
-  dnl on Linux and 1.1 or newer everywhere else.
-  if test "$OS_ARCH" = "Linux" ; then
-    if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -eq "0" -a "$_YASM_RELEASE" -lt "1" \) ; then
-      AC_MSG_ERROR([Yasm 1.0.1 or greater is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed.  See https://developer.mozilla.org/en/YASM for more details.])
-    fi
-  else
-    if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
-      AC_MSG_ERROR([Yasm 1.1 or greater is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed.  See https://developer.mozilla.org/en/YASM for more details.])
-    fi
-  fi
-elif test -n "$MOZ_LIBAV_FFT" -a "${CPU_ARCH}" != "arm"; then
-  dnl Warn if we're not building either libav or opendl-max optimized routines.
-  AC_MSG_WARN([No assembler or assembly support for libav-fft.  Using unoptimized C routines.])
-fi
-
-dnl ========================================================
 dnl = FFmpeg's ffvpx configuration
 dnl ========================================================
 
 MOZ_FFVPX=
 MOZ_FFVPX_FLACONLY=
 case "$CPU_ARCH" in
   x86|x86_64)
       MOZ_FFVPX=1
@@ -3789,18 +3722,16 @@ AC_SUBST(USE_N32)
 AC_SUBST(CC_VERSION)
 AC_SUBST(NS_ENABLE_TSF)
 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
 
 AC_SUBST(MOZ_FFVPX)
 AC_SUBST(MOZ_FFVPX_FLACONLY)
 AC_SUBST_LIST(FFVPX_ASFLAGS)
-AC_SUBST(MOZ_LIBAV_FFT)
-AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
 AC_SUBST(MOZ_DEVTOOLS)
 
 AC_SUBST(MOZ_PACKAGE_JSSHELL)
 AC_SUBST(MOZ_FOLD_LIBS)
 AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
 
 AC_SUBST(DMG_TOOL)
 
--- a/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
@@ -43,61 +43,70 @@ class TestToolkitMozConfigure(BaseConfig
         self.test_developer_options('42.0')
 
     def test_valid_yasm_version(self):
         out = StringIO()
         sandbox = self.get_sandbox({}, {}, out=out)
         func = sandbox._depends[sandbox['valid_yasm_version']]._func
 
         # Missing yasm is not an error when nothing requires it.
-        func(None, False, False)
+        func(None, False, False, False)
 
         # Any version of yasm works when nothing requires it.
-        func(Version('1.0'), False, False)
+        func(Version('1.0'), False, False, False)
 
         # Any version of yasm works when something requires any version.
-        func(Version('1.0'), True, False)
-        func(Version('1.0'), True, True)
-        func(Version('1.0'), False, True)
+        func(Version('1.0'), True, False, False)
+        func(Version('1.0'), True, True, False)
+        func(Version('1.0'), False, True, False)
 
         # A version of yasm greater than any requirement works.
-        func(Version('1.5'), Version('1.0'), True)
-        func(Version('1.5'), True, Version('1.0'))
-        func(Version('1.5'), Version('1.1'), Version('1.0'))
+        func(Version('1.5'), Version('1.0'), True, False)
+        func(Version('1.5'), True, Version('1.0'), False)
+        func(Version('1.5'), Version('1.1'), Version('1.0'), False)
 
         out.truncate(0)
         with self.assertRaises(SystemExit):
-            func(None, Version('1.0'), False)
+            func(None, Version('1.0'), False, False)
 
         self.assertEqual(
             out.getvalue(),
             'ERROR: Yasm is required to build with vpx, but you do not appear to have Yasm installed.\n'
         )
 
         out.truncate(0)
         with self.assertRaises(SystemExit):
-            func(None, Version('1.0'), Version('1.0'))
+            func(None, Version('1.0'), Version('1.0'), False)
 
         self.assertEqual(
             out.getvalue(),
             'ERROR: Yasm is required to build with jpeg and vpx, but you do not appear to have Yasm installed.\n'
         )
 
         out.truncate(0)
         with self.assertRaises(SystemExit):
-            func(Version('1.0'), Version('1.1'), Version('1.0'))
+            func(None, Version('1.0'), Version('1.0'), Version('1.0'))
+
+        self.assertEqual(
+            out.getvalue(),
+            'ERROR: Yasm is required to build with jpeg, libav and vpx, but you do not appear to have Yasm installed.\n'
+        )
+
+        out.truncate(0)
+        with self.assertRaises(SystemExit):
+            func(Version('1.0'), Version('1.1'), Version('1.0'), False)
 
         self.assertEqual(
             out.getvalue(),
             'ERROR: Yasm version 1.1 or greater is required to build with vpx.\n'
         )
 
         out.truncate(0)
         with self.assertRaises(SystemExit):
-            func(Version('1.0'), True, Version('1.0.1'))
+            func(Version('1.0'), True, Version('1.0.1'), False)
 
         self.assertEqual(
             out.getvalue(),
             'ERROR: Yasm version 1.0.1 or greater is required to build with jpeg.\n'
         )
 
 
 if __name__ == '__main__':
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -1471,22 +1471,53 @@ with only_when(compile_environment):
                 need_yasm = Version('1.1')
 
         return namespace(flags=flags, use_yasm=use_yasm, need_yasm=need_yasm)
 
     set_config('LIBJPEG_TURBO_USE_YASM', in_tree_jpeg.use_yasm)
     set_config('LIBJPEG_TURBO_ASFLAGS', in_tree_jpeg.flags)
 
 
-@depends(yasm_version, in_tree_vpx.need_yasm, in_tree_jpeg.use_yasm)
+# Libav-fft Support
+# ==============================================================
+with only_when(compile_environment):
+    @depends(target)
+    def libav_fft(target):
+        flags = None
+        if target.kernel == 'WINNT' and target.cpu == 'x86':
+            flags = ['-DPIC', '-DWIN32']
+        elif target.cpu == 'x86_64':
+            if target.kernel == 'Darwin':
+                flags = ['-D__x86_64__', '-DPIC', '-DMACHO']
+            elif target.kernel == 'WINNT':
+                flags = ['-D__x86_64__', '-DPIC', '-DWIN64', '-DMSVC']
+            else:
+                flags = ['-D__x86_64__', '-DPIC', '-DELF']
+        if flags:
+            if target.kernel == 'Linux' and target.os == 'GNU':
+                need_yasm = Version('1.0.1')
+            else:
+                need_yasm = Version('1.1')
+            return namespace(flags=flags, need_yasm=need_yasm)
+
+
+    set_config('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
+    set_define('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
+    set_config('LIBAV_FFT_ASFLAGS', libav_fft.flags)
+    add_old_configure_assignment('LIBAV_FFT_ASFLAGS', libav_fft.flags)
+
+
+@depends(yasm_version, in_tree_vpx.need_yasm, in_tree_jpeg.use_yasm,
+         libav_fft.need_yasm)
 @imports(_from='__builtin__', _import='sorted')
-def valid_yasm_version(yasm_version, for_vpx, for_jpeg):
+def valid_yasm_version(yasm_version, for_vpx, for_jpeg, for_libav):
     requires = {
         'vpx': for_vpx,
         'jpeg': for_jpeg,
+        'libav': for_libav,
     }
     requires = {k: v for (k, v) in requires.items() if v}
     if requires and not yasm_version:
         items = sorted(requires.keys())
         if len(items) > 1:
             what = ' and '.join((', '.join(items[:-1]), items[-1]))
         else:
             what = items[0]