Skip to content

Commit

Permalink
Remove ConfigurationEnvironment#getFragment()
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 218846882
  • Loading branch information
scentini authored and Copybara-Service committed Oct 26, 2018
1 parent f63c765 commit 2c90147
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package com.google.devtools.build.lib.analysis.config;

import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.packages.NoSuchPackageException;
Expand Down Expand Up @@ -70,10 +69,6 @@ Target getTarget(Label label)
*/
@Deprecated
Path getPath(Package pkg, String fileName) throws InterruptedException;

/** Returns fragment based on fragment class and build options. */
<T extends Fragment> T getFragment(BuildOptions buildOptions, Class<T> fragmentType)
throws InvalidConfigurationException, InterruptedException;
/**
* An implementation backed by a {@link PackageProvider} instance.
*/
Expand All @@ -95,10 +90,5 @@ public Target getTarget(final Label label)
public Path getPath(Package pkg, String fileName) {
return pkg.getPackageDirectory().getRelative(fileName);
}

@Override
public <T extends Fragment> T getFragment(BuildOptions buildOptions, Class<T> fragmentType) {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.lib.analysis.config;

import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
Expand All @@ -35,10 +34,6 @@ public interface PackageProviderForConfigurations {
*/
void addDependency(Package pkg, String fileName)
throws LabelSyntaxException, IOException, InterruptedException;

/** Returns fragment based on fragment type and build options. */
<T extends Fragment> T getFragment(BuildOptions buildOptions, Class<T> fragmentType)
throws InvalidConfigurationException, InterruptedException;

/**
* Returns true if any dependency is missing (value of some node hasn't been evaluated yet).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private static CrosstoolRelease findCrosstoolConfiguration(

/** Reads a crosstool file. */
@Nullable
public static CrosstoolRelease readCrosstool(ConfigurationEnvironment env, Label crosstoolTop)
static CrosstoolRelease readCrosstool(ConfigurationEnvironment env, Label crosstoolTop)
throws InvalidConfigurationException, InterruptedException {
crosstoolTop = RedirectChaser.followRedirects(env, crosstoolTop, "crosstool_top");
if (crosstoolTop == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.packages.RuleClassProvider;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.skyframe.ConfigurationFragmentValue.ConfigurationFragmentKey;
import com.google.devtools.build.lib.vfs.Path;
Expand All @@ -41,13 +40,10 @@
*/
public final class ConfigurationFragmentFunction implements SkyFunction {
private final Supplier<ImmutableList<ConfigurationFragmentFactory>> configurationFragments;
private final RuleClassProvider ruleClassProvider;

public ConfigurationFragmentFunction(
Supplier<ImmutableList<ConfigurationFragmentFactory>> configurationFragments,
RuleClassProvider ruleClassProvider) {
Supplier<ImmutableList<ConfigurationFragmentFactory>> configurationFragments) {
this.configurationFragments = configurationFragments;
this.ruleClassProvider = ruleClassProvider;
}

@Override
Expand All @@ -59,7 +55,7 @@ public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedExcept
ConfigurationFragmentFactory factory = getFactory(configurationFragmentKey.getFragmentType());
try {
PackageProviderForConfigurations packageProvider =
new SkyframePackageLoaderWithValueEnvironment(env, ruleClassProvider);
new SkyframePackageLoaderWithValueEnvironment(env);
ConfigurationEnvironment confEnv = new ConfigurationBuilderEnvironment(packageProvider);
Fragment fragment = factory.create(confEnv, buildOptions);

Expand Down Expand Up @@ -119,11 +115,6 @@ public Path getPath(Package pkg, String fileName) throws InterruptedException {
return result;
}

@Override
public <T extends Fragment> T getFragment(BuildOptions buildOptions, Class<T> fragmentType)
throws InvalidConfigurationException, InterruptedException {
return packageProvider.getFragment(buildOptions, fragmentType);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ private ImmutableMap<SkyFunctionName, SkyFunction> skyFunctions(
new BuildConfigurationFunction(directories, ruleClassProvider, defaultBuildOptions));
map.put(
SkyFunctions.CONFIGURATION_FRAGMENT,
new ConfigurationFragmentFunction(configurationFragments, ruleClassProvider));
new ConfigurationFragmentFunction(configurationFragments));
map.put(SkyFunctions.WORKSPACE_NAME, new WorkspaceNameFunction());
map.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider));
map.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
package com.google.devtools.build.lib.skyframe;

import com.google.devtools.build.lib.actions.FileValue;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.analysis.config.PackageProviderForConfigurations;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
Expand All @@ -25,7 +22,6 @@
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.packages.RuleClassProvider;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.skyframe.SkyframeExecutor.SkyframePackageLoader;
import com.google.devtools.build.lib.vfs.RootedPath;
Expand All @@ -41,12 +37,9 @@
*/
class SkyframePackageLoaderWithValueEnvironment implements PackageProviderForConfigurations {
private final SkyFunction.Environment env;
private final RuleClassProvider ruleClassProvider;

SkyframePackageLoaderWithValueEnvironment(
SkyFunction.Environment env, RuleClassProvider ruleClassProvider) {
SkyframePackageLoaderWithValueEnvironment(SkyFunction.Environment env) {
this.env = env;
this.ruleClassProvider = ruleClassProvider;
}

@Override
Expand Down Expand Up @@ -82,18 +75,6 @@ public void addDependency(Package pkg, String fileName)
}
}

@Override
public <T extends Fragment> T getFragment(BuildOptions buildOptions, Class<T> fragmentType)
throws InvalidConfigurationException, InterruptedException {
ConfigurationFragmentValue fragmentNode = (ConfigurationFragmentValue) env.getValueOrThrow(
ConfigurationFragmentValue.key(buildOptions, fragmentType, ruleClassProvider),
InvalidConfigurationException.class);
if (fragmentNode == null) {
return null;
}
return fragmentType.cast(fragmentNode.getFragment());
}

@Override
public boolean valuesMissing() {
return env.valuesMissing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
import com.google.devtools.build.lib.rules.java.JavaConfiguration;
import com.google.devtools.build.lib.rules.objc.J2ObjcConfiguration;
import com.google.devtools.build.lib.skyframe.BuildConfigurationValue;
import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester;
Expand Down Expand Up @@ -198,58 +197,6 @@ public void testTargetEnvironment() throws Exception {
assertThat(noEnvsConfig.getTargetEnvironments()).isEmpty();
}

@SafeVarargs
@SuppressWarnings("unchecked")
private final ConfigurationFragmentFactory createMockFragment(
final Class<? extends Fragment> creates, final Class<? extends Fragment>... dependsOn) {
return new ConfigurationFragmentFactory() {

@Override
public Class<? extends Fragment> creates() {
return creates;
}

@Override
public ImmutableSet<Class<? extends FragmentOptions>> requiredOptions() {
return ImmutableSet.of();
}

@Override
public Fragment create(ConfigurationEnvironment env, BuildOptions buildOptions)
throws InvalidConfigurationException, InterruptedException {
for (Class<? extends Fragment> fragmentType : dependsOn) {
env.getFragment(buildOptions, fragmentType);
}
return new Fragment() {};
}
};
}

@Test
public void testCycleInFragments() throws Exception {
configurationFragmentFactories = ImmutableList.of(
createMockFragment(CppConfiguration.class, JavaConfiguration.class),
createMockFragment(JavaConfiguration.class, CppConfiguration.class));
try {
createCollection();
fail();
} catch (IllegalStateException e) {
// expected
}
}

@Test
public void testMissingFragment() throws Exception {
configurationFragmentFactories = ImmutableList.of(
createMockFragment(CppConfiguration.class, JavaConfiguration.class));
try {
createCollection();
fail();
} catch (RuntimeException e) {
// expected
}
}

@Test
public void testGlobalMakeVariableOverride() throws Exception {
assertThat(create().getMakeEnvironment()).containsEntry("COMPILATION_MODE", "fastbuild");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.google.devtools.build.lib.vfs.Path;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public final class BazelAnalysisMock extends AnalysisMock {
Expand Down Expand Up @@ -326,11 +325,6 @@ public ConfiguredRuleClassProvider createRuleClassProvider() {
return TestRuleClassProvider.getRuleClassProvider(true);
}

@Override
public Collection<String> getOptionOverrides() {
return ImmutableList.of();
}

@Override
public boolean isThisBazel() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import com.google.devtools.common.options.InvocationPolicyEnforcer;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

Expand Down Expand Up @@ -109,8 +108,6 @@ public String getDefaultsPackageContent() {
@Override
public abstract ConfiguredRuleClassProvider createRuleClassProvider();

public abstract Collection<String> getOptionOverrides();

public abstract boolean isThisBazel();

public abstract MockCcSupport ccSupport();
Expand Down Expand Up @@ -191,11 +188,6 @@ public MockPythonSupport pySupport() {
return delegate.pySupport();
}

@Override
public Collection<String> getOptionOverrides() {
return delegate.getOptionOverrides();
}

@Override
public ImmutableMap<SkyFunctionName, SkyFunction> getSkyFunctions(
BlazeDirectories directories) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ protected final BuildConfigurationCollection createConfigurations(String... args
allArgs.add("--stamp"); // Stamp is now defaulted to false.
allArgs.add("--experimental_extended_sanity_checks");
allArgs.add("--features=cc_include_scanning");
allArgs.addAll(getAnalysisMock().getOptionOverrides());

optionsParser.parse(allArgs);
optionsParser.parse(args);
Expand Down

0 comments on commit 2c90147

Please sign in to comment.