aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar cpeyser <cpeyser@google.com>2018-02-14 12:45:39 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-14 12:46:51 -0800
commit19f05009065d4d94fc49b306557d7fb2c7b03587 (patch)
treea73cc6e9273a0fe7bed4147d18ba708c7e334149 /src/main/java/com
parent7f081f42f0c84c23ef052117a367961165b5bd29 (diff)
@AutoCodec for LicenseProvider.
PiperOrigin-RevId: 185728682
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/BUILD1
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/LicensesProvider.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/LicensesProviderImpl.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/License.java31
4 files changed, 37 insertions, 23 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD
index 51d8726c24..fb7070a064 100644
--- a/src/main/java/com/google/devtools/build/lib/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -515,6 +515,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/collect",
"//src/main/java/com/google/devtools/build/lib/collect/compacthashset",
"//src/main/java/com/google/devtools/build/lib/collect/nestedset",
+ "//src/main/java/com/google/devtools/build/lib/collect/nestedset:serialization",
"//src/main/java/com/google/devtools/build/lib/concurrent",
"//src/main/java/com/google/devtools/build/lib/graph",
"//src/main/java/com/google/devtools/build/lib/profiler",
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/LicensesProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/LicensesProvider.java
index d52a0501e3..e6cb1bf3ec 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/LicensesProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/LicensesProvider.java
@@ -19,12 +19,15 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.License;
+import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.Strategy;
import java.util.Objects;
-/**
- * A {@link ConfiguredTarget} that has licensed targets in its transitive closure.
- */
+/** A {@link ConfiguredTarget} that has licensed targets in its transitive closure. */
+@AutoCodec(strategy = Strategy.POLYMORPHIC)
public interface LicensesProvider extends TransitiveInfoProvider {
+ ObjectCodec<LicensesProvider> CODEC = new LicensesProvider_AutoCodec();
/**
* The set of label - license associations in the transitive closure.
@@ -44,10 +47,11 @@ public interface LicensesProvider extends TransitiveInfoProvider {
*/
boolean hasOutputLicenses();
- /**
- * License association for a particular target.
- */
- public static final class TargetLicense {
+ /** License association for a particular target. */
+ @AutoCodec
+ final class TargetLicense {
+ public static final ObjectCodec<TargetLicense> CODEC =
+ new LicensesProvider_TargetLicense_AutoCodec();
private final Label label;
private final License license;
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/LicensesProviderImpl.java b/src/main/java/com/google/devtools/build/lib/analysis/LicensesProviderImpl.java
index fd4f4675df..7229aec1c8 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/LicensesProviderImpl.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/LicensesProviderImpl.java
@@ -24,12 +24,16 @@ import com.google.devtools.build.lib.packages.Attribute;
import com.google.devtools.build.lib.packages.AttributeMap;
import com.google.devtools.build.lib.packages.License;
import com.google.devtools.build.lib.packages.Rule;
+import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
-/**
- * A {@link ConfiguredTarget} that has licensed targets in its transitive closure.
- */
+/** A {@link ConfiguredTarget} that has licensed targets in its transitive closure. */
@Immutable
+@AutoCodec
public final class LicensesProviderImpl implements LicensesProvider {
+ public static final ObjectCodec<LicensesProviderImpl> CODEC =
+ new LicensesProviderImpl_AutoCodec();
+
public static final LicensesProvider EMPTY =
new LicensesProviderImpl(NestedSetBuilder.<TargetLicense>emptySet(Order.LINK_ORDER), null);
diff --git a/src/main/java/com/google/devtools/build/lib/packages/License.java b/src/main/java/com/google/devtools/build/lib/packages/License.java
index 6467a7e7cc..de63c5ee3c 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/License.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/License.java
@@ -27,21 +27,24 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.events.Location;
-
+import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
-/**
- * Support for license and distribution checking.
- */
-@Immutable @ThreadSafe
+/** Support for license and distribution checking. */
+@Immutable
+@ThreadSafe
+@AutoCodec
public final class License {
+ public static final ObjectCodec<License> CODEC = new License_AutoCodec();
- private final Set<LicenseType> licenseTypes;
- private final Set<Label> exceptions;
+ private final ImmutableSet<LicenseType> licenseTypes;
+ private final ImmutableSet<Label> exceptions;
/**
* The error that's thrown if a build file contains an invalid license string.
@@ -84,11 +87,11 @@ public final class License {
}
/**
- * An instance of LicenseType.None with no exceptions, used for packages
- * outside of third_party which have no license clause in their BUILD files.
+ * An instance of LicenseType.None with no exceptions, used for packages outside of third_party
+ * which have no license clause in their BUILD files.
*/
public static final License NO_LICENSE =
- new License(ImmutableSet.of(LicenseType.NONE), Collections.<Label>emptySet());
+ new License(ImmutableSet.of(LicenseType.NONE), ImmutableSet.of());
/**
* A default instance of Distributions which is used for packages which
@@ -171,15 +174,17 @@ public final class License {
return ImmutableTable.copyOf(result);
}
- private License(Set<LicenseType> licenseTypes, Set<Label> exceptions) {
+ @AutoCodec.Instantiator
+ @VisibleForSerialization
+ License(ImmutableSet<LicenseType> licenseTypes, ImmutableSet<Label> exceptions) {
// Defensive copy is done in .of()
this.licenseTypes = licenseTypes;
this.exceptions = exceptions;
}
public static License of(Collection<LicenseType> licenses, Collection<Label> exceptions) {
- Set<LicenseType> licenseSet = ImmutableSet.copyOf(licenses);
- Set<Label> exceptionSet = ImmutableSet.copyOf(exceptions);
+ ImmutableSet<LicenseType> licenseSet = ImmutableSet.copyOf(licenses);
+ ImmutableSet<Label> exceptionSet = ImmutableSet.copyOf(exceptions);
if (exceptionSet.isEmpty() && licenseSet.equals(ImmutableSet.of(LicenseType.NONE))) {
return License.NO_LICENSE;