android: build: Support compiling resources in protobuf format.

Android dynamic app bundle generation requires compiling the
resources into a new format based on serialized protocol buffers,
instead of the existing binary xml + resources.arsc file.

This is performed through an updated (and yet unreleased)
version of the 'aapt2 compile' command that takes a new
--proto-format command-line option to specify the output
format.

This CL modifies the build system to support these, in
the following way:

- compile_resources.py now supports a --proto-format
  option that can be used to specify the output format
  of the generated file.

- The new GN build var android_sdk_app_bundle_build_tools
  can be used in your args.gn file the path of an updated
  Android SDK build-tools/<version>/ directory that
  contains the updated 'aapt2' binary.

  There is also a global android_enable_app_bundles
  global boolean, which is set to true when said
  build tools path is set.

- The android_apk() GN template can also define a new
  target (${target_name}__compile_proto_resources)
  used to compile the APK's resources set into the
  new format.

  Note that the output is put under
  $CHROMIUM_OUTPUT_DIR/gen/proto_resources/$APK_NAME.proto.ap_

  While the existing one is put under
  $CHROMIUM_OUTPUT_DIR/gen/arsc/$APK_NAME.ap_

  IMPORTANT NOTE: The APK target itself does not depend
  on this .proto.ap_ file, but a future CL will introduce
  new targets for app bundles, which will depend on
  the APK target, and use it to depend on it.

- The APK's .build_config file now includes a new
  deps_info['proto_resources_path'] that points to the
  proto-compiled resources file.

  This will be used by app bundles that depend on
  the APK itself to define a bundle module.

  The value can be specified by using --apk-proto-resources
  when using write_build_config.py

BUG=820459
R=agrieve@chromium.org, yfriedman@chromium.org, trevordixon@chromium.org

Change-Id: I1765a3d7818397a0400466ab7f8e02cf882b8927
Reviewed-on: https://chromium-review.googlesource.com/1047607
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559542}
5 files changed