Skip to content

Commit

Permalink
Delete non-interning, non-singleton @AutoCodec.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 412045358
  • Loading branch information
Googler authored and copybara-github committed Nov 24, 2021
1 parent b2010c3 commit a556f78
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.collect.nestedset.Depset;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -51,7 +50,6 @@
name = "select",
doc = "A selector between configuration-dependent entities.",
documented = false)
@AutoCodec
public final class SelectorList implements StarlarkValue, HasBinary {

// TODO(adonovan): combine Selector{List,Value} and BuildType.SelectorList.
Expand All @@ -60,8 +58,7 @@ public final class SelectorList implements StarlarkValue, HasBinary {
private final Class<?> type;
private final List<Object> elements;

@AutoCodec.VisibleForSerialization
SelectorList(Class<?> type, List<Object> elements) {
private SelectorList(Class<?> type, List<Object> elements) {
this.type = type;
this.elements = elements;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Map;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.eval.EvalException;
Expand All @@ -42,7 +41,6 @@
name = "selector",
doc = "A selector between configuration-dependent values.",
documented = false)
@AutoCodec
public final class SelectorValue implements StarlarkValue, HasBinary {

// TODO(adonovan): combine Selector{List,Value} and BuildType.SelectorList.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Objects;

/** {@link AspectClass} for aspects defined in Starlark. */
@AutoCodec
@Immutable
public final class StarlarkAspectClass implements AspectClass {
private final Label extensionLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import net.starlark.java.eval.EvalException;
import net.starlark.java.eval.Mutability;
import net.starlark.java.eval.Starlark;
Expand All @@ -34,8 +33,7 @@
* <p>TODO(adonovan): eliminate the need for this class by making the Starlark calls in the same
* Starlark thread that instantiated the rule.
*/
@AutoCodec
public class StarlarkCallbackHelper {
public final class StarlarkCallbackHelper {

private final StarlarkFunction callback;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
import com.google.devtools.build.lib.analysis.config.transitions.ConfigurationTransition;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import java.util.Objects;
import net.starlark.java.eval.EvalException;
import net.starlark.java.eval.Printer;
import net.starlark.java.eval.Starlark;
import net.starlark.java.eval.StarlarkCallable;

/** A Starlark value that is a result of an 'aspect(..)' function call. */
@AutoCodec
public class StarlarkDefinedAspect implements StarlarkExportable, StarlarkAspect {
public final class StarlarkDefinedAspect implements StarlarkExportable, StarlarkAspect {
private final StarlarkCallable implementation;
private final ImmutableList<String> attributeAspects;
private final ImmutableList<Attribute> attributes;
Expand Down Expand Up @@ -81,43 +78,6 @@ public StarlarkDefinedAspect(
this.applyToGeneratingRules = applyToGeneratingRules;
}

/** Constructor for post export reconstruction for serialization. */
@VisibleForSerialization
@AutoCodec.Instantiator
StarlarkDefinedAspect(
StarlarkCallable implementation,
ImmutableList<String> attributeAspects,
ImmutableList<Attribute> attributes,
ImmutableList<ImmutableSet<StarlarkProviderIdentifier>> requiredProviders,
ImmutableList<ImmutableSet<StarlarkProviderIdentifier>> requiredAspectProviders,
ImmutableSet<StarlarkProviderIdentifier> provides,
ImmutableSet<String> paramAttributes,
ImmutableSet<StarlarkAspect> requiredAspects,
ImmutableSet<String> fragments,
// The host transition is in lib.analysis, so we can't reference it directly here.
ConfigurationTransition hostTransition,
ImmutableSet<String> hostFragments,
ImmutableList<Label> requiredToolchains,
boolean useToolchainTransition,
boolean applyToGeneratingRules,
StarlarkAspectClass aspectClass) {
this(
implementation,
attributeAspects,
attributes,
requiredProviders,
requiredAspectProviders,
provides,
paramAttributes,
requiredAspects,
fragments,
hostTransition,
hostFragments,
requiredToolchains,
useToolchainTransition,
applyToGeneratingRules);
this.aspectClass = aspectClass;
}

public StarlarkCallable getImplementation() {
return implementation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
import net.starlark.java.eval.EvalException;
import net.starlark.java.eval.Printer;
import net.starlark.java.eval.Starlark;

/** A natively-defined aspect that is may be referenced by Starlark attribute definitions. */
public abstract class StarlarkNativeAspect extends NativeAspectClass implements StarlarkAspect {
@AutoCodec @AutoCodec.VisibleForSerialization
@SerializationConstant @AutoCodec.VisibleForSerialization
static final Function<Rule, AspectParameters> EMPTY_FUNCTION = input -> AspectParameters.EMPTY;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.util.Fingerprint;
import java.util.Collection;
import java.util.Objects;
Expand Down Expand Up @@ -221,8 +220,7 @@ public String toString() {
* A serializable representation of Starlark-defined {@link StarlarkProvider} that uniquely
* identifies all {@link StarlarkProvider}s that are exposed to SkyFrame.
*/
@AutoCodec
public static class Key extends Provider.Key {
public static final class Key extends Provider.Key {
private final Label extensionLabel;
private final String exportedName;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/lib/pkgcache/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ java_library(
"//third_party:auto_value",
"//third_party:guava",
"//third_party:jsr305",
"//third_party/protobuf:protobuf_java",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Objects;

/**
Expand Down Expand Up @@ -108,7 +107,6 @@ public boolean shouldRetain(Target target, boolean explicit) {

/** FilteringPolicy that only matches a specific rule name. */
@AutoValue
@AutoCodec
abstract static class RuleTypeFilter implements FilteringPolicy {
abstract String ruleName();

Expand All @@ -127,8 +125,7 @@ public boolean shouldRetain(Target target, boolean explicit) {
return false;
}

@AutoCodec.Instantiator
static RuleTypeFilter create(String ruleName, boolean keepExplicit) {
private static RuleTypeFilter create(String ruleName, boolean keepExplicit) {
return new AutoValue_FilteringPolicies_RuleTypeFilter(ruleName, keepExplicit);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/lib/rules/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/concurrent",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/skyframe:build_configuration",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
"//src/main/java/com/google/devtools/build/lib/util:filetype",
"//src/main/java/net/starlark/java/eval",
"//third_party:guava",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.rules.android.AndroidDataConverter.JoinerType;
import com.google.devtools.build.lib.rules.android.databinding.DataBindingContext;
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.lib.skyframe.serialization.autocodec.SerializationConstant;
import java.util.Collections;
import java.util.List;

/** Builder for creating resource processing action. */
public class AndroidResourcesProcessorBuilder {

@AutoCodec @VisibleForSerialization
@SerializationConstant @VisibleForSerialization
static final AndroidDataConverter<ValidatedAndroidResources> AAPT2_RESOURCE_DEP_TO_ARG_NO_PARSE =
AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
.withRoots(ValidatedAndroidResources::getResourceRoots)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.rules.android.AndroidDataConverter.JoinerType;
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.lib.skyframe.serialization.autocodec.SerializationConstant;

/** Builds up the spawn action for $android_rclass_generator. */
public class RClassGeneratorActionBuilder {

@AutoCodec @VisibleForSerialization
@SerializationConstant @VisibleForSerialization
static final AndroidDataConverter<ValidatedAndroidResources> AAPT2_CONVERTER =
AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
.with(RClassGeneratorActionBuilder::depsToBusyboxArg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import com.google.devtools.build.lib.packages.NonconfiguredAttributeMapper;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleTransitionData;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import java.util.Map;

/**
Expand Down Expand Up @@ -64,17 +62,14 @@ public void addToStarlarkRule(RuleDefinitionEnvironment ctx, RuleClass.Builder b
}

/** Transition which resets the set of flag-value pairs to the map it was constructed with. */
@AutoCodec
@VisibleForSerialization
static final class ConfigFeatureFlagValuesTransition implements PatchTransition {
private static final class ConfigFeatureFlagValuesTransition implements PatchTransition {
private final ImmutableSortedMap<Label, String> flagValues;
private final int cachedHashCode;

public ConfigFeatureFlagValuesTransition(Map<Label, String> flagValues) {
this(ImmutableSortedMap.copyOf(flagValues), flagValues.hashCode());
}

@AutoCodec.Instantiator
ConfigFeatureFlagValuesTransition(
ImmutableSortedMap<Label, String> flagValues, int cachedHashCode) {
this.flagValues = ImmutableSortedMap.copyOf(flagValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
import com.google.devtools.build.lib.rules.cpp.CppConfiguration.HeadersCheckingMode;
import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType;
import com.google.devtools.build.lib.shell.ShellUtils;
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.lib.util.FileType;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.PathFragment;
Expand Down Expand Up @@ -466,13 +464,11 @@ public ImmutableMap<String, String> getAllMakeVariables() throws ExpansionExcept
}

/** A filter that removes copts from a c++ compile action according to a nocopts regex. */
@AutoCodec
public static class CoptsFilter implements StarlarkValue {
public static final class CoptsFilter implements StarlarkValue {
private final Pattern noCoptsPattern;
private final boolean allPasses;

@VisibleForSerialization
CoptsFilter(Pattern noCoptsPattern, boolean allPasses) {
private CoptsFilter(Pattern noCoptsPattern, boolean allPasses) {
this.noCoptsPattern = noCoptsPattern;
this.allPasses = allPasses;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.starlarkbuildapi.cpp.CcNativeLibraryInfoApi;
import java.util.List;

Expand All @@ -28,7 +27,6 @@
* executing C++ code.
*/
@Immutable
@AutoCodec
public final class CcNativeLibraryInfo implements CcNativeLibraryInfoApi {

public static final CcNativeLibraryInfo EMPTY =
Expand Down

0 comments on commit a556f78

Please sign in to comment.