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/.
5 '''Given a list of object files and library names, prints a library
6 descriptor to standard output'''
8 from __future__
import with_statement
11 import expandlibs_config
as conf
12 from expandlibs
import LibDescriptor
, isObject
, ensureParentDir
13 from optparse
import OptionParser
16 desc
= LibDescriptor()
19 if os
.path
.exists(arg
):
20 desc
['OBJS'].append(os
.path
.abspath(arg
))
22 raise Exception("File not found: %s" % arg
)
23 elif os
.path
.splitext(arg
)[1] == conf
.LIB_SUFFIX
:
24 if os
.path
.exists(arg
) or os
.path
.exists(arg
+ conf
.LIBS_DESC_SUFFIX
):
25 desc
['LIBS'].append(os
.path
.abspath(arg
))
27 raise Exception("File not found: %s" % arg
)
30 if __name__
== '__main__':
31 parser
= OptionParser()
32 parser
.add_option("-o", dest
="output", metavar
="FILE",
33 help="send output to the given file")
35 (options
, args
) = parser
.parse_args()
36 if not options
.output
:
37 raise Exception("Missing option: -o")
39 ensureParentDir(options
.output
)
40 with
open(options
.output
, 'w') as outfile
:
41 print >>outfile
, generate(args
)