Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tylerwilliams/bazel into …
Browse files Browse the repository at this point in the history
…b3hasher2
  • Loading branch information
tylerwilliams committed Jul 6, 2023
2 parents f32259d + a309553 commit c92ed72
Show file tree
Hide file tree
Showing 142 changed files with 2,389 additions and 4,251 deletions.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ bazel_dep(name = "zstd-jni", version = "1.5.2-3")
bazel_dep(name = "blake3", version = "1.3.3")
bazel_dep(name = "zlib", version = "1.2.13")
bazel_dep(name = "rules_cc", version = "0.0.6")
bazel_dep(name = "rules_go", version = "0.39.1")
bazel_dep(name = "rules_java", version = "6.1.1")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "rules_jvm_external", version = "5.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
|| name.startsWith("com.google.common.collect.")
|| name.startsWith("com.google.common.base.")
|| name.startsWith("com.google.common.graph.")
|| name.startsWith("com.google.common.regex.")
|| name.startsWith("org.checkerframework.shaded.dataflow.")
|| name.startsWith("org.checkerframework.errorprone.dataflow.")
|| name.startsWith("com.sun.source.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* are subclasses of {@link ActionLookupKeyOrProxy}. This allows callers to easily find the value
* key, while remaining agnostic to what action lookup values actually exist.
*/
// TODO(b/261521010): this layer of indirection is no longer needed and may be cleaned up.
public interface ActionLookupKeyOrProxy extends ArtifactOwner {
/**
* Returns the {@link BuildConfigurationKey} for the configuration associated with this key, or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -69,8 +70,9 @@ public static SpawnMetrics forLocalExecution(int wallTimeInMs) {
private final int executionWallTimeInMs;
private final int processOutputsTimeInMs;
private final int networkTimeInMs;

// error code to duration in ms
private final Map<Integer, Integer> retryTimeInMs;
private final ImmutableMap<Integer, Integer> retryTimeInMs;
private final long inputBytes;
private final long inputFiles;
private final long memoryEstimateBytes;
Expand All @@ -91,7 +93,7 @@ private SpawnMetrics(Builder builder) {
this.setupTimeInMs = builder.setupTimeInMs;
this.uploadTimeInMs = builder.uploadTimeInMs;
this.executionWallTimeInMs = builder.executionWallTimeInMs;
this.retryTimeInMs = builder.retryTimeInMs;
this.retryTimeInMs = ImmutableMap.copyOf(builder.retryTimeInMs);
this.processOutputsTimeInMs = builder.processOutputsTimeInMs;
this.inputBytes = builder.inputBytes;
this.inputFiles = builder.inputFiles;
Expand Down Expand Up @@ -436,8 +438,8 @@ public Builder addRetryTimeInMs(int errorCode, int retryTimeInMs) {
}

@CanIgnoreReturnValue
public Builder setRetryTimeInMs(Map<Integer, Integer> retryTimeInMs) {
this.retryTimeInMs = new HashMap<>(retryTimeInMs);
public Builder setRetryTimeInMs(ImmutableMap<Integer, Integer> retryTimeInMs) {
this.retryTimeInMs = retryTimeInMs;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,6 @@ public class AnalysisOptions extends OptionsBase {
)
public long versionWindowForDirtyNodeGc;

@Option(
name = "experimental_skyframe_prepare_analysis",
deprecationWarning = "This flag is a no-op and will be deleted in a future release.",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
help = "Deprecated. No-op.")
public boolean skyframePrepareAnalysis;

@Option(
name = "experimental_skyframe_cpu_heavy_skykeys_thread_pool_size",
defaultValue = "HOST_CPUS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,20 @@
// 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;

import static com.google.common.collect.ImmutableSet.toImmutableSet;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue;
import com.google.devtools.build.lib.analysis.config.ConfigurationResolver;
import com.google.devtools.build.lib.analysis.config.ConfigurationResolver.TopLevelTargetsAndConfigsResult;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.analysis.config.TransitionResolver;
import com.google.devtools.build.lib.analysis.config.transitions.ConfigurationTransition;
import com.google.devtools.build.lib.analysis.config.transitions.NoTransition;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.BuiltinProvider;
import com.google.devtools.build.lib.packages.Info;
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
import com.google.devtools.build.lib.packages.StarlarkProviderWrapper;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.packages.TriState;
import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Collection;
import java.util.List;

/**
Expand Down Expand Up @@ -190,58 +174,4 @@ public static <T extends TransitiveInfoProvider> void checkProvider(Class<T> cla
clazz + " is generated by @AutoValue; use " + clazz.getSuperclass() + " instead");
}
}

/**
* Given a set of *top-level* targets and a configuration collection, evaluate top level
* transitions, resolve configurations and return the appropriate <Target, Configuration> pair for
* each target.
*
* <p>Preserves the original input ordering.
*/
public static TopLevelTargetsAndConfigsResult getTargetsWithConfigs(
BuildConfigurationValue targetConfiguration,
Collection<Target> targets,
ExtendedEventHandler eventHandler,
ConfiguredRuleClassProvider ruleClassProvider,
ConfigurationsCollector configurationsCollector)
throws InvalidConfigurationException, InterruptedException {
// We use a set here to remove duplicate nodes; this can happen for input files and package
// groups.
ImmutableSet<TargetAndConfiguration> nodes =
targets.stream()
.map(target -> new TargetAndConfiguration(target, targetConfiguration))
.collect(toImmutableSet());

// We'll get the configs from ConfigurationsCollector#getConfigurations, which gets
// configurations for deps including transitions.
Multimap<BuildConfigurationValue, DependencyKey> asDeps =
targetsToDeps(nodes, ruleClassProvider);

return ConfigurationResolver.getConfigurationsFromExecutor(
nodes, asDeps, eventHandler, configurationsCollector);
}

@VisibleForTesting
public static Multimap<BuildConfigurationValue, DependencyKey> targetsToDeps(
Collection<TargetAndConfiguration> nodes, ConfiguredRuleClassProvider ruleClassProvider) {
Multimap<BuildConfigurationValue, DependencyKey> asDeps = ArrayListMultimap.create();
for (TargetAndConfiguration targetAndConfig : nodes) {
ConfigurationTransition transition =
TransitionResolver.evaluateTransition(
targetAndConfig.getConfiguration(),
NoTransition.INSTANCE,
targetAndConfig.getTarget(),
ruleClassProvider.getTrimmingTransitionFactory());
if (targetAndConfig.getConfiguration() != null) {
// TODO(bazel-team): support top-level aspects
asDeps.put(
targetAndConfig.getConfiguration(),
DependencyKey.builder()
.setLabel(targetAndConfig.getLabel())
.setTransition(transition)
.build());
}
}
return asDeps;
}
}
39 changes: 20 additions & 19 deletions src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ java_library(
":config/transitions/patch_transition",
":config/transitions/split_transition",
":config/transitions/transition_factory",
":configurations_collector",
":configured_object_value",
":configured_target",
":constraints/constraint_constants",
Expand Down Expand Up @@ -290,6 +289,7 @@ java_library(
":config/build_options",
":config/config_conditions",
":config/config_matching_provider",
":config/configuration_transition_event",
":config/core_options",
":config/execution_transition_factory",
":config/feature_set",
Expand All @@ -314,7 +314,6 @@ java_library(
":config/transitions/starlark_exposed_rule_transition_factory",
":config/transitions/transition_collector",
":config/transitions/transition_factory",
":configurations_collector",
":configured_target",
":constraints/constraint_constants",
":constraints/constraint_semantics",
Expand Down Expand Up @@ -625,7 +624,6 @@ java_library(
":constraints/top_level_constraint_semantics",
":extra_action_artifacts_provider",
":make_environment_event",
":target_and_configuration",
":test/coverage_report_action_factory",
":test/instrumented_files_info",
":top_level_artifact_context",
Expand Down Expand Up @@ -673,22 +671,6 @@ java_library(
],
)

java_library(
name = "configurations_collector",
srcs = [
"ConfigurationsCollector.java",
"ConfigurationsResult.java",
],
deps = [
":config/build_configuration",
":config/build_options",
":config/invalid_configuration_exception",
":dependency_key",
"//src/main/java/com/google/devtools/build/lib/events",
"//third_party:guava",
],
)

java_library(
name = "configured_object_value",
srcs = ["ConfiguredObjectValue.java"],
Expand Down Expand Up @@ -1817,6 +1799,25 @@ java_library(
],
)

java_library(
name = "config/configuration_transition_event",
srcs = ["config/ConfigurationTransitionEvent.java"],
deps = [
"//src/main/java/com/google/devtools/build/lib/events",
"//third_party:auto_value",
],
)

java_library(
name = "config/configuration_value_event",
srcs = ["config/ConfigurationValueEvent.java"],
deps = [
":config/build_configuration",
"//src/main/java/com/google/devtools/build/lib/events",
"//third_party:auto_value",
],
)

java_library(
name = "config/core_option_converters",
srcs = ["config/CoreOptionConverters.java"],
Expand Down

0 comments on commit c92ed72

Please sign in to comment.