-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from grab/collect-custom-lint-jars-from-exter…
…nal-libraries collect custom lint jars from external libraries
- Loading branch information
Showing
9 changed files
with
161 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
load("@grab_bazel_common//rules/android/lint:providers.bzl", "AarInfo", "AarNodeInfo") | ||
load("@grab_bazel_common//rules/android:utils.bzl", "utils") | ||
|
||
def _collect_aar_aspect(_, ctx): | ||
transitive_aar_node_infos = depset( | ||
transitive = [ | ||
aar_node_info.transitive | ||
for aar_node_info in utils.collect_providers( | ||
AarNodeInfo, | ||
getattr(ctx.rule.attr, "deps", []), | ||
getattr(ctx.rule.attr, "exports", []), | ||
getattr(ctx.rule.attr, "associates", []), | ||
) | ||
], | ||
) | ||
current_info = AarNodeInfo( | ||
aar = None, | ||
aar_dir = None, | ||
) | ||
|
||
if hasattr(ctx.rule.attr, "aar"): # Check for rule name and only extract if it is aar_import | ||
aar = ctx.rule.attr.aar.files.to_list()[0] | ||
aar_extract = ctx.actions.declare_directory(ctx.label.name + "/lint/_extracted_aar") | ||
|
||
ctx.actions.run_shell( | ||
inputs = [aar], | ||
outputs = [aar_extract], | ||
mnemonic = "ExtractLintAar", | ||
progress_message = "Extracting %s's " % (ctx.label.name), | ||
command = ("unzip -q -o %s -d %s/ " % (aar.path, aar_extract.path)), | ||
) | ||
current_info = AarNodeInfo( | ||
aar = aar, | ||
aar_dir = aar_extract, | ||
) | ||
|
||
return [ | ||
AarInfo( | ||
self = current_info, | ||
transitive = depset( | ||
[current_info], | ||
transitive = [depset(transitive = [transitive_aar_node_infos])], | ||
), | ||
), | ||
] | ||
|
||
collect_aar_aspect = aspect( | ||
implementation = _collect_aar_aspect, | ||
attr_aspects = ["aar", "deps", "exports", "associates"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters