Bug 1255305 - Move --host and --target to moz.configure. r=chmanchester

With all the things that still depend on all the variables derived from
--host and --target in both old-configure and moz.build, we still need
to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc.

Eventually, we'd settle on the output of split_triplet.

This /tries/ to preserve the current values for all these variables,
while also trying to make things a little more consistent. It also
effectively rejects OSes such as HPUX or AIX, because it is unclear
the decades old accumulated scripts related to them still do anything
useful, and we might as well have them start again from scratch, which,
in the coming weeks, will be even easier.
This commit is contained in:
Mike Hommey 2016-03-11 22:57:15 +09:00
parent 6278d4028c
commit d33300555c
5 changed files with 170 additions and 370 deletions

View File

@ -263,6 +263,166 @@ def shell(mozillabuild):
return shell
# Host and target systems
# ==============================================================
option('--host', nargs=1, help='Define the system type performing the build')
option('--target', nargs=1,
help='Define the system type where the resulting executables will be '
'used')
@template
def split_triplet(triplet):
# The standard triplet is defined as
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# There is also a quartet form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# But we can consider the "KERNEL-OPERATING_SYSTEM" as one.
cpu, manufacturer, os = triplet.split('-', 2)
# Autoconf uses config.sub to validate and canonicalize those triplets,
# but the granularity of its results has never been satisfying to our
# use, so we've had our own, different, canonicalization. We've also
# historically not been very consistent with how we use the canonicalized
# values. Hopefully, this will help us make things better.
# The tests are inherited from our decades-old autoconf-based configure,
# which can probably be improved/cleaned up because they are based on a
# mix of uname and config.guess output, while we now only use the latter,
# which presumably has a cleaner and leaner output. Let's refine later.
os = os.replace('/', '_')
if 'android' in os:
canonical_os = 'Android'
canonical_kernel = 'Linux'
elif os.startswith('linux'):
canonical_os = 'GNU'
canonical_kernel = 'Linux'
elif os.startswith('kfreebsd') and os.endswith('-gnu'):
canonical_os = 'GNU'
canonical_kernel = 'kFreeBSD'
elif os.startswith('gnu'):
canonical_os = canonical_kernel = 'GNU'
elif os.startswith('mingw'):
canonical_os = canonical_kernel = 'WINNT'
elif os.startswith('darwin'):
canonical_os = canonical_kernel = 'Darwin'
elif os.startswith('dragonfly'):
canonical_os = canonical_kernel = 'DragonFly'
elif os.startswith('freebsd'):
canonical_os = canonical_kernel = 'FreeBSD'
elif os.startswith('netbsd'):
canonical_os = canonical_kernel = 'NetBSD'
elif os.startswith('openbsd'):
canonical_os = canonical_kernel = 'OpenBSD'
else:
error('Unknown OS: %s' % os)
# The CPU granularity is probably not enough. Moving more things from
# old-configure will tell us if we need more
if cpu.endswith('86') or (cpu.startswith('i') and '86' in cpu):
canonical_cpu = 'x86'
elif cpu in ('s390', 's390x', 'x86_64', 'ia64'):
canonical_cpu = cpu
elif cpu in ('powerpc64', 'ppc64', 'powerpc64le', 'ppc64le'):
canonical_cpu = 'ppc64'
elif cpu in ('powerpc', 'ppc', 'rs6000') or cpu.startswith('powerpc'):
canonical_cpu = 'ppc'
elif cpu in ('Alpha', 'alpha', 'ALPHA'):
canonical_cpu = 'Alpha'
elif cpu.startswith('hppa') or cpu == 'parisc':
canonical_cpu = 'hppa'
elif cpu.startswith('sparc') or cpu == 'sun4u':
canonical_cpu = 'sparc'
elif cpu.startswith('arm'):
canonical_cpu = 'arm'
elif cpu in ('mips', 'mipsel'):
canonical_cpu = 'mips32'
elif cpu in ('mips64', 'mips64el'):
canonical_cpu = 'mips64'
elif cpu.startswith('aarch64'):
canonical_cpu = 'aarch64'
else:
canonical_cpu = cpu
return namespace(
alias=triplet,
cpu=canonical_cpu,
kernel=canonical_kernel,
os=canonical_os,
raw_cpu=cpu,
)
@depends('--host', shell)
@advanced
def host(value, shell):
if not value:
import subprocess
config_guess = os.path.join(os.path.dirname(__file__), '..',
'autoconf', 'config.guess')
host = subprocess.check_output([shell, config_guess]).strip()
else:
host = value[0]
return split_triplet(host)
@depends('--target', host)
def target(value, host):
if not value:
return host
return split_triplet(value[0])
@depends(host, target)
def host_and_target_for_old_configure(host, target):
# Autoconf needs these set
add_old_configure_arg('--host=%s' % host.alias)
add_old_configure_arg('--target=%s' % target.alias)
# These variables are for compatibility with the current moz.builds and
# old-configure. Eventually, we'll want to canonicalize better.
@depends(target)
def target_variables(target):
if target.kernel == 'kFreeBSD':
os_target = 'GNU/kFreeBSD'
os_arch = 'GNU_kFreeBSD'
elif target.kernel == 'Linux' and target.os == 'GNU':
os_target = target.kernel
os_arch = target.kernel
else:
os_target = target.os
os_arch = target.kernel
add_old_configure_assignment('OS_TARGET', os_target)
set_config('OS_TARGET', os_target)
add_old_configure_assignment('OS_ARCH', os_arch)
set_config('OS_ARCH', os_arch)
if target.os == 'Darwin' and target.cpu == 'x86':
os_test = 'i386'
else:
os_test = target.raw_cpu
add_old_configure_assignment('OS_TEST', os_test)
set_config('OS_TEST', os_test)
add_old_configure_assignment('CPU_ARCH', target.cpu)
set_config('CPU_ARCH', target.cpu)
if target.cpu in ('x86', 'x86_64'):
set_config('INTEL_ARCHITECTURE', '1')
@depends(host)
def host_variables(host):
if host.kernel == 'kFreeBSD':
os_arch = 'GNU_kFreeBSD'
else:
os_arch = host.kernel
add_old_configure_assignment('HOST_OS_ARCH', os_arch)
set_config('HOST_OS_ARCH', os_arch)
# The application/project to build
# ==============================================================
option('--enable-application', nargs=1, env='MOZ_BUILD_APP',
help='Application to build. Same as --enable-project.')

