Bug 1639748 [wpt PR 23722] - Make form submissions cancel pending jsurl navigations...
[gecko.git] / config / make-system-wrappers.py
blob8636e244e8d1758a1ce3c8ff5694d00cd723007f
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 from __future__ import absolute_import
5 from __future__ import print_function
6 import os
7 from mozbuild.util import FileAvoidWrite
9 header_template = '''#pragma GCC system_header
10 #pragma GCC visibility push(default)
11 {includes}
12 #pragma GCC visibility pop
13 '''
15 include_next_template = '#include_next <{header}>'
18 # The 'unused' arg is the output file from the file_generate action. We actually
19 # generate all the files in header_list
20 def gen_wrappers(unused, outdir, *header_list):
21 for header in header_list:
22 with FileAvoidWrite(os.path.join(outdir, header)) as f:
23 includes = include_next_template.format(header=header)
24 if header == 'wayland-util.h':
25 # wayland-util.h in Wayland < 1.12 includes math.h inside an
26 # extern "C" block, which breaks including the header from C++.
27 # This was fixed in Wayland 1.12, but for versions earlier than
28 # that, we work around that by force-including math.h first.
29 includes = '#include <math.h>\n' + includes
30 elif header == 'wayland-client.h':
31 # The system wayland-client.h uses quote includes for
32 # wayland-util.h, which means wayland-util.h is picked from the
33 # directory containing wayland-client.h first, and there's no
34 # way around that with -I, -isystem, or other flags. So, we
35 # force to include it from our wrapper, before including the
36 # system header, so that our wayland-util.h wrapper is picked
37 # first.
38 includes = '#include "wayland-util.h"\n' + includes
39 f.write(header_template.format(includes=includes))