• David 'Digit' Turner's avatar
    android: Create app bundle wrapper script for bundle targets. · 2cfbe6ab
    David 'Digit' Turner authored
    This ensure that the GN android_app_bundle() template will also
    generate a wrapper script to manage bundles easily from the local
    machine during development and testing.
    
    For example, $OUT/bin/chrome_public_bundle is generated for the
    'chrome_public_bundle' target.
    
    The script is very similar to the wrapper script for APKs, it
    also uses apk_operations.py, which has been lightly modified
    to support bundles.
    
    A few important notes about this CL:
    
    - The 'generate_apks' variable of android_app_bundle() is now
      a no-op, i.e. .apks archives are no longer generated by the
      build itself. Instead, the wrapper script will generate the
      .apks archive on demand.
    
      This simplifies the build, and allows to locally test any
      bundle if needed easily.
    
      The variable still exists to avoid breaking the clank/ build.
    
    - The generation of .apks archives from bundles is implemented
      by using 'bundletool build-apks', which is called from the
      new helper script app_bundle_utils.py
    
      This is performed lazily through a small closure function
      generated by the bundle wrapper script, which is passed
      to the new apk_operations.RunForBundle() function.
    
      This scheme is used to considerably reduce the amount of
      modifications required in apk_operations.py, since this
      avoids the need to pass 6 more command-line flags down to
      the internal _Command class.
    
    - The new 'build-bundle-apks' command can be used to build
      said .apks archive on demand, and optionally copy it to a
      different location.
    
      Generation is also triggered in case of 'install'.
    
      MD5 checks are used to ensure the .apks archive is only
      rebuild if strictly necessary, since this is a slow
      process (e.g. around 40s for chrome_public_bundle on my
      machine).
    
    - Installation currently uses 'bundletool install-apks'
      directly and avoids using devil, since the latter doesn't
      have a good way to support bundle installation.
    
      Proper support for app bundles in devil will be added
      in a future CL, after which apk_operations.py may be
      updated to use it.
    
    What was tested and works:
    
      'devices', 'install', 'uninstall', 'launch' (without a URL),
      'stop', 'clear-data', 'logcat', 'ps', 'disk-usage', 'run'
    
    Tested but does not work:
    
      'launch <URL>' (but see TODO inside apk_operations.py)
    
    Not tested yet:
    
      'argv', 'gdb', 'mem-usage', 'shell', 'compile-dex',
      'profile'
    
    BUG=862525
    R=agrieve@chromium.org, benmason@chromium.org, jbudorick@chromium.org
    
    Change-Id: Ic1074a723b0a705f1f53ff484a19a1ca1041e7d7
    Reviewed-on: https://chromium-review.googlesource.com/1146811
    Commit-Queue: David Turner <digit@chromium.org>
    Reviewed-by: default avataragrieve <agrieve@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#577842}
    2cfbe6ab
apk_operations.py 52.3 KB