diff options
author | 2018-03-02 10:20:15 -0800 | |
---|---|---|
committer | 2018-03-02 10:22:30 -0800 | |
commit | eee53d3a33dde441f7e7adaecde81ef2d3db7c1b (patch) | |
tree | 0c6ddd2c54993b9b919e2e59faa0ddd1de117bb0 /src/main/java/com/google/devtools/build/lib/skyframe | |
parent | d1201c8e61ee77feabeb83da88e0eae049087a09 (diff) |
@AutoCodec ConfiguredTargetValue.
PiperOrigin-RevId: 187635570
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java | 22 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java | 40 |
2 files changed, 58 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java index fc4ebd6727..341da8a6ec 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java @@ -16,9 +16,11 @@ package com.google.devtools.build.lib.skyframe; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; import com.google.devtools.build.lib.actions.ActionLookupValue; import com.google.devtools.build.lib.actions.Actions.GeneratingActions; +import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.cmdline.Label; @@ -26,18 +28,18 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; import com.google.devtools.build.lib.packages.Package; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; import com.google.devtools.build.skyframe.SkyKey; import java.util.List; import javax.annotation.Nullable; -/** - * A configured target in the context of a Skyframe graph. - */ +/** A configured target in the context of a Skyframe graph. */ +@AutoCodec @Immutable @ThreadSafe @VisibleForTesting public final class ConfiguredTargetValue extends ActionLookupValue { - // These variables are only non-final because they may be clear()ed to save memory. // configuredTarget is null only after it is cleared. @Nullable private ConfiguredTarget configuredTarget; @@ -45,6 +47,18 @@ public final class ConfiguredTargetValue extends ActionLookupValue { // May be null either after clearing or because transitive packages are not tracked. @Nullable private NestedSet<Package> transitivePackagesForPackageRootResolution; + @AutoCodec.Instantiator + @VisibleForSerialization + ConfiguredTargetValue( + List<ActionAnalysisMetadata> actions, + ImmutableMap<Artifact, Integer> generatingActionIndex, + ConfiguredTarget configuredTarget, + NestedSet<Package> transitivePackagesForPackageRootResolution) { + super(actions, generatingActionIndex); + this.configuredTarget = configuredTarget; + this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution; + } + ConfiguredTargetValue( ConfiguredTarget configuredTarget, GeneratingActions generatingActions, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java new file mode 100644 index 0000000000..c30b69d2ef --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java @@ -0,0 +1,40 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skyframe.serialization; + +import com.google.protobuf.CodedInputStream; +import com.google.protobuf.CodedOutputStream; +import java.io.IOException; + +/** Codec for {@link Boolean}. */ +class BooleanCodec implements ObjectCodec<Boolean> { + + @Override + public Class<Boolean> getEncodedClass() { + return Boolean.class; + } + + @Override + public void serialize(SerializationContext context, Boolean value, CodedOutputStream codedOut) + throws IOException { + codedOut.writeBoolNoTag(value); + } + + @Override + public Boolean deserialize(DeserializationContext context, CodedInputStream codedIn) + throws IOException { + return codedIn.readBool(); + } +} |