3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # This script processes NSS .def files according to the rules defined in
8 # a comment at the top of each one. The files are used to define the
9 # exports from NSS shared libraries, with -DEFFILE on Windows, a linker
10 # script on Linux, or with -exported_symbols_list on OS X.
12 # The NSS build system processes them using a series of sed replacements,
13 # but the Mozilla build system is already running a Python script to generate
14 # the file so it's simpler to just do the replacement in Python.
16 # One difference between the NSS build system and Mozilla's is that
17 # Mozilla's supports building on Linux for Windows using MinGW. MinGW
18 # expects all lines containing ;+ removed and all ;- tokens removed.
23 def main(output
, input):
24 is_darwin
= buildconfig
.substs
['OS_ARCH'] == 'Darwin'
25 is_mingw
= "WINNT" == buildconfig
.substs
['OS_ARCH'] and \
26 buildconfig
.substs
.get('GCC_USE_GNU_LD')
28 with
open(input, 'r', encoding
='utf-8') as f
:
31 # On everything except MinGW, remove all lines containing ';-'
32 if not is_mingw
and ';-' in line
:
34 # On OS X, remove all lines containing ';+'
35 if is_darwin
and ';+' in line
:
37 # Remove the string ' DATA '.
38 line
= line
.replace(' DATA ', '')
39 # Remove the string ';+'
41 line
= line
.replace(';+', '')
42 # Remove the string ';;'
43 line
= line
.replace(';;', '')
44 # If a ';' is present, remove everything after it,
45 # and on OS X, remove it as well.
48 if is_darwin
or is_mingw
:
52 # On OS X, symbols get an underscore in front.
53 if line
and is_darwin
: