author Michael Layzell <>
Fri, 02 Sep 2016 18:05:09 -0400
changeset 357488 362852b89f4e5a2254f26e8d601279331ff6bc2a
parent 218085 b9051530561e0ce8fc56b07681301b01b452c196
child 361011 8090e9a4b93d7bb03e48e78f52645d2dfd9fb378
permissions -rw-r--r--
Bug 1300208 - Allow specifying multiple rust crates to mozbuild within the same FINAL_LIBRARY, r=froydnj MozReview-Commit-ID: IIjV4Kg7wOv

# 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
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:
            # We want to skip static libraries with the name foo-rs-prelink
            # as they are individually linked for every final library, and
            # thus should not be included in the descriptor file
            if '-rs-prelink' in os.path.basename(arg):
            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("-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)