Example #1
0
def main():
    dispatch_table = {
        'callback_function': bind_gen.generate_callback_functions,
        'callback_interface': bind_gen.generate_callback_interfaces,
        'dictionary': bind_gen.generate_dictionaries,
        'enumeration': bind_gen.generate_enumerations,
        'interface': bind_gen.generate_interfaces,
        'namespace': bind_gen.generate_namespaces,
        'observable_array': bind_gen.generate_observable_arrays,
        'typedef': bind_gen.generate_typedefs,
        'union': bind_gen.generate_unions,
    }

    options = parse_options(valid_tasks=dispatch_table.keys())

    output_reldirs = parse_output_reldirs(options.output_reldir)

    component_reldirs = {}
    for component, reldir in output_reldirs.items():
        component_reldirs[web_idl.Component(component)] = reldir

    bind_gen.init(web_idl_database_path=options.web_idl_database,
                  root_src_dir=options.root_src_dir,
                  root_gen_dir=options.root_gen_dir,
                  component_reldirs=component_reldirs,
                  enable_style_format=options.format_generated_files)

    task_queue = bind_gen.TaskQueue(single_process=options.single_process)

    for task in options.tasks:
        dispatch_table[task](task_queue)

    def print_to_console(message):
        out = sys.stdout
        if not out.isatty():
            return
        out.write(message)
        out.flush()

    def report_progress(total, done):
        percentage = (int(float(done) / float(total) *
                          100) if total != 0 else 100)
        message = "Blink-V8 bindings generation: {}% done\r".format(percentage)
        print_to_console(message)

    task_queue.run(report_progress)
    print_to_console("\n")
Example #2
0
def main():
    options, tasks = parse_options()

    dispatch_table = {
        'callback_function': bind_gen.generate_callback_functions,
        'callback_interface': bind_gen.generate_callback_interfaces,
        'dictionary': bind_gen.generate_dictionaries,
        'enumeration': bind_gen.generate_enumerations,
        'interface': bind_gen.generate_interfaces,
        'namespace': bind_gen.generate_namespaces,
        'typedef': bind_gen.generate_typedefs,
        'union': bind_gen.generate_unions,
    }

    for task in tasks:
        if task not in dispatch_table:
            sys.exit("Unknown task: {}".format(task))

    component_reldirs = {
        web_idl.Component('core'): options.output_core_reldir,
        web_idl.Component('modules'): options.output_modules_reldir,
    }
    bind_gen.init(web_idl_database_path=options.web_idl_database,
                  root_src_dir=options.root_src_dir,
                  root_gen_dir=options.root_gen_dir,
                  component_reldirs=component_reldirs)

    task_queue = bind_gen.TaskQueue(single_process=options.single_process)

    for task in tasks:
        dispatch_table[task](task_queue)

    def print_to_console(message):
        out = sys.stdout
        if not out.isatty():
            return
        out.write(message)
        out.flush()

    def report_progress(total, done):
        percentage = (int(float(done) / float(total) *
                          100) if total != 0 else 100)
        message = "Blink-V8 bindings generation: {}% done\r".format(percentage)
        print_to_console(message)

    task_queue.run(report_progress)
    print_to_console("\n")
Example #3
0
def main():
    options, tasks = parse_options()

    dispatch_table = {
        'dictionary': bind_gen.generate_dictionaries,
        'enumeration': bind_gen.generate_enumerations,
        'interface': bind_gen.generate_interfaces,
    }

    for task in tasks:
        if task not in dispatch_table:
            sys.exit("Unknown task: {}".format(task))

    web_idl_database = web_idl.Database.read_from_file(
        options.web_idl_database)
    component_reldirs = {
        web_idl.Component('core'): options.output_core_reldir,
        web_idl.Component('modules'): options.output_modules_reldir,
    }
    bind_gen.init(root_src_dir=options.root_src_dir,
                  root_gen_dir=options.root_gen_dir,
                  component_reldirs=component_reldirs)

    task_queue = bind_gen.TaskQueue()

    for task in tasks:
        dispatch_table[task](task_queue=task_queue,
                             web_idl_database=web_idl_database)

    def report_progress(total, done):
        out = sys.stdout
        if not out.isatty():
            return
        if total == 0:
            return
        percentage = int(float(done) / float(total) * 100)
        message = "Blink-V8 bindings generation: {}% done\r".format(percentage)
        out.write(message)
        out.flush()

    task_queue.run(report_progress)