コード例 #1
0
  def _blink_compile_idl_files(self, file_paths, import_options, is_dart_idl):
    if not(is_dart_idl):
      start_time = time.time()

      # 2-stage computation: individual, then overall
      for file_path in file_paths:
        compute_info_individual(file_path, 'dart')
      info_individuals = [info_individual()]
      compute_interfaces_info_overall(info_individuals)

      end_time = time.time()
      print 'Compute dependencies %s seconds' % round((end_time - start_time), 2)
    else:
      # Compute the interface_info for dart.idl for implements defined.  This
      # file is special in that more than one interface can exist in this file.
      implement_pairs = self._compute_dart_idl_implements(file_paths[0])

      interfaces_info['__dart_idl___'] = {
        'implement_pairs': implement_pairs,
      }

    # Parse the IDL files serially.
    start_time = time.time()

    for file_path in file_paths:
      file_path = os.path.normpath(file_path)
      ast = _compile_idl_file(self.build, file_path, import_options)
      self._process_ast(os.path.splitext(os.path.basename(file_path))[0], ast)

    end_time = time.time()
    print 'Compiled %s IDL files in %s seconds' % (len(file_paths),
                                                  round((end_time - start_time), 2))
コード例 #2
0
    def _blink_compile_idl_files(self, file_paths, import_options,
                                 is_dart_idl):
        if not (is_dart_idl):
            start_time = time.time()

            # 2-stage computation: individual, then overall
            for file_path in file_paths:
                compute_info_individual(file_path, 'dart')
            info_individuals = [info_individual()]
            compute_interfaces_info_overall(info_individuals)

            end_time = time.time()
            print 'Compute dependencies %s seconds' % round(
                (end_time - start_time), 2)
        else:
            # Compute the interface_info for dart.idl for implements defined.  This
            # file is special in that more than one interface can exist in this file.
            implement_pairs = self._compute_dart_idl_implements(file_paths[0])

            interfaces_info['__dart_idl___'] = {
                'implement_pairs': implement_pairs,
            }

        # Parse the IDL files serially.
        start_time = time.time()

        for file_path in file_paths:
            file_path = os.path.normpath(file_path)
            ast = _compile_idl_file(self.build, file_path, import_options)
            self._process_ast(
                os.path.splitext(os.path.basename(file_path))[0], ast)

        end_time = time.time()
        print 'Compiled %s IDL files in %s seconds' % (
            len(file_paths), round((end_time - start_time), 2))
コード例 #3
0
    def _blink_compile_idl_files(self, file_paths, import_options, parallel,
                                 is_dart_idl):
        if not (is_dart_idl):
            start_time = time.time()

            # 2-stage computation: individual, then overall
            for file_path in file_paths:
                compute_info_individual(file_path, 'dart')
            info_individuals = [info_individual()]
            compute_interfaces_info_overall(info_individuals)

            end_time = time.time()
            print 'Compute dependencies %s seconds' % round(
                (end_time - start_time), 2)
        else:
            # Compute the interface_info for dart.idl for implements defined.  This
            # file is special in that more than one interface can exist in this file.
            implement_pairs = self._compute_dart_idl_implements(file_paths[0])

            interfaces_info['__dart_idl___'] = {
                'implement_pairs': implement_pairs,
            }

        # use --parallel for async on a pool.  Look at doing it like Blink
        blink_compiler = _new_compile_idl_file
        process_ast = self._process_ast

        if parallel:
            # Parse the IDL files in parallel.
            pool = multiprocessing.Pool()
            try:
                for file_path in file_paths:
                    pool.apply_async(
                        blink_compiler,
                        [self.build, file_path, import_options],
                        callback=lambda new_ast: process_ast(new_ast, True))
                pool.close()
                pool.join()
            except:
                pool.terminate()
                raise
        else:
            # Parse the IDL files serially.
            start_time = time.time()

            for file_path in file_paths:
                file_path = os.path.normpath(file_path)
                ast = blink_compiler(self.build, file_path, import_options)
                process_ast(
                    os.path.splitext(os.path.basename(file_path))[0], ast,
                    True)

            end_time = time.time()
            print 'Compiled %s IDL files in %s seconds' % (
                len(file_paths), round((end_time - start_time), 2))
