author Mike Shal <>
Tue, 19 Mar 2013 11:47:00 -0700
changeset 136725 97e443115162450609702fc72c99b6d88d8703d6
parent 136491 d764382ed4cf45467027f632018c6b8b8ec18df5
child 140013 260999a5d63b383d04c070410417828db69196d6
permissions -rw-r--r--
Bug 844654 - Part 2: Move MODULE to; rs=gps

# 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

'''Given a list of object files and library names, prints a library
descriptor to standard output'''

from __future__ import with_statement
import sys
import os
import expandlibs_config as conf
from expandlibs import LibDescriptor, isObject, ensureParentDir, ExpandLibsDeps
from optparse import OptionParser

def generate(args):
    desc = LibDescriptor()
    for arg in args:
        if isObject(arg):
            if os.path.exists(arg):
                raise Exception("File not found: %s" % arg)
        elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX:
            if os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
                raise Exception("File not found: %s" % arg)
    return desc

if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option("--depend", dest="depend", metavar="FILE",
        help="generate dependencies for the given execution and store it in the given file")
    parser.add_option("-o", dest="output", metavar="FILE",
        help="send output to the given file")

    (options, args) = parser.parse_args()
    if not options.output:
        raise Exception("Missing option: -o")

    with open(options.output, 'w') as outfile:
        print >>outfile, generate(args)
    if options.depend:
        with open(options.depend, 'w') as depfile:
            depfile.write("%s : %s\n" % (options.output, ' '.join(ExpandLibsDeps(args))))