Skip to content

Commit

Permalink
Remove CppToolchainInfo
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 252830462
  • Loading branch information
scentini authored and copybara-github committed Jun 12, 2019
1 parent 372f412 commit a103ec0
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 344 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public final class CcToolchainProvider extends ToolchainInfo
new CcToolchainProvider(
/* values= */ ImmutableMap.of(),
/* cppConfiguration= */ null,
/* toolchainInfo= */ null,
/* toolchainFeatures= */ null,
/* crosstoolTopPathFragment= */ null,
/* allFiles= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
Expand Down Expand Up @@ -88,10 +87,24 @@ public final class CcToolchainProvider extends ToolchainInfo
/* fdoContext= */ null,
/* isHostConfiguration= */ false,
/* licensesProvider= */ null,
/* toolPaths= */ ImmutableMap.of());
/* toolPaths= */ ImmutableMap.of(),
/* toolchainIdentifier= */ "",
/* compiler= */ "",
/* abiGlibcVersion= */ "",
/* targetCpu= */ "",
/* targetOS= */ "",
/* defaultSysroot= */ PathFragment.EMPTY_FRAGMENT,
/* runtimeSysroot= */ PathFragment.EMPTY_FRAGMENT,
/* targetLibc= */ "",
/* hostSystemName= */ "",
/* ccToolchainLabel= */ null,
/* solibDirectory= */ "",
/* abi= */ "",
/* targetSystemName= */ "",
/* additionalMakeVariables= */ ImmutableMap.of(),
/* legacyCcFlagsMakeVariable= */ "");

@Nullable private final CppConfiguration cppConfiguration;
private final CppToolchainInfo toolchainInfo;
private final PathFragment crosstoolTopPathFragment;
private final NestedSet<Artifact> allFiles;
private final NestedSet<Artifact> allFilesMiddleman;
Expand Down Expand Up @@ -126,6 +139,23 @@ public final class CcToolchainProvider extends ToolchainInfo
private final boolean isHostConfiguration;
private final ImmutableMap<String, PathFragment> toolPaths;
private final CcToolchainFeatures toolchainFeatures;
private final String toolchainIdentifier;
private final String compiler;
private final String targetCpu;
private final String targetOS;
private final PathFragment defaultSysroot;
private final PathFragment runtimeSysroot;
private final String abiGlibcVersion;
private final String abi;
private final String targetLibc;
private final String hostSystemName;
private final String targetSystemName;
private final Label ccToolchainLabel;
private final String solibDirectory;

private final ImmutableMap<String, String> additionalMakeVariables;
// TODO(b/65151735): Remove when cc_flags is entirely from features.
private final String legacyCcFlagsMakeVariable;
/**
* WARNING: We don't like {@link FdoContext}. Its {@link FdoContext#fdoProfilePath} is pure path
* and that is horrible as it breaks many Bazel assumptions! Don't do bad stuff with it, don't
Expand All @@ -138,7 +168,6 @@ public final class CcToolchainProvider extends ToolchainInfo
public CcToolchainProvider(
ImmutableMap<String, Object> values,
@Nullable CppConfiguration cppConfiguration,
CppToolchainInfo toolchainInfo,
CcToolchainFeatures toolchainFeatures,
PathFragment crosstoolTopPathFragment,
NestedSet<Artifact> allFiles,
Expand Down Expand Up @@ -174,10 +203,24 @@ public CcToolchainProvider(
FdoContext fdoContext,
boolean isHostConfiguration,
LicensesProvider licensesProvider,
ImmutableMap<String, PathFragment> toolPaths) {
ImmutableMap<String, PathFragment> toolPaths,
String toolchainIdentifier,
String compiler,
String abiGlibcVersion,
String targetCpu,
String targetOS,
PathFragment defaultSysroot,
PathFragment runtimeSysroot,
String targetLibc,
String hostSystemName,
Label ccToolchainLabel,
String solibDirectory,
String abi,
String targetSystemName,
ImmutableMap<String, String> additionalMakeVariables,
String legacyCcFlagsMakeVariable) {
super(values, Location.BUILTIN);
this.cppConfiguration = cppConfiguration;
this.toolchainInfo = toolchainInfo;
this.crosstoolTopPathFragment = crosstoolTopPathFragment;
this.allFiles = Preconditions.checkNotNull(allFiles);
this.allFilesMiddleman = Preconditions.checkNotNull(allFilesMiddleman);
Expand Down Expand Up @@ -213,11 +256,26 @@ public CcToolchainProvider(
this.builtInIncludeDirectories = builtInIncludeDirectories;
this.sysroot = sysroot;
this.targetSysroot = targetSysroot;
this.defaultSysroot = defaultSysroot;
this.runtimeSysroot = runtimeSysroot;
this.fdoContext = fdoContext == null ? FdoContext.getDisabledContext() : fdoContext;
this.isHostConfiguration = isHostConfiguration;
this.licensesProvider = licensesProvider;
this.toolPaths = toolPaths;
this.toolchainFeatures = toolchainFeatures;
this.toolchainIdentifier = toolchainIdentifier;
this.compiler = compiler;
this.abiGlibcVersion = abiGlibcVersion;
this.targetCpu = targetCpu;
this.targetOS = targetOS;
this.targetLibc = targetLibc;
this.hostSystemName = hostSystemName;
this.ccToolchainLabel = ccToolchainLabel;
this.solibDirectory = solibDirectory;
this.abi = abi;
this.targetSystemName = targetSystemName;
this.additionalMakeVariables = additionalMakeVariables;
this.legacyCcFlagsMakeVariable = legacyCcFlagsMakeVariable;
}

/**
Expand Down Expand Up @@ -398,7 +456,7 @@ public ImmutableList<PathFragment> getBuiltInIncludeDirectories() {

/** Returns the identifier of the toolchain as specified in the {@code CToolchain} proto. */
public String getToolchainIdentifier() {
return toolchainInfo.getToolchainIdentifier();
return toolchainIdentifier;
}

