• Peter Wen's avatar
    Android: Improve type filtering, add __assetres (reland) · 81f95977
    Peter Wen authored
    Add _java_resource_types, _java_library_types, and _java_leaf_types.
    These types, together with "group", define all existing invoker.type
    values for all java targets. Since leaf types like android_apk are not
    used as dependencies for other java targets, all java targets in deps
    trees can be defined as either resources, libraries, or groups.
    
    Naming conventions have also been improved. Now java targets must match
    _java_resource_patterns if the target is a resource target. Otherwise,
    it must match _java_library_patterns if the target is a library target.
    Group targets can match either of those, but should prefer matching
    _java_library_patterns since they are treated as library targets in the
    java_group template.
    
    Thus, target filtering is now simplified. To filter for resource targets
    , simply use _java_resource_patterns. To filter for library targets, use
    _java_library_patterns and ignore the ones that also match
    _java_resource_patterns. To filter for any java target, use
    _java_target_patterns, which is a simple concatenation of the other two
    lists of patterns.
    
    The assert in write_build_config has been updated to enforce naming
    schemes accordingly. This enables assumptions about library and resource
    targets such as __header, __impl, and the newly added __assetres, which
    is defined on library targets to be its transitive list of all resource
    target deps.
    
    Now compile_resources targets can filter their deps so that they only
    depend on transitive resource deps. This allows compile_resources to
    not depend on java library targets, and unblocks header generation for
    apk targets. Previously an apk's __header target would depend on
    compile_resources to finish, while the compile_resources target would
    depend on the rest of the java library dependencies (not headers),
    completely removing any benefit of header compilation for apk targets.
    
    Original CL: https://crrev.com/c/2220585
    
    Fixed:
    - Turns out compile_resources depends on the android sdk, and that was
      either supplied directly (in the case of android_apk_or_module) or it
      was supplied by its java dependencies (in the case of junit_binary).
    - This dependency was broken by replacing java library deps with their
      corresponding __assetres deps.
    - Fixed by explicitly specifying android_sdk_dep just like
      build_config_dep.
    - Added comments for both of these explicit *_dep variables.
    
    Bug: 1090812
    Change-Id: I57c63ff805c4e27ff6b47bc69c0a6954b0b681c1
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231178
    Commit-Queue: Peter Wen <wnwen@chromium.org>
    Commit-Queue: Andrew Grieve <agrieve@chromium.org>
    Auto-Submit: Peter Wen <wnwen@chromium.org>
    Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#775105}
    81f95977
internal_rules.gni 151 KB