diff options
author | janakr <janakr@google.com> | 2018-03-30 12:49:12 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-30 12:50:39 -0700 |
commit | d3fe5e7f42e31a1021ace7cefb8a10285aad3494 (patch) | |
tree | a4168b035db55ea1ade11c7cdb7e22db429d36d5 /src/main/java/com/google/devtools/build/lib/query2 | |
parent | 78a5fcff8a311c71cfe163a40856f7413e346409 (diff) |
Make RuleClass serializable and remove Environment from it, since it was only being used for the transitive hash code and transitive label of its globals, which can be passed in explicitly.
Assert along the way that the transitive label of its globals is always non-null. That is currently the case, although there seems to be no hard invariant of the system that it is true. Might as well tighten it now.
PiperOrigin-RevId: 191103310
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java b/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java index edb0796fff..ef5c31a073 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java +++ b/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java @@ -52,7 +52,6 @@ import com.google.devtools.build.lib.query2.proto.proto2api.Build; import com.google.devtools.build.lib.query2.proto.proto2api.Build.GeneratedFile; import com.google.devtools.build.lib.query2.proto.proto2api.Build.QueryResult.Builder; import com.google.devtools.build.lib.query2.proto.proto2api.Build.SourceFile; -import com.google.devtools.build.lib.syntax.Environment; import com.google.devtools.build.lib.syntax.Type; import java.io.IOException; import java.io.OutputStream; @@ -211,15 +210,15 @@ public class ProtoOutputFormatter extends AbstractUnorderedFormatter { postProcess(rule, rulePb, serializedAttributes); - Environment env = rule.getRuleClassObject().getRuleDefinitionEnvironment(); - if (env != null && includeRuleDefinitionEnvironment()) { + String transitiveHashCode = rule.getRuleClassObject().getRuleDefinitionEnvironmentHashCode(); + if (transitiveHashCode != null && includeRuleDefinitionEnvironment()) { // The RuleDefinitionEnvironment is always defined for Skylark rules and // always null for non Skylark rules. rulePb.addAttribute( Build.Attribute.newBuilder() .setName(RULE_IMPLEMENTATION_HASH_ATTR_NAME) .setType(ProtoUtils.getDiscriminatorFromType(Type.STRING)) - .setStringValue(env.getTransitiveContentHashCode())); + .setStringValue(transitiveHashCode)); } ImmutableMultimap<Attribute, Label> aspectsDependencies = |