Bug 1299919 - Set CPP/CXXCPP from python configure. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 06 Sep 2016 08:22:36 +0900
changeset 410881 7da2407fda35c6d5eca0f2f1ad5a53d7ccfda066
parent 410880 d4ddc0a0cf6d70a72ed580c88baf0fe4cef077bf
child 530616 0e9f0cb31b14187e77f3bf8097eead99f66d5f52
push id28775
push userbmo:mh+mozilla@glandium.org
push dateWed, 07 Sep 2016 01:34:57 +0000
reviewerschmanchester
bugs1299919
milestone51.0a1
Bug 1299919 - Set CPP/CXXCPP from python configure. r?chmanchester
build/autoconf/toolchain.m4
build/moz.configure/toolchain.configure
dom/bindings/GenerateCSS2PropertiesWebIDL.py
js/src/old-configure.in
layout/style/GenerateCSSPropsGenerated.py
old-configure.in
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -1,12 +1,20 @@
 dnl This Source Code Form is subject to the terms of the Mozilla Public
 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+dnl Several autoconf functions AC_REQUIRE AC_PROG_CPP/AC_PROG_CXXCPP,
+dnl meaning they are called even when we don't call them explicitly.
+dnl However, theses checks are not necessary and python configure sets
+dnl the corresponding variables already, so just skip those tests
+dnl entirely.
+define([AC_PROG_CPP],[])
+define([AC_PROG_CXXCPP],[])
+
 AC_DEFUN([MOZ_TOOL_VARIABLES],
 [
 GNU_AS=
 GNU_LD=
 
 GNU_CC=
 GNU_CXX=
 if test "$CC_TYPE" = "gcc"; then
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -749,16 +749,33 @@ def compiler(language, host_or_target, c
 
     def compiler_error():
         raise FatalCheckError('Failed compiling a simple %s source with %s'
                               % (language, what))
 
     valid_compiler.try_compile(check_msg='%s works' % what,
                                onerror=compiler_error)
 
+
+    # Set CPP/CXXCPP for both the build system and old-configure. We don't
+    # to check this works for preprocessing, because we already relied on
+    # $CC -E/$CXX -E doing preprocessing work to validate the compiler in
+    # the first place.
+    if host_or_target == target:
+        pp_var = {
+            'C': 'CPP',
+            'C++': 'CXXCPP',
+        }[language]
+
+        preprocessor = depends_if(valid_compiler)(
+                lambda x: list(x.wrapper) + [x.compiler, '-E'] + list(x.flags))
+
+        set_config(pp_var, preprocessor)
+        add_old_configure_assignment(pp_var, preprocessor)
+
     return valid_compiler
 
 
 c_compiler = compiler('C', target)
 cxx_compiler = compiler('C++', target, c_compiler=c_compiler)
 host_c_compiler = compiler('C', host, other_compiler=c_compiler)
 host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
                              other_compiler=cxx_compiler,
--- a/dom/bindings/GenerateCSS2PropertiesWebIDL.py
+++ b/dom/bindings/GenerateCSS2PropertiesWebIDL.py
@@ -11,17 +11,17 @@ from mozbuild import shellutil
 
 # Generates a line of WebIDL with the given spelling of the property name
 # (whether camelCase, _underscorePrefixed, etc.) and the given array of
 # extended attributes.
 def generateLine(propName, extendedAttrs):
     return "  [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs),
                                                  propName)
 def generate(output, idlFilename, preprocessorHeader):
-    cpp = shellutil.split(buildconfig.substs['CPP'])
+    cpp = list(buildconfig.substs['CPP'])
     cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
     cpp.append(preprocessorHeader)
     preprocessed = subprocess.check_output(cpp)
 
     propList = eval(preprocessed)
     props = ""
     for [name, prop, id, flags, pref, proptype] in propList:
         if "CSS_PROPERTY_INTERNAL" in flags:
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -135,19 +135,16 @@ else
     fi
     if test -z "$HOST_AR_FLAGS"; then
         HOST_AR_FLAGS='$(AR_FLAGS)'
     fi
 fi
 
 MOZ_TOOL_VARIABLES
 
-AC_PROG_CPP
-AC_PROG_CXXCPP
-
 dnl Special win32 checks
 dnl ========================================================
 
 # Target the Windows 8.1 SDK by default
 WINVER=502
 
 case "$target" in
 *-mingw*)
--- a/layout/style/GenerateCSSPropsGenerated.py
+++ b/layout/style/GenerateCSSPropsGenerated.py
@@ -5,17 +5,17 @@
 import sys
 import string
 import argparse
 import subprocess
 import buildconfig
 from mozbuild import shellutil
 
 def get_properties(preprocessorHeader):
-    cpp = shellutil.split(buildconfig.substs['CPP'])
+    cpp = list(buildconfig.substs['CPP'])
     cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
     cpp.append(preprocessorHeader)
     preprocessed = subprocess.check_output(cpp)
     properties = [{"name":p[0], "prop":p[1], "id":p[2],
                    "flags":p[3], "pref":p[4], "proptype":p[5]}
                   for (i, p) in enumerate(eval(preprocessed))]
 
     # Sort the list so that longhand and logical properties are intermingled
--- a/old-configure.in
+++ b/old-configure.in
@@ -236,19 +236,16 @@ else
 fi
 
 if test -n "$MOZ_WINCONSOLE"; then
     AC_DEFINE(MOZ_WINCONSOLE)
 fi
 
 MOZ_TOOL_VARIABLES
 
-AC_PROG_CPP
-AC_PROG_CXXCPP
-
 dnl ========================================================
 dnl Special win32 checks
 dnl ========================================================
 
 WINVER=502
 
 case "$target" in
 *-mingw*)