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
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)
18 def header_path(header
, compiler
):
20 # we use include_next on gcc
22 elif compiler
== 'msvc':
23 return find_in_path(header
, os
.environ
.get('INCLUDE', ''))
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
,