Bug 1473362 [wpt PR 11778] - Update wpt metadata, a=testonly
[gecko.git] / config / make-stl-wrappers.py
blob1f8661fb35bfc435105fdf2990da74047186301f
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 print_function
5 import os
6 import string
7 from mozbuild.util import FileAvoidWrite
10 def find_in_path(file, searchpath):
11 for dir in searchpath.split(os.pathsep):
12 f = os.path.join(dir, file)
13 if os.path.exists(f):
14 return f
15 return ''
18 def header_path(header, compiler):
19 if compiler == 'gcc':
20 # we use include_next on gcc
21 return header
22 elif compiler == 'msvc':
23 return find_in_path(header, os.environ.get('INCLUDE', ''))
24 else:
25 # hope someone notices this ...
26 raise NotImplementedError(compiler)
28 # The 'unused' arg is the output file from the file_generate action. We actually
29 # generate all the files in header_list
32 def gen_wrappers(unused, outdir, compiler, template_file, *header_list):
33 template = open(template_file, 'r').read()
35 for header in header_list:
36 path = header_path(header, compiler)
37 with FileAvoidWrite(os.path.join(outdir, header)) as f:
38 f.write(string.Template(template).substitute(HEADER=header,
39 HEADER_PATH=path))