parameters: (java_file_paths,
                srcjar_path,
                proxy_opts,
                header_path=None,
                namespace='')
docstring: Generates files required to perform JNI registration.
  
    Generates a srcjar containing a single class, GEN_JNI, that contains all
    native method declarations.
  
    Optionally generates a header file that provides functions
    (RegisterMainDexNatives and RegisterNonMainDexNatives) to perform
    JNI registration.
  
    Args:
      java_file_paths: A list of java file paths.
      srcjar_path: Path to the GEN_JNI srcjar.
      header_path: If specified, generates a header file in this location.
      namespace: If specified, sets the namespace for the generated header file.
docstring_summary: Generates files required to perform JNI registration.
docstring_tokens: Generates files required to perform JNI registration .
function: def _Generate(java_file_paths,
                srcjar_path,
                proxy_opts,
                header_path=None,
                namespace=''):
    """Generates files required to perform JNI registration.
  
    Generates a srcjar containing a single class, GEN_JNI, that contains all
    native method declarations.
  
    Optionally generates a header file that provides functions
    (RegisterMainDexNatives and RegisterNonMainDexNatives) to perform
    JNI registration.
  
    Args:
      java_file_paths: A list of java file paths.
      srcjar_path: Path to the GEN_JNI srcjar.
      header_path: If specified, generates a header file in this location.
      namespace: If specified, sets the namespace for the generated header file.
    """
    # Without multiprocessing, script takes ~13 seconds for chrome_public_apk
    # on a z620. With multiprocessing, takes ~2 seconds.
    pool = multiprocessing.Pool()
  
    results = []
    for d in pool.imap_unordered(
        functools.partial(_DictForPath, use_proxy_hash=proxy_opts.use_hash),
        java_file_paths):
      if d:
        results.append(d)
    pool.close()
  
    # Sort to make output deterministic.
    results.sort(key=lambda d: d['FULL_CLASS_NAME'])
  
    combined_dict = {}
    for key in MERGEABLE_KEYS:
      combined_dict[key] = ''.join(d.get(key, '') for d in results)
  
    if header_path:
      combined_dict['HEADER_GUARD'] = \
          os.path.splitext(header_path)[0].replace('/', '_').upper() + '_'
      combined_dict['NAMESPACE'] = namespace
      header_content = CreateFromDict(combined_dict, proxy_opts.use_hash)
      with build_utils.AtomicOutput(header_path, mode='w') as f:
        f.write(header_content)
  
    with build_utils.AtomicOutput(srcjar_path) as f:
      with zipfile.ZipFile(f, 'w') as srcjar:
        build_utils.AddToZipHermetic(
            srcjar,
            '%s.java' % jni_generator.ProxyHelpers.GetQualifiedClass(
                proxy_opts.use_hash),
            data=CreateProxyJavaFromDict(combined_dict, proxy_opts))
function_tokens: def _Generate ( java_file_paths , srcjar_path , proxy_opts , header_path = None , namespace = '' ) : # Without multiprocessing, script takes ~13 seconds for chrome_public_apk # on a z620. With multiprocessing, takes ~2 seconds. pool = multiprocessing . Pool ( ) results = [ ] for d in pool . imap_unordered ( functools . partial ( _DictForPath , use_proxy_hash = proxy_opts . use_hash ) , java_file_paths ) : if d : results . append ( d ) pool . close ( ) # Sort to make output deterministic. results . sort ( key = lambda d : d [ 'FULL_CLASS_NAME' ] ) combined_dict = { } for key in MERGEABLE_KEYS : combined_dict [ key ] = '' . join ( d . get ( key , '' ) for d in results ) if header_path : combined_dict [ 'HEADER_GUARD' ] = os . path . splitext ( header_path ) [ 0 ] . replace ( '/' , '_' ) . upper ( ) + '_' combined_dict [ 'NAMESPACE' ] = namespace header_content = CreateFromDict ( combined_dict , proxy_opts . use_hash ) with build_utils . AtomicOutput ( header_path , mode = 'w' ) as f : f . write ( header_content ) with build_utils . AtomicOutput ( srcjar_path ) as f : with zipfile . ZipFile ( f , 'w' ) as srcjar : build_utils . AddToZipHermetic ( srcjar , '%s.java' % jni_generator . ProxyHelpers . GetQualifiedClass ( proxy_opts . use_hash ) , data = CreateProxyJavaFromDict ( combined_dict , proxy_opts ) )