示例#1
0
def scanner_main(args):
    parser = _get_option_parser()
    (options, args) = parser.parse_args(args)

    if options.passthrough_gir:
        passthrough_gir(options.passthrough_gir, sys.stdout)
    if options.test_codegen:
        return test_codegen(options.test_codegen,
                            options.function_decoration,
                            options.include_first_header,
                            options.include_last_header,
                            options.include_first_src,
                            options.include_last_src)

    if hasattr(options, 'filelist') and not options.filelist:
        if len(args) <= 1:
            _error('Need at least one filename')

    if not options.namespace_name:
        _error('Namespace name missing')

    if options.format == 'gir':
        from giscanner.girwriter import GIRWriter as Writer
    else:
        _error("Unknown format: %s" % (options.format, ))

    if not (options.libraries
            or options.program
            or options.header_only):
        _error("Must specify --program or --library")

    namespace = create_namespace(options)
    logger = message.MessageLogger.get(namespace=namespace)
    if options.warn_all:
        logger.enable_warnings((message.WARNING, message.ERROR, message.FATAL))

    transformer = create_transformer(namespace, options)

    packages = set(options.packages)
    packages.update(transformer.get_pkgconfig_packages())
    if packages:
        exit_code = process_packages(options, packages)
        if exit_code:
            return exit_code

    ss = create_source_scanner(options, args)

    cbp = GtkDocCommentBlockParser()
    blocks = cbp.parse_comment_blocks(ss.get_comments())

    # Transform the C symbols into AST nodes
    transformer.parse(ss.get_symbols())

    if not options.header_only:
        shlibs = create_binary(transformer, options, args)
    else:
        shlibs = []

    transformer.namespace.shared_libraries = shlibs

    main = MainTransformer(transformer, blocks)
    main.transform()

    utils.break_on_debug_flag('tree')

    final = IntrospectablePass(transformer, blocks)
    final.validate()

    warning_count = logger.get_warning_count()
    if options.warn_fatal and warning_count > 0:
        message.fatal("warnings configured as fatal")
        return 1
    elif warning_count > 0 and options.warn_all is False:
        print ("g-ir-scanner: %s: warning: %d warnings suppressed (use --warn-all to see them)"
               % (transformer.namespace.name, warning_count, ))

    # Write out AST
    if options.packages_export:
        exported_packages = options.packages_export
    else:
        exported_packages = options.packages

    transformer.namespace.c_includes = options.c_includes
    transformer.namespace.exported_packages = exported_packages
    writer = Writer(transformer.namespace)
    data = writer.get_xml()

    write_output(data, options)

    return 0
示例#2
0
def scanner_main(args):
    parser = _get_option_parser()
    (options, args) = parser.parse_args(args)

    if options.passthrough_gir:
        passthrough_gir(options.passthrough_gir, sys.stdout)
    if options.test_codegen:
        return test_codegen(options.test_codegen)

    if len(args) <= 1:
        _error('Need at least one filename')

    if not options.namespace_name:
        _error('Namespace name missing')

    if options.format == 'gir':
        from giscanner.girwriter import GIRWriter as Writer
    else:
        _error("Unknown format: %s" % (options.format, ))

    if not (options.libraries
            or options.program
            or options.header_only):
        _error("Must specify --program or --library")

    namespace = create_namespace(options)
    logger = message.MessageLogger.get(namespace=namespace)
    if options.warn_all:
        logger.enable_warnings(True)
    transformer = create_transformer(namespace, options)

    packages = set(options.packages)
    packages.update(transformer.get_pkgconfig_packages())
    if packages:
        exit_code = process_packages(options, packages)
        if exit_code:
            return exit_code

    ss = create_source_scanner(options, args)

    ap = AnnotationParser()
    blocks = ap.parse(ss.get_comments())

    # Transform the C symbols into AST nodes
    transformer.set_annotations(blocks)
    transformer.parse(ss.get_symbols())

    if not options.header_only:
        shlibs = create_binary(transformer, options, args)
    else:
        shlibs = []

    main = MainTransformer(transformer, blocks)
    main.transform()

    utils.break_on_debug_flag('tree')

    final = IntrospectablePass(transformer, blocks)
    final.validate()

    warning_count = logger.get_warning_count()
    if options.warn_fatal and warning_count > 0:
        message.fatal("warnings configured as fatal")
        return 1
    elif warning_count > 0 and options.warn_all is False:
        print ("g-ir-scanner: %s: warning: %d warnings suppressed (use --warn-all to see them)"
               % (transformer.namespace.name, warning_count, ))

    # Write out AST
    if options.packages_export:
        exported_packages = options.packages_export
    else:
        exported_packages = options.packages

    writer = Writer(transformer.namespace, shlibs, transformer.get_includes(),
                    exported_packages, options.c_includes)
    data = writer.get_xml()

    write_output(data, options)

    return 0
