Bug 1618760 - Remove MSVC-specific include hacks in header wrappers. r=dmajor
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 28 Feb 2020 21:41:18 +0000
changeset 516207 622db942c06efdb80b454cf3e8a751d23c318b6c
parent 516206 812c3e2899d778e1a95e09be8090badead9c1ecf
child 516208 376190643b00db7507171aa5fa819b5c50feaf18
push id37167
push usercbrindusan@mozilla.com
push dateSat, 29 Feb 2020 04:04:56 +0000
treeherdermozilla-central@4f2f9bda72ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmajor
bugs1618760
milestone75.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1618760 - Remove MSVC-specific include hacks in header wrappers. r=dmajor Differential Revision: https://phabricator.services.mozilla.com/D64708
config/make-stl-wrappers.py
config/make-windows-h-wrapper.py
config/msvc-stl-wrapper.template.h
config/system_header_util.py
config/windows-h-wrapper.template.h
tools/lint/license.yml
--- a/config/make-stl-wrappers.py
+++ b/config/make-stl-wrappers.py
@@ -1,23 +1,20 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 from __future__ import absolute_import
 from __future__ import print_function
 import os
 import string
 from mozbuild.util import FileAvoidWrite
-from system_header_util import header_path
 
 
 # The 'unused' arg is the output file from the file_generate action. We actually
 # generate all the files in header_list
 
 
 def gen_wrappers(unused, outdir, compiler, template_file, *header_list):
     template = open(template_file, 'r').read()
 
     for header in header_list:
-        path = header_path(header, compiler)
         with FileAvoidWrite(os.path.join(outdir, header)) as f:
-            f.write(string.Template(template).substitute(HEADER=header,
-                                                         HEADER_PATH=path))
+            f.write(string.Template(template).substitute(HEADER=header))
--- a/config/make-windows-h-wrapper.py
+++ b/config/make-windows-h-wrapper.py
@@ -1,17 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import
 import re
 import textwrap
 import string
-from system_header_util import header_path
 
 comment_re = re.compile(r'//[^\n]*\n|/\*.*\*/', re.S)
 decl_re = re.compile(r'''^(.+)\s+        # type
                          (\w+)\s*        # name
                          (?:\((.*)\))?$  # optional param tys
                          ''', re.X | re.S)
 
 
@@ -76,12 +75,10 @@ def generate(fd, consts_path, unicodes_p
               return {name}W({args});
             #else
               return {name}A({args});
             #endif
             }}
             #endif
             """.format(ty=ty, name=name, params=params, args=args))
 
-    path = header_path('windows.h', compiler)
-
     # Write out the resulting file
-    fd.write(template.substitute(header_path=path, decls=decls))
+    fd.write(template.substitute(decls=decls))
--- a/config/msvc-stl-wrapper.template.h
+++ b/config/msvc-stl-wrapper.template.h
@@ -46,30 +46,17 @@
 //
 // FIXME/bug 551254: because we're not wrapping all the STL headers we
 // use, undefining this here can cause some headers to be built with
 // iterator checking and others not.  Turning this off until we have a
 // better plan.
 //#  undef _SECURE_SCL
 #endif
 
-// C4275: When _HAS_EXCEPTIONS is set to 0, system STL header
-//        will generate the warning which we can't modify.
-// C4530: We know that code won't be able to catch exceptions,
-//        but that's OK because we're not throwing them.
-#pragma warning( push )
-#pragma warning( disable : 4275 4530 )
-
-#ifdef __clang__
 #include_next <${HEADER}>
-#else
-#include <${HEADER_PATH}>
-#endif
-
-#pragma warning( pop )
 
 #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
 // See if we're in code that can use mozalloc.
 #  if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
 #    include "mozilla/mozalloc.h"
 #  else
 #    error "STL code can only be used with infallible ::operator new()"
 #  endif
deleted file mode 100644
--- a/config/system_header_util.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from __future__ import absolute_import
-import os
-
-
-def find_in_path(file, searchpath):
-    for dir in searchpath.split(os.pathsep):
-        f = os.path.join(dir, file)
-        if os.path.exists(f):
-            return f
-    return ''
-
-
-def header_path(header, compiler):
-    if compiler == 'gcc':
-        # we use include_next on gcc
-        return header
-    elif compiler == 'msvc':
-        return find_in_path(header, os.environ.get('INCLUDE', ''))
-    else:
-        # hope someone notices this ...
-        raise NotImplementedError(compiler)
--- a/config/windows-h-wrapper.template.h
+++ b/config/windows-h-wrapper.template.h
@@ -2,57 +2,42 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_windows_h
 #define mozilla_windows_h
 
-// Include the "real" windows.h header. On clang/gcc, this can be done with the
-// `include_next` feature, however MSVC requires a direct include path.
+// Include the "real" windows.h header.
 //
 // Also turn off deprecation warnings, as we may be wrapping deprecated fns.
 
-#if defined(__GNUC__) || defined(__clang__)
-#  pragma GCC system_header
-#  include_next <windows.h>
+#pragma GCC system_header
+#include_next <windows.h>
 
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#else
-#  include <${header_path}>
-
-#  pragma warning(push)
-#  pragma warning(disable: 4996 4995)
-#endif // defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 
 // Check if the header should be disabled
 #if defined(MOZ_DISABLE_WINDOWS_WRAPPER)
 #define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled"
 
 #elif !defined(__cplusplus)
 #define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file"
 
-#elif !defined(__GNUC__) && !defined(__clang__) && !defined(_DLL)
-#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-dynamic RTL"
-
 #else
 // We're allowed to wrap in the current context. Define `MOZ_WRAPPED_WINDOWS_H`
 // to note that fact, and perform the wrapping.
 #define MOZ_WRAPPED_WINDOWS_H
 extern "C++" {
 
 ${decls}
 
 } // extern "C++"
 
 #undef GetCurrentTime // Use GetTickCount() instead.
 
 #endif // enabled
 
-#if defined(__GNUC__) || defined(__clang__)
-#  pragma GCC diagnostic pop
-#else
-#  pragma warning(pop)
-#endif // defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
 
 #endif // !defined(mozilla_windows_h)
--- a/tools/lint/license.yml
+++ b/tools/lint/license.yml
@@ -21,17 +21,16 @@ license:
         # Different license
         - build/pgo/blueprint/print.css
         # Different license
         - build/pgo/blueprint/screen.css
         - config/external/ffi/preprocess_libffi_asm.py
         - config/external/ffi/subst_header.py
         - config/external/nspr/_pl_bld.h
         - config/external/nspr/_pr_bld.h
-        - config/system_header_util.py
         - dom/docs/Fission-IPC-Diagram.svg
         # Unknown origin
         - gfx/2d/MMIHelpers.h
         # Generated code
         - gfx/2d/ShadersD2D1.h
         # might not work with license
         - gradle.properties
         # might not work with license