Add support for CL_INCLUDES_PREFIX environment variable for handling localized cl.exe /showIncludes output. (Bug 587372) r=ted a2.0=blocking2.0:final
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 17 Sep 2010 12:29:52 -0700
changeset 54266 fa73c53624741ffc9921702c53aadcb7e50373d0
parent 54265 181294166500dacb178903b21655495abbcc9a48
child 54267 d85d2070d0f89aff3352267840298542ac99f77c
push idunknown
push userunknown
push dateunknown
reviewersted
bugs587372
milestone2.0b7pre
Add support for CL_INCLUDES_PREFIX environment variable for handling localized cl.exe /showIncludes output. (Bug 587372) r=ted a2.0=blocking2.0:final
build/cl.py
config/autoconf.mk.in
configure.in
js/src/build/cl.py
js/src/config/autoconf.mk.in
js/src/configure.in
--- a/build/cl.py
+++ b/build/cl.py
@@ -35,16 +35,18 @@
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
 import os, os.path
 import subprocess
 import sys
 
+CL_INCLUDES_PREFIX = os.environ.get("CL_INCLUDES_PREFIX", "Note: including file:")
+
 def InvokeClWithDependencyGeneration(cmdline):
     target = ""
     # Figure out what the target is
     for arg in cmdline:
         if arg.startswith("-Fo"):
             target = arg[3:]
             break
 
@@ -56,18 +58,18 @@ def InvokeClWithDependencyGeneration(cmd
 
     cmdline += ['-showIncludes']
     cl = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
 
     deps = set()
     for line in cl.stdout:
         # cl -showIncludes prefixes every header with "Note: including file:"
         # and an indentation corresponding to the depth (which we don't need)
-        if line.startswith("Note: including file:"):
-            dep = line[21:].strip()
+        if line.startswith(CL_INCLUDES_PREFIX):
+            dep = line[len(CL_INCLUDES_PREFIX):].strip()
             # We can't handle pathes with spaces properly in mddepend.pl, but
             # we can assume that anything in a path with spaces is a system
             # header and throw it away.
             if dep.find(' ') == -1:
                 deps.add(dep)
         else:
             sys.stdout.write(line) # Make sure we preserve the relevant output
                                    # from cl
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -565,16 +565,18 @@ GLIB_CFLAGS	= @GLIB_CFLAGS@
 GLIB_LIBS	= @GLIB_LIBS@
 GLIB_GMODULE_LIBS	= @GLIB_GMODULE_LIBS@
 LIBIDL_CFLAGS = @LIBIDL_CFLAGS@
 LIBIDL_LIBS = @LIBIDL_LIBS@
 STATIC_LIBIDL = @STATIC_LIBIDL@
 
 MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
 
+export CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
+
 MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
 COMPILER_DEPEND = @COMPILER_DEPEND@
 MDDEPDIR        := @MDDEPDIR@
 CC_WRAPPER = @CC_WRAPPER@
 CXX_WRAPPER = @CXX_WRAPPER@
 
 MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
 
--- a/configure.in
+++ b/configure.in
@@ -8023,16 +8023,25 @@ if test "$_cpp_md_flag"; then
 else
   COMPILER_DEPEND=
   dnl Don't override this for MSVC
   if test -z "$_WIN32_MSVC"; then
     _USE_CPP_INCLUDE_FLAG=
     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
   else
+    echo '#include <stdio.h>' > dummy-hello.c
+    changequote(,)
+    CL_INCLUDES_PREFIX=`"${CC}" -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
+    changequote([,])
+    if test -z "$CL_INCLUDES_PREFIX"; then
+        AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
+    fi
+    AC_SUBST(CL_INCLUDES_PREFIX)
+    rm -f dummy-hello.c
     _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
     dnl cl.py provides dependency generation for MSVC
     CC_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
     CXX_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
     COMPILER_DEPEND=1
   fi
 fi
 fi # MOZ_AUTO_DEPS
--- a/js/src/build/cl.py
+++ b/js/src/build/cl.py
@@ -35,16 +35,18 @@
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
 import os, os.path
 import subprocess
 import sys
 
+CL_INCLUDES_PREFIX = os.environ.get("CL_INCLUDES_PREFIX", "Note: including file:")
+
 def InvokeClWithDependencyGeneration(cmdline):
     target = ""
     # Figure out what the target is
     for arg in cmdline:
         if arg.startswith("-Fo"):
             target = arg[3:]
             break
 
@@ -56,18 +58,18 @@ def InvokeClWithDependencyGeneration(cmd
 
     cmdline += ['-showIncludes']
     cl = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
 
     deps = set()
     for line in cl.stdout:
         # cl -showIncludes prefixes every header with "Note: including file:"
         # and an indentation corresponding to the depth (which we don't need)
-        if line.startswith("Note: including file:"):
-            dep = line[21:].strip()
+        if line.startswith(CL_INCLUDES_PREFIX):
+            dep = line[len(CL_INCLUDES_PREFIX):].strip()
             # We can't handle pathes with spaces properly in mddepend.pl, but
             # we can assume that anything in a path with spaces is a system
             # header and throw it away.
             if dep.find(' ') == -1:
                 deps.add(dep)
         else:
             sys.stdout.write(line) # Make sure we preserve the relevant output
                                    # from cl
--- a/js/src/config/autoconf.mk.in
+++ b/js/src/config/autoconf.mk.in
@@ -273,16 +273,18 @@ DLL_SUFFIX              = @DLL_SUFFIX@
 
 NO_LD_ARCHIVE_FLAGS     = @NO_LD_ARCHIVE_FLAGS@
 
 MOZ_TOOLKIT_REGISTRY_CFLAGS = \
 	$(TK_CFLAGS)
 
 MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
 
+export CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
+
 MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
 COMPILER_DEPEND = @COMPILER_DEPEND@
 MDDEPDIR        := @MDDEPDIR@
 CC_WRAPPER = @CC_WRAPPER@
 CXX_WRAPPER = @CXX_WRAPPER@
 
 MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
 
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -4961,16 +4961,25 @@ if test "$_cpp_md_flag"; then
 else
   COMPILER_DEPEND=
   dnl Don't override this for MSVC
   if test -z "$_WIN32_MSVC"; then
     _USE_CPP_INCLUDE_FLAG=
     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
   else
+    echo '#include <stdio.h>' > dummy-hello.c
+    changequote(,)
+    CL_INCLUDES_PREFIX=`"${CC}" -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
+    changequote([,])
+    if test -z "$CL_INCLUDES_PREFIX"; then
+        AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
+    fi
+    AC_SUBST(CL_INCLUDES_PREFIX)
+    rm -f dummy-hello.c
     _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
     dnl cl.py provides dependency generation for MSVC
     CC_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
     CXX_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
     COMPILER_DEPEND=1
   fi
 fi
 fi # MOZ_AUTO_DEPS