Bug 1826333 [wpt PR 39362] - Iframe credentialless: Test quota-storage-partitioning...
[gecko.git] / config / make-system-wrappers.py
bloba4b3d51af1e8c10d51338639bc2c29713bf3858a
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 import os
6 from mozbuild.util import FileAvoidWrite
8 header_template = """#pragma GCC system_header
9 #pragma GCC visibility push(default)
10 {includes}
11 #pragma GCC visibility pop
12 """
14 include_next_template = "#include_next <{header}>"
17 # The 'unused' arg is the output file from the file_generate action. We actually
18 # generate all the files in header_list
19 def gen_wrappers(unused, outdir, *header_list):
20 for header in header_list:
21 with FileAvoidWrite(os.path.join(outdir, header)) as f:
22 includes = include_next_template.format(header=header)
23 if header == "wayland-util.h":
24 # wayland-util.h in Wayland < 1.12 includes math.h inside an
25 # extern "C" block, which breaks including the header from C++.
26 # This was fixed in Wayland 1.12, but for versions earlier than
27 # that, we work around that by force-including math.h first.
28 includes = "#include <math.h>\n" + includes
29 elif header == "wayland-client.h":
30 # The system wayland-client.h uses quote includes for
31 # wayland-util.h, which means wayland-util.h is picked from the
32 # directory containing wayland-client.h first, and there's no
33 # way around that with -I, -isystem, or other flags. So, we
34 # force to include it from our wrapper, before including the
35 # system header, so that our wayland-util.h wrapper is picked
36 # first.
37 includes = '#include "wayland-util.h"\n' + includes
38 f.write(header_template.format(includes=includes))