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 buildconfig
.substs
.get(
29 with
open(input, "r", encoding
="utf-8") as f
:
32 # On everything except MinGW, remove all lines containing ';-'
33 if not is_mingw
and ";-" in line
:
35 # On OS X, remove all lines containing ';+'
36 if is_darwin
and ";+" in line
:
38 # Remove the string ' DATA '.
39 line
= line
.replace(" DATA ", "")
40 # Remove the string ';+'
42 line
= line
.replace(";+", "")
43 # Remove the string ';;'
44 line
= line
.replace(";;", "")
45 # If a ';' is present, remove everything after it,
46 # and on OS X, remove it as well.
49 if is_darwin
or is_mingw
:
53 # On OS X, symbols get an underscore in front.
54 if line
and is_darwin
: