Bug 1289294 - Move MT detection to python configure. r=chmanchester
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -454,33 +454,22 @@ def vc_compiler_path(host):
@depends(vc_compiler_path)
@imports('os')
def toolchain_search_path(vc_compiler_path):
if vc_compiler_path:
result = [os.environ.get('PATH')]
result.extend(vc_compiler_path)
+ # We're going to alter PATH for good in windows.configure, but we also
+ # need to do it for the valid_compiler() check below.
+ os.environ['PATH'] = os.pathsep.join(result)
return result
-# Normally, we'd just have CC, etc. set to absolute paths, but the build system
-# doesn't currently handle properly the case where the paths contain spaces.
-# Additionally, there's the issue described further below in valid_compiler().
-@depends(toolchain_search_path)
-@imports('os')
-def alter_path(toolchain_search_path):
- if toolchain_search_path:
- path = os.pathsep.join(toolchain_search_path)
- os.environ['PATH'] = path
- return path
-
-set_config('PATH', alter_path)
-
-
@template
def default_c_compilers(host_or_target):
'''Template defining the set of default C compilers for the host and
target platforms.
`host_or_target` is either `host` or `target` (the @depends functions
from init.configure.
'''
assert host_or_target in (host, target)
--- a/build/moz.configure/windows.configure
+++ b/build/moz.configure/windows.configure
@@ -114,8 +114,82 @@ def valid_windows_sdk_dir(compiler, wind
add_old_configure_assignment(
'WINDOWSSDKDIR',
delayed_getattr(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))
+
+
+option(env='MT', nargs=1, help='Path to the Microsoft Manifest Tool')
+
+@depends_win(valid_windows_sdk_dir)
+@imports(_from='os', _import='environ')
+@imports('platform')
+def sdk_bin_path(valid_windows_sdk_dir):
+ if not valid_windows_sdk_dir:
+ return
+
+ vc_host = {
+ 'x86': 'x86',
+ 'AMD64': 'x64',
+ }.get(platform.machine())
+
+ result = [
+ environ['PATH'],
+ os.path.join(valid_windows_sdk_dir.path, 'bin', vc_host)
+ ]
+ if vc_host == 'x64':
+ result.append(
+ os.path.join(valid_windows_sdk_dir.path, 'bin', 'x86'))
+ return result
+
+
+# Normally, we'd use `MT` instead of `_MT`, but for now, we want MT to only contain
+# mt.exe.
+mt = check_prog('_MT', depends_win()(lambda: ('mt.exe',)), what='mt',
+ input='MT', paths=sdk_bin_path)
+
+
+# Check that MT is not something unexpected like "magnetic tape manipulation
+# utility".
+@depends_win(mt)
+@checking('whether MT is really Microsoft Manifest Tool', lambda x: bool(x))
+@imports('re')
+@imports('subprocess')
+def valid_mt(path):
+ try:
+ out = subprocess.check_output([path]).splitlines()
+ out = '\n'.join(l for l in out
+ if 'Microsoft (R) Manifest Tool' in l)
+ if out:
+ m = re.search(r'(?<=[^!-~])[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+',
+ out)
+ if not m:
+ raise FatalCheckError(
+ 'Unknown version of the Microsoft Manifest Tool')
+ return namespace(
+ path=path,
+ version=Version(m.group(0)),
+ )
+ except subprocess.CalledProcessError:
+ pass
+ raise FatalCheckError('%s is not Microsoft Manifest Tool')
+
+
+set_config('MT', depends_if(valid_mt)(lambda x: os.path.basename(x.path)))
+set_config('MSMANIFEST_TOOL', depends(valid_mt)(lambda x: bool(x)))
+
+
+# Normally, we'd just have CC, etc. set to absolute paths, but the build system
+# doesn't currently handle properly the case where the paths contain spaces.
+# Additionally, there's the issue described in toolchain.configure, in
+# valid_compiler().
+@depends_win(sdk_bin_path)
+@imports('os')
+def alter_path(sdk_bin_path):
+ path = os.pathsep.join(sdk_bin_path)
+ os.environ['PATH'] = path
+ return path
+
+set_config('PATH', alter_path)
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -48,18 +48,16 @@ dnl ====================================
NSPR_VERSION=4
NSPR_MINVER=4.9.2
dnl Set the minimum version of toolkit libs used by mozilla
dnl ========================================================
WINDRES_VERSION=2.14.90
W32API_VERSION=3.14
-MSMANIFEST_TOOL=
-
dnl Set various checks
dnl ========================================================
MISSING_X=
dnl Initialize the Pthread test variables early so they can be
dnl overridden by each platform.
dnl ========================================================
USE_PTHREADS=
@@ -216,36 +214,16 @@ case "$target" in
# See https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics
CXXFLAGS="$CXXFLAGS -Zc:threadSafeInit-"
;;
esac
AC_SUBST(MSVS_VERSION)
AC_SUBST(MSVC_C_RUNTIME_DLL)
AC_SUBST(MSVC_CXX_RUNTIME_DLL)
- dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
- dnl not something else like "magnetic tape manipulation utility".
- MT=${MT-mt.exe}
- MSMT_TOOL=`${MT} 2>&1|grep 'Microsoft (R) Manifest Tool'`
- if test -z "$MSMT_TOOL"; then
- AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
- fi
-
- changequote(,)
- _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
- changequote([,])
- MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
- if test -z "$MSMANIFEST_TOOL_VERSION"; then
- AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
- fi
-
- MSMANIFEST_TOOL=1
- unset MSMT_TOOL
- AC_SUBST(MT)
-
# Check linker version
_LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
_LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION, does not match the compiler suite version, $_CC_SUITE.])
fi
INCREMENTAL_LINKER=1
@@ -2433,17 +2411,16 @@ AC_SUBST(DLL_PREFIX)
AC_SUBST(DLL_SUFFIX)
AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
AC_SUBST(LIB_SUFFIX)
AC_SUBST(OBJ_SUFFIX)
AC_SUBST(BIN_SUFFIX)
AC_SUBST(IMPORT_LIB_SUFFIX)
AC_SUBST(USE_N32)
AC_SUBST(CC_VERSION)
-AC_SUBST(MSMANIFEST_TOOL)
AC_SUBST(MOZ_LINKER)
AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
dnl Set various defines and substitutions
dnl ========================================================
--- a/old-configure.in
+++ b/old-configure.in
@@ -68,18 +68,16 @@ WINDRES_VERSION=2.14.90
W32API_VERSION=3.14
GNOMEUI_VERSION=2.2.0
GCONF_VERSION=1.2.1
STARTUP_NOTIFICATION_VERSION=0.8
DBUS_VERSION=0.60
SQLITE_VERSION=3.13.0
FONTCONFIG_VERSION=2.7.0
-MSMANIFEST_TOOL=
-
dnl Set various checks
dnl ========================================================
MISSING_X=
dnl Initialize the Pthread test variables early so they can be
dnl overridden by each platform.
dnl ========================================================
MOZ_USE_PTHREADS=
@@ -342,36 +340,16 @@ case "$target" in
if test -n "$WIN32_REDIST_DIR"; then
if test ! -d "$WIN32_REDIST_DIR"; then
AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
fi
WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd -W`
fi
- dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
- dnl not something else like "magnetic tape manipulation utility".
- MT=${MT-mt.exe}
- MSMT_TOOL=`${MT} 2>&1|grep 'Microsoft (R) Manifest Tool'`
- if test -z "$MSMT_TOOL"; then
- AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
- fi
-
- changequote(,)
- _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
- changequote([,])
- MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
- if test -z "$MSMANIFEST_TOOL_VERSION"; then
- AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
- fi
-
- MSMANIFEST_TOOL=1
- unset MSMT_TOOL
- AC_SUBST(MT)
-
# Check linker version
_LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
_LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION, does not match the compiler suite version, $_CC_SUITE.])
fi
INCREMENTAL_LINKER=1
@@ -6501,17 +6479,16 @@ AC_SUBST(DLL_PREFIX)
AC_SUBST(DLL_SUFFIX)
AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
AC_SUBST(LIB_SUFFIX)
AC_SUBST(OBJ_SUFFIX)
AC_SUBST(BIN_SUFFIX)
AC_SUBST(IMPORT_LIB_SUFFIX)
AC_SUBST(USE_N32)
AC_SUBST(CC_VERSION)
-AC_SUBST(MSMANIFEST_TOOL)
AC_SUBST(NS_ENABLE_TSF)
AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
AC_SUBST(MOZ_VORBIS)
AC_SUBST(MOZ_TREMOR)
AC_SUBST(MOZ_FFVPX)
AC_SUBST_LIST(FFVPX_ASFLAGS)