From b019e5ea0957ec9e0e90fa40a685078e3608a936 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 16 Oct 2015 21:00:41 +0000 Subject: Trying again with checking for the presence of the "resources" attribute. Change the resource dependency handling to separate between the transitive and direct resources from libraries. This slightly increases the complexity of resource propagation. The initial algorithm was to simply merge all transitive ResourceContainers together with any new ResourceContainer and propagate them via the AndroidResourcesProvider. The new algorithm is encapsulated inside a new ResourceDependencies class which works as follows: 1. Collect resources from the deps into transitive and direct NestedSets 2. If a rule provides a ResourceContainer, merge the transitive and direct into a new transitive set 3. Export the provider This results having a rule without resources "forward" the merged sets of transitive and direct resources to the next rule. -- MOS_MIGRATED_REVID=105631635 --- .../lib/analysis/actions/CustomCommandLine.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java index 8eed18804e..584944f0e9 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java @@ -129,6 +129,22 @@ public final class CustomCommandLine extends CommandLine { } } + private static final class JoinStringsArg extends ArgvFragment { + + private final String delimiter; + private final Iterable strings; + + private JoinStringsArg(String delimiter, Iterable strings) { + this.delimiter = delimiter; + this.strings = CollectionUtils.makeImmutable(strings); + } + + @Override + void eval(ImmutableList.Builder builder) { + builder.add(Joiner.on(delimiter).join(strings)); + } + } + /** * Arguments that intersperse strings between the items in a sequence. There are two forms of * interspersing, and either may be used by this implementation: @@ -261,6 +277,14 @@ public final class CustomCommandLine extends CommandLine { return this; } + public Builder addJoinStrings(String arg, String delimiter, Iterable strings) { + if (arg != null && strings != null) { + arguments.add(new ObjectArg(arg)); + arguments.add(new JoinStringsArg(delimiter, strings)); + } + return this; + } + public Builder addJoinExecPaths(String arg, String delimiter, Iterable artifacts) { if (arg != null && artifacts != null) { arguments.add(new ObjectArg(arg)); -- cgit v1.2.3