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, ExpandLibsDeps
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("--depend", dest="depend", metavar="FILE",
33
help="generate dependencies for the given execution and store it in the given file")
34
parser.add_option("-o", dest="output", metavar="FILE",
35
help="send output to the given file")
37
(options, args) = parser.parse_args()
38
if not options.output:
39
raise Exception("Missing option: -o")
41
ensureParentDir(options.output)
42
with open(options.output, 'w') as outfile:
43
print >>outfile, generate(args)
45
ensureParentDir(options.depend)
46
with open(options.depend, 'w') as depfile:
47
depfile.write("%s : %s\n" % (options.output, ' '.join(ExpandLibsDeps(args))))