Skip to content

Commit

Permalink
Remove package loading from CppConfiguration
Browse files Browse the repository at this point in the history
This change removes RedirectChaser and code that it retained.

RELNOTES: CppConfiguration doesn't do package loading anymore. That means:
* it's no longer needed to have C++ toolchain available when building non-C++ projects
* bazel will not analyze C++ toolchain when not needed -> speedup ~2s on bazel startup when C++ rules using hermetic toolchain are not loaded
PiperOrigin-RevId: 222957363
  • Loading branch information
hlopko authored and Copybara-Service committed Nov 27, 2018
1 parent f75fd8c commit 37dc726
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 565 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment;
import javax.annotation.Nullable;

/**
* A factory that creates configuration fragments.
Expand All @@ -24,40 +23,11 @@ public interface ConfigurationFragmentFactory {
/**
* Creates a configuration fragment.
*
* <p>All implementations should override this method unless they have a really good reason
* to override {@link #create(ConfigurationEnvironment, BuildOptions)} instead. The latter
* interface is slated for removal once we detach legacy callers.
*
* @param buildOptions command-line options (see {@link FragmentOptions})
* @return the configuration fragment or null if some required dependencies are missing.
*/
@Nullable
default BuildConfiguration.Fragment create(BuildOptions buildOptions)
throws InvalidConfigurationException, InterruptedException {
throw new IllegalStateException(
"One of this method's signatures must be overridden to have a valid fragment creator");
}

/**
* Creates a configuration fragment: <b>LEGACY VERSION</b>.
*
* <p>For implementations that cannot override {@link #create(BuildOptions)} because they really
* need access to {@link ConfigurationEnvironment}. {@link ConfigurationEnvironment} adds extra
* dependencies to fragment creation that makes the whole process more complicated and delicate.
* We're also working on Bazel enhancements that will make current calls unnecessary. So this
* version really only exists as a stopgap before we can migrate away the legacy calls.
*
* @param env the ConfigurationEnvironment for querying targets and paths
* @param buildOptions command-line options (see {@link FragmentOptions})
* @return the configuration fragment or null if some required dependencies are missing.
*/
@Deprecated
@Nullable
default BuildConfiguration.Fragment create(ConfigurationEnvironment env,
BuildOptions buildOptions) throws InvalidConfigurationException, InterruptedException {
return create(buildOptions);
}

BuildConfiguration.Fragment create(BuildOptions buildOptions)
throws InvalidConfigurationException;

/**
* @return the exact type of the fragment this factory creates.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public String toString() {
// verify that the two are the same, we can remove one of desiredCpu and targetCpu.
private final String desiredCpu;

private final Label redirectChasedCrosstoolTop;
private final PathFragment fdoPath;
private final Label fdoOptimizeLabel;

Expand All @@ -163,8 +162,7 @@ public String toString() {
private final boolean stripBinaries;
private final CompilationMode compilationMode;

static CppConfiguration create(
CpuTransformer cpuTransformer, Label redirectChasedCrosstoolTop, BuildOptions options)
static CppConfiguration create(CpuTransformer cpuTransformer, BuildOptions options)
throws InvalidConfigurationException {
CppOptions cppOptions = options.get(CppOptions.class);

Expand Down Expand Up @@ -199,7 +197,6 @@ static CppConfiguration create(

return new CppConfiguration(
cpuTransformer.getTransformer().apply(commonOptions.cpu),
redirectChasedCrosstoolTop,
Preconditions.checkNotNull(commonOptions.cpu),
fdoPath,
fdoProfileLabel,
Expand All @@ -218,7 +215,6 @@ static CppConfiguration create(

private CppConfiguration(
String transformedCpuFromOptions,
Label redirectChasedCrosstoolTop,
String desiredCpu,
PathFragment fdoPath,
Label fdoOptimizeLabel,
Expand All @@ -232,7 +228,6 @@ private CppConfiguration(
boolean stripBinaries,
CompilationMode compilationMode) {
this.transformedCpuFromOptions = transformedCpuFromOptions;
this.redirectChasedCrosstoolTop = redirectChasedCrosstoolTop;
this.desiredCpu = desiredCpu;
this.fdoPath = fdoPath;
this.fdoOptimizeLabel = fdoOptimizeLabel;
Expand All @@ -254,7 +249,7 @@ private CppConfiguration(
defaultLabel = "//tools/cpp:crosstool",
defaultInToolRepository = true)
public Label getRuleProvidingCcToolchainProvider() {
return redirectChasedCrosstoolTop;
return cppOptions.crosstoolTop;
}

/**
Expand Down Expand Up @@ -571,10 +566,6 @@ boolean enableCcToolchainConfigInfoFromSkylark() {
return cppOptions.enableCcToolchainConfigInfoFromSkylark;
}

public Label getCrosstoolTop() {
return cppOptions.crosstoolTop;
}

/**
* Returns the value of the libc top-level directory (--grte_top) as specified on the command line
*/
Expand Down
Loading

0 comments on commit 37dc726

Please sign in to comment.