コード例 #4
0
  def _blink_compile_idl_files(self, file_paths, import_options, parallel, is_dart_idl):
    if not(is_dart_idl):
      start_time = time.time()

      # 2-stage computation: individual, then overall
      for file_path in file_paths:
        compute_info_individual(file_path, 'dart')
      info_individuals = [info_individual()]
      compute_interfaces_info_overall(info_individuals)

      end_time = time.time()
      print 'Compute dependencies %s seconds' % round((end_time - start_time), 2)
    else:
      # Compute the interface_info for dart.idl for implements defined.  This
      # file is special in that more than one interface can exist in this file.
      implement_pairs = self._compute_dart_idl_implements(file_paths[0])

      interfaces_info['__dart_idl___'] = {
        'implement_pairs': implement_pairs,
      }

    # use --parallel for async on a pool.  Look at doing it like Blink
    blink_compiler = _new_compile_idl_file
    process_ast = self._process_ast

    if parallel:
      # Parse the IDL files in parallel.
      pool = multiprocessing.Pool()
      try:
        for file_path in file_paths:
          pool.apply_async(blink_compiler,
                           [ self.build, file_path, import_options],
                           callback = lambda new_ast: process_ast(new_ast, True))
        pool.close()
        pool.join()
      except:
        pool.terminate()
        raise
    else:
      # Parse the IDL files serially.
      start_time = time.time()

      for file_path in file_paths:
        file_path = os.path.normpath(file_path)
        ast = blink_compiler(self.build, file_path, import_options)
        process_ast(os.path.splitext(os.path.basename(file_path))[0], ast, True)

      end_time = time.time()
      print 'Compiled %s IDL files in %s seconds' % (len(file_paths),
                                                    round((end_time - start_time), 2))
コード例 #5
0
def main(argv):
    '''
    Runs Dart IDL code generator; IDL files.  IDL files same as GYP files in
    Source/bindings/core/core.gypi and Source/bindings/modules/modules.gypi (see
    idl_files.py on list of files).

    To run the PYTHONPATH should have the directories:

        Source/bindings/scripts
        Source/bindings/scripts/dart
    '''

    options = parse_options()

    if options.compute_idls:
        # TODO(terry): Assumes CWD is third_party/WebKit so any call to
        # full_path_NNNN is prefixing 'Source/core' to path.
        core_idls = full_path_core_idl_files()
        core_dependency_idls = full_path_core_dependency_idl_files()
        modules_idls = full_path_modules_idl_files()
        modules_dependency_idls = full_path_modules_dependency_idl_files()

        all_interfaces = core_idls + modules_idls
        all_dependencies = core_dependency_idls + modules_dependency_idls
        all_files = all_interfaces + all_dependencies

        # 2-stage computation: individual, then overall
        for idl_filename in all_files:
            compute_info_individual(idl_filename, 'dart')
        info_individuals = [info_individual()]
        compute_interfaces_info_overall(info_individuals)

        # Compile just IDLs with interfaces (no dependencies).
        if (options.output_directory == None):
            with ScopedTempFileProvider(keep=options.keep) as provider:
                build = Build(provider)
        else:
            provider = DirectoryProvider(path=options.output_directory)
            build = Build(provider)

        if options.verbose and options.keep:
            print 'Output directory %s created' % build.output_directory

        # Compile IDLs
        for filename in all_interfaces:
            if not filename.endswith('.idl'):
                continue
            if build.generate_from_idl(filename):
                return False

        if options.verbose:
            print '%s IDLs with interfaces processed' % len(all_interfaces)

        if options.verbose and not options.keep:
            print 'Output directory %s deleted' % build.output_directory

    if options.globals_only:
        if (options.output_directory == None):
            with ScopedTempFileProvider(keep=options.keep) as provider:
                build = Build(provider)
        else:
            provider = DirectoryProvider(path=options.output_directory)
            build = Build(provider)

        if options.verbose:
            print 'Generating global...'

        build.generate_global()

        if options.verbose:
            print 'Created DartWebkitClassIds .h/.cpp'