diff options
author | 2017-05-08 08:26:03 -0400 | |
---|---|---|
committer | 2017-05-08 09:49:57 -0400 | |
commit | 0cce00c45cfe663caa20cd565d505e1bd43024e4 (patch) | |
tree | d55c4e73d08b289d9bcd19437bc02568aa3ab472 /src/main/java/com/google/devtools/build/lib/analysis | |
parent | 5aaf52f5d0704b91245517f19f2fe4638b2a6a97 (diff) |
BEP: Provide infrastructure to report configurations
In preparation to support multi-configuration builds, provide infrastructure
allowing build events to reference BuildConfigurations. The streaming mechanism
will ensure that build configurations are introduced in the stream before being
referenced for the first time.
Change-Id: I6b96fbebc76a05eff4f75a07e8a9cfbcd57f9c22
PiperOrigin-RevId: 155368666
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis')
2 files changed, 55 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java index 8514cdd7cd..3ff7f470df 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java @@ -42,6 +42,11 @@ import com.google.devtools.build.lib.analysis.Dependency; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.actions.FileWriteAction; import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection.Transitions; +import com.google.devtools.build.lib.buildeventstream.BuildEvent; +import com.google.devtools.build.lib.buildeventstream.BuildEventConverters; +import com.google.devtools.build.lib.buildeventstream.BuildEventId; +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos; +import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.RepositoryName; @@ -119,7 +124,7 @@ import javax.annotation.Nullable; category = SkylarkModuleCategory.BUILTIN, doc = "Data required for the analysis of a target that comes from targets that " + "depend on it and not targets that it depends on.") -public final class BuildConfiguration { +public final class BuildConfiguration implements BuildEvent { /** * An interface for language-specific configurations. * @@ -2713,4 +2718,26 @@ public final class BuildConfiguration { } return currentTransition; } + + @Override + public BuildEventId getEventId() { + return BuildEventId.configurationId(checksum()); + } + + @Override + public Collection<BuildEventId> getChildrenEvents() { + return ImmutableList.of(); + } + + @Override + public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) { + return GenericBuildEvent.protoChaining(this) + .setConfiguration( + BuildEventStreamProtos.Configuration.newBuilder() + .setMnemonic(getMnemonic()) + .setPlatformName(getPlatformName()) + .setCpu(getCpu()) + .build()) + .build(); + } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildEventWithConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildEventWithConfiguration.java new file mode 100644 index 0000000000..a4742c0101 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildEventWithConfiguration.java @@ -0,0 +1,27 @@ +// Copyright 2017 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.analysis.config; + +import com.google.devtools.build.lib.buildeventstream.BuildEvent; +import java.util.Collection; + +/** Interface for {@link BuildEvent}s that reference {@link BuildConfigration}s */ +public interface BuildEventWithConfiguration extends BuildEvent { + /** + * The {@link BuildConfiguration}s the event mentions, and hence should be introduced in the + * stream before this event. + */ + Collection<BuildConfiguration> getConfigurations(); +} |