View File

@ -274,10 +274,8 @@ def old_configure_options(*options):
'--enable-xterm-updates',
'--enable-xul',
'--enable-zipwriter',
'--host',
'--no-create',
'--prefix',
'--target',
'--with-adjust-sdk-keyfile',
'--with-android-cxx-stl',
'--with-android-distribution-directory',

View File

@ -100,3 +100,11 @@ def deprecated_option(*args, **kwargs):
return deprecated
return decorator
# from mozbuild.util import ReadOnlyNamespace as namespace
@template
@advanced
def namespace(**kwargs):
from mozbuild.util import ReadOnlyNamespace
return ReadOnlyNamespace(**kwargs)

View File

@ -691,82 +691,8 @@ USE_DEPENDENT_LIBS=1
_PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
if test -n "$CROSS_COMPILE"; then
OS_TARGET="${target_os}"
OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
case "${target_os}" in
linux*) OS_ARCH=Linux OS_TARGET=Linux ;;
kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU/kFreeBSD ;;
gnu*) OS_ARCH=GNU ;;
solaris*) OS_ARCH=SunOS ;;
mingw*) OS_ARCH=WINNT OS_TARGET=WINNT ;;
darwin*) OS_ARCH=Darwin OS_TARGET=Darwin ;;
dragonfly*) OS_ARCH=DragonFly OS_TARGET=DragonFly ;;
freebsd*) OS_ARCH=FreeBSD OS_TARGET=FreeBSD ;;
netbsd*) OS_ARCH=NetBSD OS_TARGET=NetBSD ;;
openbsd*) OS_ARCH=OpenBSD OS_TARGET=OpenBSD ;;
esac
case "${target}" in
*-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
esac
else
OS_TARGET=`uname -s`
OS_ARCH=`uname -s | sed -e 's|/|_|g'`
fi
# Before this used `uname -m` when not cross compiling
# but that breaks when you have a 64 bit kernel with a 32 bit userland.
OS_TEST="${target_cpu}"
HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
#######################################################################
# Master "Core Components" macros for getting the OS target #
#######################################################################
#
# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
# cross-compilation.
#
#
# Define and override various archtecture-specific variables, including
# HOST_OS_ARCH
# OS_ARCH
# OS_TEST
# OS_TARGET
#
case "$HOST_OS_ARCH" in
mingw*)
HOST_OS_ARCH=WINNT
;;
darwin*)
HOST_OS_ARCH=Darwin
;;
linux*)
HOST_OS_ARCH=Linux
;;
kfreebsd*-gnu)
HOST_OS_ARCH=GNU_kFreeBSD
;;
gnu*)
HOST_OS_ARCH=GNU
;;
dragonfly*)
HOST_OS_ARCH=DragonFly
;;
freebsd*)
HOST_OS_ARCH=FreeBSD
;;
netbsd*)
HOST_OS_ARCH=NetBSD
;;
openbsd*)
HOST_OS_ARCH=OpenBSD
;;
solaris*)
HOST_OS_ARCH=SunOS
SunOS)
SOLARIS_SUNPRO_CC=
SOLARIS_SUNPRO_CXX=
if test -z "$GNU_CC"; then
@ -786,115 +712,15 @@ solaris*)
esac
case "$OS_ARCH" in
WINNT)
if test -z "$CROSS_COMPILE" ; then
OS_TEST=`uname -p`
fi
;;
Windows_NT)
OS_ARCH=WINNT
OS_TARGET=WINNT
;;
MINGW*_NT*)
OS_ARCH=WINNT
OS_TARGET=WINNT
;;
AIX)
OS_TEST=${target_cpu}
if test -z "$GNU_CC"; then
if test "`$CC -qversion 2>&1 | egrep -c 'IBM XL'`" != "0"; then
AIX_IBM_XLC=1
fi
fi
;;
Darwin)
case "${target_cpu}" in
powerpc*)
OS_TEST=ppc
;;
i*86*)
OS_TEST=i386
;;
x86_64)
OS_TEST=x86_64
;;
*)
if test -z "$CROSS_COMPILE" ; then
OS_TEST=`uname -p`
fi
;;
esac
;;
esac
# Only set CPU_ARCH if we recognize the value of OS_TEST
case "$OS_TEST" in
*86 | i86pc)
CPU_ARCH=x86
;;
powerpc64 | ppc64 | powerpc64le | ppc64le)
CPU_ARCH=ppc64
;;
powerpc | ppc | rs6000)
CPU_ARCH=ppc
;;
Alpha | alpha | ALPHA)
CPU_ARCH=Alpha
;;
s390)
CPU_ARCH=s390
;;
s390x)
CPU_ARCH=s390x
;;
hppa* | parisc)
CPU_ARCH=hppa
;;
sun4u | sparc*)
CPU_ARCH=sparc
;;
x86_64 | ia64)
CPU_ARCH="$OS_TEST"
;;
arm*)
CPU_ARCH=arm
;;
mips|mipsel)
CPU_ARCH="mips32"
;;
mips64|mips64el)
CPU_ARCH="mips64"
;;
aarch64*)
CPU_ARCH=aarch64
;;
esac
if test -z "$OS_TARGET"; then
OS_TARGET=$OS_ARCH
fi
dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
dnl ===============================================================
INTEL_ARCHITECTURE=
case "$OS_TEST" in
x86_64|i?86)
INTEL_ARCHITECTURE=1
esac
dnl Configure platform-specific CPU architecture compiler options.
dnl ==============================================================
@ -3404,17 +3230,11 @@ AC_SUBST(HOST_AR_FLAGS)
AC_SUBST(HOST_LD)
AC_SUBST(HOST_RANLIB)
AC_SUBST(HOST_BIN_SUFFIX)
AC_SUBST(HOST_OS_ARCH)
AC_SUBST(TARGET_CPU)
AC_SUBST(TARGET_VENDOR)
AC_SUBST(TARGET_OS)
AC_SUBST(TARGET_XPCOM_ABI)
AC_SUBST(OS_TARGET)
AC_SUBST(OS_ARCH)
AC_SUBST(OS_TEST)
AC_SUBST(CPU_ARCH)
AC_SUBST(INTEL_ARCHITECTURE)
AC_SUBST(WRAP_LDFLAGS)
AC_SUBST(MKSHLIB)

