def create_binary(transformer, options, args): # Transform the C AST nodes into higher level # GLib/GObject nodes gdump_parser = GDumpParser(transformer) # Do enough parsing that we have the get_type() functions to reference # when creating the introspection binary gdump_parser.init_parse() if options.program: args = [options.program] args.extend(options.program_args) binary = IntrospectionBinary(args) else: binary = compile_introspection_binary( options, gdump_parser.get_get_type_functions(), gdump_parser.get_error_quark_functions()) shlibs = resolve_shlibs(options, binary, options.libraries) if options.wrapper: # The wrapper needs the binary itself, not the libtool wrapper script, # so we check if libtool has sneaked the binary into .libs subdirectory # and adjust the path accordingly import os.path dir_name, binary_name = os.path.split(binary.args[0]) libtool_binary = os.path.join(dir_name, '.libs', binary_name) if os.path.exists(libtool_binary): binary.args[0] = libtool_binary # Then prepend the wrapper to the command line to execute binary.args = [options.wrapper] + binary.args gdump_parser.set_introspection_binary(binary) gdump_parser.parse() return shlibs
def create_binary(transformer, options, args): # Transform the C AST nodes into higher level # GLib/GObject nodes gdump_parser = GDumpParser(transformer) # Do enough parsing that we have the get_type() functions to reference # when creating the introspection binary gdump_parser.init_parse() if options.program: args = [options.program] args.extend(options.program_args) binary = IntrospectionBinary(args) else: binary = compile_introspection_binary(options, gdump_parser.get_get_type_functions(), gdump_parser.get_error_quark_functions()) shlibs = resolve_shlibs(options, binary, options.libraries) gdump_parser.set_introspection_binary(binary) gdump_parser.parse() return shlibs
def create_binary(transformer, options, args): # Transform the C AST nodes into higher level # GLib/GObject nodes gdump_parser = GDumpParser(transformer) # Do enough parsing that we have the get_type() functions to reference # when creating the introspection binary gdump_parser.init_parse() if options.program: args = [options.program] args.extend(options.program_args) binary = IntrospectionBinary(args) else: binary = compile_introspection_binary(options, gdump_parser.get_get_type_functions(), gdump_parser.get_error_quark_functions()) shlibs = resolve_shlibs(options, binary, options.libraries) gdump_parser.set_introspection_binary(binary) gdump_parser.parse() return shlibs
def scanner_main(args): parser = _get_option_parser() (options, args) = parser.parse_args(args) if len(args) <= 1: _error('Need at least one filename') if options.typelib_xml: return typelib_xml_strip(args[1]) if options.inject: if len(args) != 4: _error('Need three filenames; e.g. g-ir-scanner ' '--inject Source.gir Additions.xml SourceOut.gir') return inject(*args[1:4]) if options.xpath_assertions: return validate(options.xpath_assertions, args[1]) 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") libraries = options.libraries filenames = [] for arg in args: if (arg.endswith('.c') or arg.endswith('.h')): if not os.path.exists(arg): _error('%s: no such a file or directory' % (arg, )) # Make absolute, because we do comparisons inside scannerparser.c # against the absolute path that cpp will give us filenames.append(os.path.abspath(arg)) cachestore = CacheStore() transformer = Transformer(cachestore, options.namespace_name, options.namespace_version) if options.strip_prefix: transformer.set_strip_prefix(options.strip_prefix) else: transformer.set_strip_prefix(options.namespace_name) transformer.set_include_paths(options.include_paths) shown_include_warning = False for include in options.includes: if os.sep in include: raise ValueError("Invalid include path %r" % (include, )) try: include_obj = Include.from_string(include) except: sys.stderr.write("Malformed include %r\n" % (include, )) sys.exit(1) transformer.register_include(include_obj) packages = set(options.packages) packages.update(transformer.get_pkgconfig_packages()) process_packages(parser, options, packages) # Run the preprocessor, tokenize and construct simple # objects representing the raw C symbols ss = SourceScanner() ss.set_cpp_options(options.cpp_includes, options.cpp_defines, options.cpp_undefines) ss.parse_files(filenames) ss.parse_macros(filenames) # Transform the C symbols into AST nodes transformer.set_source_ast(ss) # Transform the C AST nodes into higher level # GLib/GObject nodes glibtransformer = GLibTransformer(transformer, noclosure=options.noclosure) # Do enough parsing that we have the get_type() functions to reference # when creating the introspection binary glibtransformer.init_parse() if options.program: args=[options.program] args.extend(options.program_args) binary = IntrospectionBinary(args) else: binary = compile_introspection_binary(options, glibtransformer.get_get_type_functions()) shlibs = resolve_shlibs(options, binary, libraries) glibtransformer.set_introspection_binary(binary) namespace = glibtransformer.parse() ap = AnnotationParser(namespace, ss, transformer) try: ap.parse() except InvalidAnnotationError, e: raise SystemExit("ERROR in annotation: %s" % (str(e), ))