aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java
diff options
context:
space:
mode:
authorGravatar rosica <rosica@google.com>2018-06-21 02:05:54 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-21 02:07:33 -0700
commitc97082475fc2b60251dc19d8882b668f1547b9b7 (patch)
treea25aa76bb1b2f6d98fcc3a76de6c8ca63c656bcd /src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java
parent5a9befc5602e71f7512074c303afbdcff5617cca (diff)
Extract logic from CROSSTOOL in CrosstoolInfo provider
CrosstoolInfo carries the necessary information from the CROSSTOOL text proto. Later on, instead from the CROSSTOOL file and the corresponding CToolchain, CrosstoolInfo will be derived from a skylark_crosstool rule implemented in Skylark. Therefore CToolchain involvement in CppConfiguration and CcToolchain creation needs to be eliminated. Work towards issue #5380 RELNOTES: None. PiperOrigin-RevId: 201491207
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java
index 48ec524c0b..a4e2d3f9a8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java
@@ -78,7 +78,6 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory {
* Value class for all the data needed to create a {@link CppConfiguration}.
*/
public static class CppConfigurationParameters {
- protected final CrosstoolConfig.CToolchain toolchain;
protected final CrosstoolConfigurationLoader.CrosstoolFile crosstoolFile;
protected final String cacheKeySuffix;
protected final BuildConfiguration.Options commonOptions;
@@ -90,9 +89,9 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory {
protected final Label fdoOptimizeLabel;
protected final Label sysrootLabel;
protected final CpuTransformer cpuTransformer;
+ protected final CrosstoolInfo crosstoolInfo;
CppConfigurationParameters(
- CrosstoolConfig.CToolchain toolchain,
CrosstoolConfigurationLoader.CrosstoolFile crosstoolFile,
String cacheKeySuffix,
BuildOptions buildOptions,
@@ -102,8 +101,8 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory {
Label ccToolchainLabel,
Label stlLabel,
Label sysrootLabel,
- CpuTransformer cpuTransformer) {
- this.toolchain = toolchain;
+ CpuTransformer cpuTransformer,
+ CrosstoolInfo crosstoolInfo) {
this.crosstoolFile = crosstoolFile;
this.cacheKeySuffix = cacheKeySuffix;
this.commonOptions = buildOptions.get(BuildConfiguration.Options.class);
@@ -115,6 +114,7 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory {
this.stlLabel = stlLabel;
this.sysrootLabel = sysrootLabel;
this.cpuTransformer = cpuTransformer;
+ this.crosstoolInfo = crosstoolInfo;
}
}
@@ -241,11 +241,19 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory {
: CrosstoolConfigurationLoader.getToolchainByIdentifier(
file.getProto(), identifier, desiredCpu, cppOptions.cppCompiler);
}
+ toolchain =
+ CppToolchainInfo.addLegacyFeatures(
+ toolchain, crosstoolTopLabel.getPackageIdentifier().getPathUnderExecRoot());
+
+ CrosstoolInfo crosstoolInfo =
+ CrosstoolInfo.fromToolchain(
+ file.getProto(),
+ toolchain,
+ crosstoolTopLabel.getPackageIdentifier().getPathUnderExecRoot());
Label sysrootLabel = getSysrootLabel(toolchain, cppOptions.libcTopLabel);
return new CppConfigurationParameters(
- toolchain,
file,
file.getMd5(),
options,
@@ -255,13 +263,15 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory {
ccToolchainLabel,
stlLabel,
sysrootLabel,
- cpuTransformer);
+ cpuTransformer,
+ crosstoolInfo);
}
@Nullable
public static Label getSysrootLabel(CrosstoolConfig.CToolchain toolchain, Label libcTopLabel)
throws InvalidConfigurationException {
- PathFragment defaultSysroot = CppConfiguration.computeDefaultSysroot(toolchain);
+ PathFragment defaultSysroot =
+ CppConfiguration.computeDefaultSysroot(toolchain.getBuiltinSysroot());
if ((libcTopLabel != null) && (defaultSysroot == null)) {
throw new InvalidConfigurationException(