示例#3
0
def scanner_main(args):
    parser = _get_option_parser()
    (options, args) = parser.parse_args(args)

    if options.verbose:
        import distutils
        distutils.log.set_threshold(distutils.log.DEBUG)
    if options.passthrough_gir:
        passthrough_gir(options.passthrough_gir, sys.stdout)
    if options.test_codegen:
        return test_codegen(options.test_codegen,
                            options.function_decoration,
                            options.include_first_header,
                            options.include_last_header,
                            options.include_first_src,
                            options.include_last_src)

    if hasattr(options, 'filelist') and not options.filelist:
        if len(args) <= 1:
            _error('Need at least one filename')

    if not options.namespace_name:
        _error('Namespace name missing')

    if options.format == 'gir':
        from giscanner.girwriter import GIRWriter as Writer
    else:
        _error("Unknown format: %s" % (options.format, ))

    if not (options.libraries
            or options.program
            or options.header_only):
        _error("Must specify --program or --library")

    namespace = create_namespace(options)
    logger = message.MessageLogger.get(namespace=namespace)
    if options.warn_all:
        logger.enable_warnings(True)

    transformer = create_transformer(namespace, options)

    packages = set(options.packages)
    packages.update(transformer.get_pkgconfig_packages())
    if packages:
        try:
            process_packages(options, packages)
        except pkgconfig.PkgConfigError as e:
            _error(str(e))

    ss, filenames = create_source_scanner(options, args)

    cbp = GtkDocCommentBlockParser()
    blocks = cbp.parse_comment_blocks(ss.get_comments())

    # Transform the C symbols into AST nodes
    transformer.parse(ss.get_symbols())

    if not options.header_only:
        shlibs = create_binary(transformer, options, args)
    else:
        shlibs = []

    transformer.namespace.shared_libraries = shlibs

    main = MainTransformer(transformer, blocks)
    main.transform()

    utils.break_on_debug_flag('tree')

    final = IntrospectablePass(transformer, blocks)
    final.validate()

    warning_count = logger.get_warning_count()
    if options.warn_fatal and warning_count > 0:
        message.fatal("warnings configured as fatal")
        return 1
    elif warning_count > 0 and options.warn_all is False and options.quiet is False:
        print("g-ir-scanner: %s: warning: %d warnings suppressed "
              "(use --warn-all to see them)" %
              (transformer.namespace.name, warning_count, ))

    # Write out AST
    if options.packages_export:
        exported_packages = options.packages_export
    else:
        exported_packages = options.packages

    transformer.namespace.c_includes = options.c_includes
    transformer.namespace.exported_packages = exported_packages

    sources_top_dirs = get_source_root_dirs(options, filenames)
    writer = Writer(transformer.namespace, sources_top_dirs)
    data = writer.get_encoded_xml()

    write_output(data, options)

    return 0
def scanner_main(args):
    parser = _get_option_parser()
    (options, args) = parser.parse_args(args)

    if options.passthrough_gir:
        passthrough_gir(options.passthrough_gir, sys.stdout)
    if options.test_codegen:
        return test_codegen(options.test_codegen)

    if len(args) <= 1:
        _error('Need at least one filename')

    if not options.namespace_name:
        _error('Namespace name missing')

    if options.format == 'gir':
        from giscanner.girwriter import GIRWriter as Writer
    else:
        _error("Unknown format: %s" % (options.format, ))

    if not (options.libraries or options.program):
        _error("Must specify --program or --library")

    namespace = create_namespace(options)
    logger = message.MessageLogger.get(namespace=namespace)
    if options.warn_all:
        logger.enable_warnings(True)
    transformer = create_transformer(namespace, options)

    packages = set(options.packages)
    packages.update(transformer.get_pkgconfig_packages())
    exit_code = process_packages(options, packages)
    if exit_code:
        return exit_code

    ss = create_source_scanner(options, args)

    ap = AnnotationParser()
    blocks = ap.parse(ss.get_comments())

    # Transform the C symbols into AST nodes
    transformer.set_annotations(blocks)
    transformer.parse(ss.get_symbols())

    shlibs = create_binary(transformer, options, args)

    main = MainTransformer(transformer, blocks)
    main.transform()

    utils.break_on_debug_flag('tree')

    final = IntrospectablePass(transformer, blocks)
    final.validate()

    warning_count = logger.get_warning_count()
    if options.warn_fatal and warning_count > 0:
        message.fatal("warnings configured as fatal")
        return 1
    elif warning_count > 0 and options.warn_all is False:
        print ("g-ir-scanner: %s: warning: %d warnings suppressed (use --warn-all to see them)"
               % (transformer.namespace.name, warning_count, ))

    # Write out AST
    if options.packages_export:
        exported_packages = options.packages_export
    else:
        exported_packages = options.packages

    writer = Writer(transformer.namespace, shlibs, transformer.get_includes(),
                    exported_packages, options.c_includes)
    data = writer.get_xml()

    write_output(data, options)

    return 0