View File

@ -894,82 +894,8 @@ USE_DEPENDENT_LIBS=1
_PLATFORM_DEFAULT_TOOLKIT=cairo-gtk3
if test -n "$CROSS_COMPILE"; then
OS_TARGET="${target_os}"
OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
case "${target_os}" in
linux*) OS_ARCH=Linux OS_TARGET=Linux ;;
kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU/kFreeBSD ;;
gnu*) OS_ARCH=GNU ;;
solaris*) OS_ARCH=SunOS ;;
mingw*) OS_ARCH=WINNT OS_TARGET=WINNT ;;
darwin*) OS_ARCH=Darwin OS_TARGET=Darwin ;;
dragonfly*) OS_ARCH=DragonFly OS_TARGET=DragonFly ;;
freebsd*) OS_ARCH=FreeBSD OS_TARGET=FreeBSD ;;
netbsd*) OS_ARCH=NetBSD OS_TARGET=NetBSD ;;
openbsd*) OS_ARCH=OpenBSD OS_TARGET=OpenBSD ;;
esac
case "${target}" in
*-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
esac
else
OS_TARGET=`uname -s`
OS_ARCH=`uname -s | sed -e 's|/|_|g'`
fi
# Before this used `uname -m` when not cross compiling
# but that breaks when you have a 64 bit kernel with a 32 bit userland.
OS_TEST="${target_cpu}"
HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
#######################################################################
# Master "Core Components" macros for getting the OS target #
#######################################################################
#
# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
# cross-compilation.
#
#
# Define and override various archtecture-specific variables, including
# HOST_OS_ARCH
# OS_ARCH
# OS_TEST
# OS_TARGET
#
case "$HOST_OS_ARCH" in
mingw*)
HOST_OS_ARCH=WINNT
;;
darwin*)
HOST_OS_ARCH=Darwin
;;
linux*)
HOST_OS_ARCH=Linux
;;
kfreebsd*-gnu)
HOST_OS_ARCH=GNU_kFreeBSD
;;
gnu*)
HOST_OS_ARCH=GNU
;;
dragonfly*)
HOST_OS_ARCH=DragonFly
;;
freebsd*)
HOST_OS_ARCH=FreeBSD
;;
netbsd*)
HOST_OS_ARCH=NetBSD
;;
openbsd*)
HOST_OS_ARCH=OpenBSD
;;
solaris*)
HOST_OS_ARCH=SunOS
SunOS)
SOLARIS_SUNPRO_CC=
SOLARIS_SUNPRO_CXX=
if test -z "$GNU_CC"; then
@ -988,112 +914,6 @@ solaris*)
;;
esac
case "$OS_ARCH" in
WINNT)
if test -z "$CROSS_COMPILE" ; then
OS_TEST=`uname -p`
fi
;;
Windows_NT)
OS_ARCH=WINNT
OS_TARGET=WINNT
;;
MINGW*_NT*)
OS_ARCH=WINNT
OS_TARGET=WINNT
;;
AIX)
OS_TEST=${target_cpu}
;;
Darwin)
case "${target_cpu}" in
powerpc*)
OS_TEST=ppc
;;
i*86*)
OS_TEST=i386
;;
x86_64)
OS_TEST=x86_64
;;
*)
if test -z "$CROSS_COMPILE" ; then
OS_TEST=`uname -p`
fi
;;
esac
;;
esac
# Only set CPU_ARCH if we recognize the value of OS_TEST
case "$OS_TEST" in
*86 | i86pc)
CPU_ARCH=x86
;;
powerpc64 | ppc64 | powerpc64le | ppc64le)
CPU_ARCH=ppc64
;;
powerpc | ppc | rs6000)
CPU_ARCH=ppc
;;
Alpha | alpha | ALPHA)
CPU_ARCH=Alpha
;;
s390)
CPU_ARCH=s390
;;
s390x)
CPU_ARCH=s390x
;;
hppa* | parisc)
CPU_ARCH=hppa
;;
sun4u | sparc*)
CPU_ARCH=sparc
;;
x86_64 | ia64)
CPU_ARCH="$OS_TEST"
;;
arm*)
CPU_ARCH=arm
;;
mips|mipsel)
CPU_ARCH="mips32"
;;
mips64|mips64el)
CPU_ARCH="mips64"
;;
aarch64*)
CPU_ARCH=aarch64
;;
esac
if test -z "$OS_TARGET"; then
OS_TARGET=$OS_ARCH
fi
dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
dnl ===============================================================
INTEL_ARCHITECTURE=
case "$OS_TEST" in
x86_64|i?86)
INTEL_ARCHITECTURE=1
esac
dnl Configure platform-specific CPU architecture compiler options.
dnl ==============================================================
if test "$COMPILE_ENVIRONMENT"; then
@ -8671,7 +8491,6 @@ AC_SUBST(HOST_AR_FLAGS)
AC_SUBST(HOST_LD)
AC_SUBST(HOST_RANLIB)
AC_SUBST(HOST_BIN_SUFFIX)
AC_SUBST(HOST_OS_ARCH)
AC_SUBST(RUSTFLAGS)
@ -8679,11 +8498,6 @@ AC_SUBST(TARGET_CPU)
AC_SUBST(TARGET_VENDOR)
AC_SUBST(TARGET_OS)
AC_SUBST(TARGET_XPCOM_ABI)
AC_SUBST(OS_TARGET)
AC_SUBST(OS_ARCH)
AC_SUBST(OS_TEST)
AC_SUBST(CPU_ARCH)
AC_SUBST(INTEL_ARCHITECTURE)
AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
AC_SUBST(HAVE_X86_AVX2)