Skip to content

Latest commit

 

History

History
34 lines (30 loc) · 1.3 KB

make-stl-wrappers.py

File metadata and controls

34 lines (30 loc) · 1.3 KB
 
May 21, 2012
May 21, 2012
1
2
3
# 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/.
Feb 27, 2013
Feb 27, 2013
4
from __future__ import print_function
5
import os, re, string, sys
Sep 6, 2013
Sep 6, 2013
6
from mozbuild.util import FileAvoidWrite
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 ...
Feb 27, 2013
Feb 27, 2013
23
raise NotImplementedError(compiler)
Nov 8, 2017
Nov 8, 2017
25
26
27
# 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):
28
template = open(template_file, 'r').read()
Apr 20, 2010
Apr 20, 2010
29
Nov 8, 2017
Nov 8, 2017
30
for header in header_list:
31
path = header_path(header, compiler)
Sep 6, 2013
Sep 6, 2013
32
with FileAvoidWrite(os.path.join(outdir, header)) as f:
33
f.write(string.Template(template).substitute(HEADER=header,
May 21, 2016
May 21, 2016
34
HEADER_PATH=path))