Skip to content

Commit

Permalink
Make ContextualBuildConfigurationKeyCodec a LeafObjectCodec.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 596956418
Change-Id: I8d35cbd5687798b3f1d21370baf959bb5c3ac786
  • Loading branch information
aoeui authored and copybara-github committed Jan 9, 2024
1 parent e7a0086 commit 9e4f112
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,7 @@ java_library(
deps = [
":config/fragment_options",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization:visible-for-serialization",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:serialization-constant",
"//src/main/java/com/google/devtools/build/lib/util",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.devtools.build.lib.skyframe.serialization.LeafObjectCodec;
import com.google.devtools.build.lib.skyframe.serialization.SerializationDependencyProvider;
import com.google.devtools.build.lib.skyframe.serialization.SerializationException;
import com.google.devtools.build.lib.skyframe.serialization.VisibleForSerialization;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.common.options.OptionDefinition;
Expand Down Expand Up @@ -464,8 +465,20 @@ public BuildOptions build() {
private Builder() {}
}

@SuppressWarnings("unused") // Used reflectively.
private static final class Codec extends LeafObjectCodec<BuildOptions> {
/**
* Codec for {@link BuildOptions}.
*
* <p>This codec works by serializing the {@link BuildOptions#checksum} only. This works due to
* the assumption that anytime a value containing a particular configuration is deserialized, it
* was previously requested using the same configuration key, thus priming the cache.
*/
@VisibleForSerialization
public static final class Codec extends LeafObjectCodec<BuildOptions> {
private static final Codec INSTANCE = new Codec();

public static Codec buildOptionsCodec() {
return INSTANCE;
}

@Override
public Class<BuildOptions> getEncodedClass() {
Expand Down

0 comments on commit 9e4f112

Please sign in to comment.