• David 'Digit' Turner's avatar
    android: Do not generate .apk.jar.info files in javac.py · 609082c6
    David 'Digit' Turner authored
    When compiling Java sources into .jar files, the javac.py
    script will also generate a .jar.info file, used to map
    fully-qualified Java class names to the path of the
    corresponding source or .srcjar file.
    
    These are stored along the generated .jar file, e.g.:
    
      $OUT/gen/base/base_java.javac.jar
      $OUT/gen/base/base_java.javac.jar.info
    
    In addition to this, each APK has a final .apk.jar.info
    file stored under $OUT_DIR/size-info/ that corresponds to the
    union of all the .jar.info files of its dependencies, e.g.:
    
      $OUT/size-info/ChromePublic.apk.jar.info
    
    Before this CL, the .apk.jar.info was generated by javac.py
    when compiling the APK's own source files (which include things
    like the auto-generated resource-related .srcjar files), by
    passing the --apk-jar-info option to the script.
    
    Unfortunately, this made the implementation of the android_apk(),
    java_library_impl() and compile_java() GN templates slightly more
    complex (tightly coupled) than needed, making future changes more
    difficult.
    
    This CL tries to untangle the coupling as follows:
    
    - Add a new script (merge_jar_info_files.py) to merge one or
      more .jar.info file into a final .apk.jar.info.
    
    - Remove --apk-jar-info option from javac.py. The latter is now
      only responsible for generating the .jar.info of its final
      .jar file, and doesn't need to know anything about that may
      or may not embed it later.
    
      Similarly, remove the 'apk_name' variable from compile_java()
      and java_library_impl().
    
    - Ensure that the android_apk() generates the final .apk.jar.info
      file by calling merge_jar_info_files.py.
    
    + Move common functionality to build/android/gyp/util/jar_info_utils.py
    
    To test the result, I manually checked that all .apk.jar.info files
    are identical after sorting (since they are a dump of a Python dictionary,
    with no guaranteed ordering:
    
    BUG=830641
    R=agrieve@chromium.org, yfriedman@chromium.org
    
    Change-Id: I2051bc35aba2931947d2a30db507a4d437998238
    Reviewed-on: https://chromium-review.googlesource.com/1047269
    Commit-Queue: David Turner <digit@chromium.org>
    Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
    Reviewed-by: default avataragrieve <agrieve@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#556770}
    609082c6
javac.py 21.7 KB