コード例 #1
0
def 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("--target", dest="target", metavar="FILE",
        help="designate the target for dependencies")
    parser.add_option("--extract", action="store_true", dest="extract",
        help="when a library has no descriptor file, extract it first, when possible")
    parser.add_option("--uselist", action="store_true", dest="uselist",
        help="use a list file for objects when executing a command")
    parser.add_option("--verbose", action="store_true", dest="verbose",
        help="display executed command and temporary files content")
    parser.add_option("--symbol-order", dest="symbol_order", metavar="FILE",
        help="use the given list of symbols to order symbols in the resulting binary when using with a linker")

    (options, args) = parser.parse_args()

    if not options.target:
        options.depend = False
    if options.depend:
        deps = ExpandLibsDeps(args)
        # Filter out common command wrappers
        while os.path.basename(deps[0]) in ['ccache', 'distcc']:
            deps.pop(0)
        # Remove command
        deps.pop(0)
    with ExpandArgsMore(args) as args:
        if options.extract:
            args.extract()
        if options.symbol_order:
            args.orderSymbols(options.symbol_order)
        if options.uselist:
            args.makelist()

        if True: #options.verbose:
            print_command(sys.stderr, args)
        proc = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
        (stdout, stderr) = proc.communicate()
        if proc.returncode and not options.verbose:
            print_command(sys.stderr, args)
        sys.stderr.write(stdout)
        sys.stderr.flush()
        if proc.returncode:
            exit(proc.returncode)
    if not options.depend:
        return
    ensureParentDir(options.depend)
    with open(options.depend, 'w') as depfile:
        depfile.write("%s : %s\n" % (options.target, ' '.join(dep for dep in deps if os.path.isfile(dep) and dep != options.target)))

        for dep in deps:
            if os.path.isfile(dep) and dep != options.target:
                depfile.write("%s :\n" % dep)
コード例 #2
0
            proc = subprocess.Popen(args,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)
        except Exception, e:
            print >> sys.stderr, 'error: Launching', args, ':', e
            raise e
        (stdout, stderr) = proc.communicate()
        if proc.returncode and not options.verbose:
            print_command(sys.stderr, args)
        sys.stderr.write(stdout)
        sys.stderr.flush()
        if proc.returncode:
            exit(proc.returncode)
    if not options.depend:
        return
    ensureParentDir(options.depend)
    mk = Makefile()
    deps = [
        dep for dep in deps if os.path.isfile(dep) and dep != options.target
    ]
    no_dynamic_lib = [dep for dep in deps if not isDynamicLib(dep)]
    mk.create_rule([options.target]).add_dependencies(no_dynamic_lib)
    if len(deps) != len(no_dynamic_lib):
        mk.create_rule(['%s_order_only' % options.target
                        ]).add_dependencies(dep for dep in deps
                                            if isDynamicLib(dep))

    with open(options.depend, 'w') as depfile:
        mk.dump(depfile, removal_guard=True)

コード例 #3
0
            else:
                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):
                desc['LIBS'].append(os.path.abspath(arg))
            else:
                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")

    ensureParentDir(options.output)
    with open(options.output, 'w') as outfile:
        print >>outfile, generate(args)
    if options.depend:
        ensureParentDir(options.depend)
        with open(options.depend, 'w') as depfile:
            deps = ExpandLibsDeps(args)
            depfile.write("%s : %s\n" % (options.output, ' '.join(deps)))
            for dep in deps:
                depfile.write("%s :\n" % dep)
コード例 #4
0
def 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("--target",
                      dest="target",
                      metavar="FILE",
                      help="designate the target for dependencies")
    parser.add_option(
        "--extract",
        action="store_true",
        dest="extract",
        help=
        "when a library has no descriptor file, extract it first, when possible"
    )
    parser.add_option(
        "--uselist",
        action="store_true",
        dest="uselist",
        help="use a list file for objects when executing a command")
    parser.add_option(
        "--verbose",
        action="store_true",
        dest="verbose",
        help="display executed command and temporary files content")
    parser.add_option(
        "--symbol-order",
        dest="symbol_order",
        metavar="FILE",
        help=
        "use the given list of symbols to order symbols in the resulting binary when using with a linker"
    )

    (options, args) = parser.parse_args()

    if not options.target:
        options.depend = False
    if options.depend:
        deps = ExpandLibsDeps(args)
        # Filter out common command wrappers
        while os.path.basename(deps[0]) in ['ccache', 'distcc']:
            deps.pop(0)
        # Remove command
        deps.pop(0)
    with ExpandArgsMore(args) as args:
        if options.extract:
            args.extract()
        if options.symbol_order:
            args.orderSymbols(options.symbol_order)
        if options.uselist:
            args.makelist()

        if options.verbose:
            print_command(sys.stderr, args)
        proc = subprocess.Popen(args,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)
        (stdout, stderr) = proc.communicate()
        if proc.returncode and not options.verbose:
            print_command(sys.stderr, args)
        sys.stderr.write(stdout)
        sys.stderr.flush()
        if proc.returncode:
            exit(proc.returncode)
    if not options.depend:
        return
    ensureParentDir(options.depend)
    with open(options.depend, 'w') as depfile:
        depfile.write("%s : %s\n" % (options.target, ' '.join(
            dep
            for dep in deps if os.path.isfile(dep) and dep != options.target)))

        for dep in deps:
            if os.path.isfile(dep) and dep != options.target:
                depfile.write("%s :\n" % dep)
コード例 #5
0
        if options.verbose:
            print_command(sys.stderr, args)
        try:
            proc = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
        except Exception, e:
            print >>sys.stderr, 'error: Launching', args, ':', e
            raise e
        (stdout, stderr) = proc.communicate()
        if proc.returncode and not options.verbose:
            print_command(sys.stderr, args)
        sys.stderr.write(stdout)
        sys.stderr.flush()
        if proc.returncode:
            exit(proc.returncode)
    if not options.depend:
        return
    ensureParentDir(options.depend)
    mk = Makefile()
    deps = [dep for dep in deps if os.path.isfile(dep) and dep != options.target
            and os.path.abspath(dep) != os.path.abspath(options.depend)]
    no_dynamic_lib = [dep for dep in deps if not isDynamicLib(dep)]
    mk.create_rule([options.target]).add_dependencies(no_dynamic_lib)
    if len(deps) != len(no_dynamic_lib):
        mk.create_rule(['%s_order_only' % options.target]).add_dependencies(dep for dep in deps if isDynamicLib(dep))

    with open(options.depend, 'w') as depfile:
        mk.dump(depfile, removal_guard=True)

if __name__ == '__main__':
    main()
コード例 #6
0
    desc = LibDescriptor()
    for arg in args:
        if isObject(arg):
            if os.path.exists(arg):
                desc['OBJS'].append(os.path.abspath(arg))
            else:
                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):
                desc['LIBS'].append(os.path.abspath(arg))
            else:
                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")

    ensureParentDir(options.output)
    with open(options.output, 'w') as outfile:
        print >> outfile, generate(args)
コード例 #7
0
from optparse import OptionParser


def generate(args):
    desc = LibDescriptor()
    for arg in args:
        if isObject(arg):
            if os.path.exists(arg):
                desc["OBJS"].append(os.path.abspath(arg))
            else:
                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):
                desc["LIBS"].append(os.path.abspath(arg))
            else:
                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")

    ensureParentDir(options.output)
    with open(options.output, "w") as outfile:
        print >> outfile, generate(args)
コード例 #8
0
                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")

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