Bug 1515852 - Move --with-system-jpeg to python configure. r=froydnj

We remove --disable-libjpeg-turbo because that's only useful when Yasm
is too old, and the required version is now almost 8 years old, so we
can reasonably require people to upgrade rather than workaround with a
--disable option.

The valid_yasm_version function can seem overkill, but that's because
future moves of other things to python configure will pile up.

Differential Revision: https://phabricator.services.mozilla.com/D15184

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2018-12-21 15:47:22 +00:00
Родитель c0ee00e2c3
Коммит c683c549a5
4 изменённых файлов: 193 добавлений и 151 удалений

Просмотреть файл

@ -251,7 +251,6 @@ def old_configure_options(*options):
'--with-soft-float',
'--with-system-bz2',
'--with-system-icu',
'--with-system-jpeg',
'--with-system-libevent',
'--with-system-nspr',
'--with-system-nss',

Просмотреть файл

@ -45,7 +45,6 @@ _SUBDIR_CONFIG_ARGS="$ac_configure_args"
dnl Set the version number of the libs included with mozilla
dnl ========================================================
MOZJPEG=62
MOZPNG=10635
NSPR_VERSION=4
NSPR_MINVER=4.19
@ -1639,51 +1638,6 @@ if test -z "$MOZ_SYSTEM_NSS"; then
esac
fi
if test -z "$SKIP_LIBRARY_CHECKS"; then
dnl system JPEG support
dnl ========================================================
MOZ_ARG_WITH_STRING(system-jpeg,
[ --with-system-jpeg[=PFX]
Use system libjpeg [installed at prefix PFX]],
JPEG_DIR=$withval)
_SAVE_CFLAGS=$CFLAGS
_SAVE_LDFLAGS=$LDFLAGS
_SAVE_LIBS=$LIBS
if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
fi
if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
MOZ_SYSTEM_JPEG=
else
AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_SYSTEM_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_SYSTEM_JPEG=)
fi
if test "$MOZ_SYSTEM_JPEG" = 1; then
AC_TRY_COMPILE([ #include <stdio.h>
#include <sys/types.h>
#include <jpeglib.h> ],
[ #if JPEG_LIB_VERSION < $MOZJPEG
#error "Insufficient JPEG library version ($MOZJPEG required)."
#endif
#ifndef JCS_EXTENSIONS
#error "libjpeg-turbo JCS_EXTENSIONS required"
#endif
],
MOZ_SYSTEM_JPEG=1,
AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
fi
CFLAGS=$_SAVE_CFLAGS
LDFLAGS=$_SAVE_LDFLAGS
LIBS=$_SAVE_LIBS
if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_SYSTEM_JPEG" = 1; then
MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
fi
fi # SKIP_LIBRARY_CHECKS
dnl system ZLIB support
dnl ========================================================
MOZ_ZLIB_CHECK([1.2.3])
@ -1752,8 +1706,6 @@ MOZ_AUTH_EXTENSION=1
if test "$MOZ_IOS"; then
MOZ_AUTH_EXTENSION=
fi
LIBJPEG_TURBO_AS=
LIBJPEG_TURBO_ASFLAGS=
MOZ_PREF_EXTENSIONS=1
MOZ_SPELLCHECK=1
MOZ_TOOLKIT_SEARCH=1
@ -2386,96 +2338,6 @@ if test -n "$MOZ_CRASHREPORTER"; then
fi
fi
dnl ========================================================
dnl = libjpeg-turbo configuration
dnl ========================================================
MOZ_LIBJPEG_TURBO=
LIBJPEG_TURBO_USE_YASM=
if test -z "$MOZ_SYSTEM_JPEG"; then
MOZ_LIBJPEG_TURBO=1
fi
MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
[ --disable-libjpeg-turbo Disable optimized jpeg decoding routines],
MOZ_LIBJPEG_TURBO=,
MOZ_LIBJPEG_TURBO=1)
if test "$MOZ_SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
fi
dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
dnl files.
if test -n "$MOZ_LIBJPEG_TURBO" -a -n "$COMPILE_ENVIRONMENT"; then
dnl Do we support libjpeg-turbo on this platform?
case "$OS_ARCH:$CPU_ARCH" in
Darwin:x86)
LIBJPEG_TURBO_ASFLAGS="-DPIC -DMACHO"
;;
Darwin:x86_64)
LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
;;
Darwin:arm*)
;;
WINNT:x86)
LIBJPEG_TURBO_ASFLAGS="-DPIC -DWIN32"
;;
WINNT:x86_64)
LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
;;
WINNT:*)
;;
*:arm)
LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
;;
*:aarch64)
LIBJPEG_TURBO_ASFLAGS="-march=armv8-a"
;;
*:mips32)
LIBJPEG_TURBO_ASFLAGS="-mdspr2"
;;
*:x86)
if $CC -E -dM -</dev/null | grep -q __ELF__; then
LIBJPEG_TURBO_ASFLAGS="-DPIC -DELF"
fi
;;
*:x86_64)
if $CC -E -dM -</dev/null | grep -q __ELF__; then
LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DELF"
fi
;;
esac
fi
if test -n "$LIBJPEG_TURBO_ASFLAGS"; then
case "$CPU_ARCH" in
dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
dnl it doesn't exist or we have too old of a version.
x86_64|x86)
LIBJPEG_TURBO_USE_YASM=1
if test -z "$YASM" ; then
AC_MSG_ERROR([Yasm is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you do not appear to have Yasm installed. Either install it or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder. 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 libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.$_YASM_RELEASE. Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder. 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 libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION. Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder. See https://developer.mozilla.org/en/YASM for more details.])
fi
fi
;;
esac
fi
dnl ========================================================
dnl = libav-fft configuration
dnl ========================================================
@ -3894,11 +3756,8 @@ HOST_CXXFLAGS=`echo \
$_COMPILATION_HOST_CXXFLAGS \
$HOST_CXXFLAGS`
AC_SUBST(MOZ_SYSTEM_JPEG)
AC_SUBST(MOZ_SYSTEM_PNG)
AC_SUBST_LIST(MOZ_JPEG_CFLAGS)
AC_SUBST_LIST(MOZ_JPEG_LIBS)
AC_SUBST_LIST(MOZ_PNG_CFLAGS)
AC_SUBST_LIST(MOZ_PNG_LIBS)
@ -3962,8 +3821,6 @@ AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
AC_SUBST(MOZ_FFVPX)
AC_SUBST(MOZ_FFVPX_FLACONLY)
AC_SUBST_LIST(FFVPX_ASFLAGS)
AC_SUBST(LIBJPEG_TURBO_USE_YASM)
AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
AC_SUBST(MOZ_LIBAV_FFT)
AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
AC_SUBST(MOZ_DEVTOOLS)

Просмотреть файл

@ -6,10 +6,12 @@ from __future__ import absolute_import, print_function, unicode_literals
import os
from StringIO import StringIO
from buildconfig import topsrcdir
from common import BaseConfigureTest
from mozunit import MockedOpen, main
from mozbuild.configure.options import InvalidOptionError
from mozbuild.configure.util import Version
class TestToolkitMozConfigure(BaseConfigureTest):
@ -40,5 +42,63 @@ class TestToolkitMozConfigure(BaseConfigureTest):
def test_developer_options_release(self):
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)
# Any version of yasm works when nothing requires it.
func(Version('1.0'), 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)
# 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'))
out.truncate(0)
with self.assertRaises(SystemExit):
func(None, Version('1.0'), 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'))
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'))
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'))
self.assertEqual(
out.getvalue(),
'ERROR: Yasm version 1.0.1 or greater is required to build with jpeg.\n'
)
if __name__ == '__main__':
main()

Просмотреть файл

@ -1303,21 +1303,21 @@ with only_when(compile_environment):
set_config('MOZ_SYSTEM_LIBVPX', True)
@depends('--with-system-libvpx', target, yasm_version, gnu_as)
def in_tree_vpx(system_libvpx, target, yasm_version, gnu_as):
@depends('--with-system-libvpx', target, gnu_as)
def in_tree_vpx(system_libvpx, target, gnu_as):
if system_libvpx:
return
use_yasm = (target.cpu in ('x86', 'x86_64')) or None
need_yasm = False
arm_asm = (target.cpu == 'arm' and gnu_as) or None
if use_yasm:
if not yasm_version:
die('Yasm is required to build on this architecture.')
if target.kernel == 'WINNT' and yasm_version < '1.1':
die('Yasm 1.1 or greater is required to build libvpx for Windows.')
need_yasm = True
if target.kernel == 'WINNT':
need_yasm = Version('1.1')
return namespace(arm_asm=arm_asm, use_yasm=use_yasm)
return namespace(arm_asm=arm_asm, use_yasm=use_yasm, need_yasm=need_yasm)
# Building with -mfpu=neon requires either the "softfp" or the
@ -1354,3 +1354,129 @@ with only_when(compile_environment):
set_config('VPX_USE_YASM', in_tree_vpx.use_yasm)
set_config('VPX_ASFLAGS', vpx_as_flags)
add_old_configure_assignment('VPX_ASFLAGS', vpx_as_flags)
# JPEG
# ====
with only_when(compile_environment):
option('--with-system-jpeg', nargs='?',
help='Use system libjpeg (installed at given prefix)')
@depends_if('--with-system-jpeg')
def jpeg_flags(value):
if len(value):
return namespace(
cflags=('-I%s/include' % value[0],),
ldflags=('-L%s/lib' % value[0], '-ljpeg'),
)
return namespace(
ldflags=('-ljpeg',),
)
with only_when('--with-system-jpeg'):
check_symbol('jpeg_destroy_compress', flags=jpeg_flags.ldflags,
onerror=lambda: die('--with-system-jpeg requested but symbol '
'jpeg_destroy_compress not found.'))
c_compiler.try_compile(
includes=[
'stdio.h',
'sys/types.h',
'jpeglib.h',
],
body='''
#if JPEG_LIB_VERSION < 62
#error Insufficient JPEG library version
#endif
''',
check_msg='for sufficient jpeg library version',
onerror=lambda: die('Insufficient JPEG library version for '
'--with-system-jpeg (62 required)'),
)
c_compiler.try_compile(
includes=[
'stdio.h',
'sys/types.h',
'jpeglib.h',
],
body='''
#ifndef JCS_EXTENSIONS
#error libjpeg-turbo JCS_EXTENSIONS required
#endif
''',
check_msg='for sufficient libjpeg-turbo JCS_EXTENSIONS',
onerror=lambda: die('libjpeg-turbo JCS_EXTENSIONS required for '
'--with-system-jpeg'),
)
set_config('MOZ_JPEG_CFLAGS', jpeg_flags.cflags)
set_config('MOZ_JPEG_LIBS', jpeg_flags.ldflags)
@depends('--with-system-jpeg', target)
def in_tree_jpeg(system_jpeg, target):
if system_jpeg:
return
flags = ()
use_yasm = None
need_yasm = False
if target.kernel == 'Darwin':
if target.cpu == 'x86':
flags = ('-DPIC', '-DMACHO')
elif target.cpu == 'x86_64':
flags = ('-D__x86_64__', '-DPIC', '-DMACHO')
elif target.kernel == 'WINNT':
if target.cpu == 'x86':
flags = ('-DPIC', '-DWIN32')
elif target.cpu == 'x86_64':
flags = ('-D__x86_64__', '-DPIC', '-DWIN64', '-DMSVC')
elif target.cpu == 'arm':
flags = ('-march=armv7-a', '-mfpu=neon')
elif target.cpu == 'aarch64':
flags = ('-march=armv8-a',)
elif target.cpu == 'mips32':
flags = ('-mdspr2',)
elif target.cpu == 'x86':
flags = ('-DPIC', '-DELF')
elif target.cpu == 'x86_64':
flags = ('-D__x86_64__', '-DPIC', '-DELF')
if target.cpu in ('x86', 'x86_64'):
use_yasm = True
if target.kernel == 'Linux' and target.os == 'GNU':
need_yasm = Version('1.0.1')
else:
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)
@imports(_from='__builtin__', _import='sorted')
def valid_yasm_version(yasm_version, for_vpx, for_jpeg):
requires = {
'vpx': for_vpx,
'jpeg': for_jpeg,
}
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]
die('Yasm is required to build with %s, but you do not appear to have '
'Yasm installed.' % what)
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))