/** Returns all the files in Crosstool. Is not a middleman. */
Expand Down Expand Up @@ -586,7 +644,7 @@ public CcToolchainFeatures getFeatures() {
}

public Label getCcToolchainLabel() {
return toolchainInfo.getCcToolchainLabel();
return ccToolchainLabel;
}

/**
Expand All @@ -595,15 +653,15 @@ public Label getCcToolchainLabel() {
* sysroots, then this method returns <code>null</code>.
*/
public PathFragment getRuntimeSysroot() {
return toolchainInfo.getRuntimeSysroot();
return runtimeSysroot;
}

/**
* Return the name of the directory (relative to the bin directory) that holds mangled links to
* shared libraries. This name is always set to the '{@code _solib_<cpu_archictecture_name>}.
*/
public String getSolibDirectory() {
return toolchainInfo.getSolibDirectory();
return solibDirectory;
}

/** Returns whether the toolchain supports dynamic linking. */
Expand Down Expand Up @@ -714,7 +772,7 @@ public PathFragment getSysrootPathFragment(CppConfiguration cppConfiguration) {
*/
// TODO(bazel-team): The javadoc should clarify how this is used in Blaze.
public String getAbi() {
return toolchainInfo.getAbi();
return abi;
}

/**
Expand All @@ -725,25 +783,25 @@ public String getAbi() {
*/
// TODO(bazel-team): The javadoc should clarify how this is used in Blaze.
public String getAbiGlibcVersion() {
return toolchainInfo.getAbiGlibcVersion();
return abiGlibcVersion;
}

/** Returns the compiler version string (e.g. "gcc-4.1.1"). */
@Override
public String getCompiler() {
return toolchainInfo == null ? null : toolchainInfo.getCompiler();
return compiler;
}

/** Returns the libc version string (e.g. "glibc-2.2.2"). */
@Override
public String getTargetLibc() {
return toolchainInfo == null ? null : toolchainInfo.getTargetLibc();
return targetLibc;
}

/** Returns the target architecture using blaze-specific constants (e.g. "piii"). */
@Override
public String getTargetCpu() {
return toolchainInfo == null ? null : toolchainInfo.getTargetCpu();
return targetCpu;
}

/**
Expand All @@ -755,7 +813,7 @@ public String getTargetCpu() {
* may be an empty string.
*/
public ImmutableMap<String, String> getAdditionalMakeVariables() {
return toolchainInfo.getAdditionalMakeVariables();
return additionalMakeVariables;
}

/**
Expand All @@ -766,7 +824,7 @@ public ImmutableMap<String, String> getAdditionalMakeVariables() {
// TODO(b/65151735): Remove when cc_flags is entirely from features.
@Deprecated
public String getLegacyCcFlagsMakeVariable() {
return toolchainInfo.getLegacyCcFlagsMakeVariable();
return legacyCcFlagsMakeVariable;
}

public FdoContext getFdoContext() {
Expand All @@ -780,27 +838,33 @@ public FdoContext getFdoContext() {
*/
@Deprecated
public String getTargetOS() {
return toolchainInfo.getTargetOS();
return targetOS;
}

/** Returns the system name which is required by the toolchain to run. */
public String getHostSystemName() {
return toolchainInfo.getHostSystemName();
return hostSystemName;
}

/** Returns the GNU System Name */
@Override
public String getTargetGnuSystemName() {
return toolchainInfo == null ? null : toolchainInfo.getTargetGnuSystemName();
return targetSystemName;
}

/** Returns the architecture component of the GNU System Name */
public String getGnuSystemArch() {
return toolchainInfo.getGnuSystemArch();
if (targetSystemName.indexOf('-') == -1) {
return targetSystemName;
}
return targetSystemName.substring(0, targetSystemName.indexOf('-'));
}

public final boolean isLLVMCompiler() {
return toolchainInfo.isLLVMCompiler();
// TODO(tmsriram): Checking for "llvm" does not handle all the cases. This
// is temporary until the crosstool configuration is modified to add fields that
// indicate which flavor of fdo is being used.
return toolchainIdentifier.contains("llvm");
}

/**
Expand Down Expand Up @@ -887,7 +951,7 @@ public LicensesProvider getLicensesProvider() {
}

public PathFragment getDefaultSysroot() {
return toolchainInfo.getDefaultSysroot();
return defaultSysroot;
}

public boolean requireCtxInConfigureFeatures() {
Expand Down
Loading

0 comments on commit a103ec0

Please sign in to comment.