From 58502f2103d876fa734d53f29eff69bf48c19ea6 Mon Sep 17 00:00:00 2001 From: Ulf Adams Date: Thu, 24 Sep 2015 13:27:35 +0000 Subject: Remove the experimental check-deps implementation. -- MOS_MIGRATED_REVID=103839895 --- .../devtools/build/lib/analysis/AnalysisHooks.java | 36 ------------ .../lib/bazel/rules/java/BazelJavaSemantics.java | 18 +----- .../lib/rules/java/DirectDependencyProvider.java | 64 ---------------------- .../devtools/build/lib/rules/java/JavaCommon.java | 17 ------ .../lib/rules/java/JavaCompilationHelper.java | 4 -- .../build/lib/rules/java/JavaCompileAction.java | 3 +- .../build/lib/rules/java/JavaSemantics.java | 6 -- 7 files changed, 2 insertions(+), 146 deletions(-) delete mode 100644 src/main/java/com/google/devtools/build/lib/analysis/AnalysisHooks.java delete mode 100644 src/main/java/com/google/devtools/build/lib/rules/java/DirectDependencyProvider.java (limited to 'src/main/java/com/google/devtools') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisHooks.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisHooks.java deleted file mode 100644 index 82c448514c..0000000000 --- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisHooks.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 Google Inc. 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; - -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.packages.Target; -import com.google.devtools.build.lib.pkgcache.PackageManager; - -/** - * This interface resolves target - configuration pairs to {@link ConfiguredTarget} instances. - * - *

This interface is used to provide analysis phase functionality to actions that need it in - * the execution phase. - */ -public interface AnalysisHooks { - /** - * Returns the package manager used during the analysis phase. - */ - PackageManager getPackageManager(); - - /** - * Resolves an existing configured target. Returns null if it is not in the cache. - */ - ConfiguredTarget getExistingConfiguredTarget(Target target, BuildConfiguration configuration); -} diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java index ea8908a974..2b36476e2a 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java @@ -29,13 +29,10 @@ import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction.Co import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction.Substitution; import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction.Template; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration.StrictDepsMode; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.rules.java.DeployArchiveBuilder; import com.google.devtools.build.lib.rules.java.DeployArchiveBuilder.Compression; -import com.google.devtools.build.lib.rules.java.DirectDependencyProvider; -import com.google.devtools.build.lib.rules.java.DirectDependencyProvider.Dependency; import com.google.devtools.build.lib.rules.java.JavaCommon; import com.google.devtools.build.lib.rules.java.JavaCompilationArtifacts; import com.google.devtools.build.lib.rules.java.JavaCompilationHelper; @@ -232,15 +229,7 @@ public class BazelJavaSemantics implements JavaSemantics { JavaCompilationHelper helper, NestedSetBuilder filesBuilder, RuleConfiguredTargetBuilder ruleBuilder) { - if (!isJavaBinaryOrJavaTest(ruleContext)) { - Artifact outputDepsProto = helper.getOutputDepsProtoArtifact(); - if (outputDepsProto != null && helper.getStrictJavaDeps() != StrictDepsMode.OFF) { - ImmutableList strictDependencies = - javaCommon.computeStrictDepsFromJavaAttributes(helper.getAttributes()); - ruleBuilder.add(DirectDependencyProvider.class, - new DirectDependencyProvider(strictDependencies)); - } - } else { + if (isJavaBinaryOrJavaTest(ruleContext)) { boolean createExec = ruleContext.attributes().get("create_executable", Type.BOOLEAN); ruleBuilder.add(JavaPrimaryClassProvider.class, new JavaPrimaryClassProvider(createExec ? getMainClassInternal(ruleContext) : null)); @@ -262,11 +251,6 @@ public class BazelJavaSemantics implements JavaSemantics { return mainClass; } - @Override - public boolean useStrictJavaDeps(BuildConfiguration configuration) { - return true; - } - @Override public CustomCommandLine buildSingleJarCommandLine(BuildConfiguration configuration, Artifact output, String mainClass, ImmutableList manifestLines, diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/DirectDependencyProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/DirectDependencyProvider.java deleted file mode 100644 index 9712fdff9a..0000000000 --- a/src/main/java/com/google/devtools/build/lib/rules/java/DirectDependencyProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2014 Google Inc. 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.rules.java; - -import com.google.common.collect.ImmutableList; -import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; - -/** - * A provider that returns the direct dependencies of a target. Used for strict dependency - * checking. - */ -@Immutable -public final class DirectDependencyProvider implements TransitiveInfoProvider { - - private final ImmutableList strictDependencies; - - public DirectDependencyProvider(Iterable strictDependencies) { - this.strictDependencies = ImmutableList.copyOf(strictDependencies); - } - - /** - * @returns the direct (strict) dependencies of this provider. All symbols that are directly - * reachable from the sources of the provider should be available in one these artifacts. - */ - public Iterable getStrictDependencies() { - return strictDependencies; - } - - /** - * A pair of label and its generated list of artifacts. - */ - public static class Dependency { - private final Label label; - - // TODO(bazel-team): change this to Artifacts - private final Iterable fileExecPaths; - - public Dependency(Label label, Iterable fileExecPaths) { - this.label = label; - this.fileExecPaths = fileExecPaths; - } - - public Label getLabel() { - return label; - } - - public Iterable getDependencyOutputs() { - return fileExecPaths; - } - } -} diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java index ce7954c7fb..702cd906ef 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java @@ -15,13 +15,11 @@ package com.google.devtools.build.lib.rules.java; import com.google.common.base.Function; import com.google.common.base.Preconditions; -import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.AnalysisEnvironment; @@ -42,7 +40,6 @@ import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.rules.cpp.CppCompilationContext; import com.google.devtools.build.lib.rules.cpp.LinkerInput; -import com.google.devtools.build.lib.rules.java.DirectDependencyProvider.Dependency; import com.google.devtools.build.lib.rules.java.JavaCompilationArgs.ClasspathType; import com.google.devtools.build.lib.rules.test.InstrumentedFilesCollector; import com.google.devtools.build.lib.rules.test.InstrumentedFilesCollector.InstrumentationSpec; @@ -707,20 +704,6 @@ public class JavaCommon { return NestedSetBuilder.create(Order.STABLE_ORDER, classJar); } - public ImmutableList computeStrictDepsFromJavaAttributes( - JavaTargetAttributes javaTargetAttributes) { - Multimap depMap = HashMultimap.create(); - for (Artifact jar : javaTargetAttributes.getDirectJars()) { - depMap.put(Preconditions.checkNotNull(jar.getOwner()), - jar.getExecPathString()); - } - ImmutableList.Builder depOuts = ImmutableList.builder(); - for (Label label : depMap.keySet()) { - depOuts.add(new Dependency(label, depMap.get(label))); - } - return depOuts.build(); - } - public ImmutableList getSrcsArtifacts() { return sources; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java index 7aad5ba86a..d13258c259 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java @@ -265,10 +265,6 @@ public class JavaCompilationHelper extends BaseJavaCompilationHelper { .setMnemonic("JavaSourceJar") .build(getRuleContext())); } - - public Artifact getOutputDepsProtoArtifact() { - return outputDepsProtoArtifact; - } /** * Creates the jdeps file artifact if needed. Returns null if the target can't emit dependency diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java index 13457f304a..4496bc743c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java @@ -568,8 +568,7 @@ public class JavaCompileAction extends AbstractAction { // written out and whether we try to minimize the compile-time classpath. if (strictJavaDeps != BuildConfiguration.StrictDepsMode.OFF) { result.add("--strict_java_deps"); - result.add((semantics.useStrictJavaDeps(configuration) ? strictJavaDeps - : BuildConfiguration.StrictDepsMode.OFF).toString()); + result.add(strictJavaDeps.toString()); result.add(new CustomMultiArgv() { @Override public Iterable argv() { diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java index 16ad9756d5..6695da7fe2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java @@ -298,12 +298,6 @@ public interface JavaSemantics { NestedSetBuilder filesBuilder, RuleConfiguredTargetBuilder ruleBuilder) throws InterruptedException; - /** - * Tell if a build with the given configuration should use strict java dependencies. This method - * enforces strict java dependencies off if it returns false. - */ - boolean useStrictJavaDeps(BuildConfiguration configuration); - /** * Translates XMB messages to translations artifact suitable for Java targets. */ -- cgit v1.2.3