diff options
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.java | 44 |
1 files changed, 9 insertions, 35 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 b334b10923..9a98181724 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 @@ -36,11 +36,10 @@ import com.google.devtools.build.lib.packages.NoSuchThingException; import com.google.devtools.build.lib.packages.NonconfigurableAttributeMapper; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.Target; +import com.google.devtools.build.lib.rules.cpp.CppConfiguration.LibcTop; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; -import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig; -import com.google.devtools.common.options.OptionsParsingException; import javax.annotation.Nullable; /** @@ -90,7 +89,7 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory { protected final Label ccToolchainLabel; protected final Label stlLabel; protected final Path fdoZip; - protected final Label sysrootLabel; + protected final LibcTop libcTop; CppConfigurationParameters( CrosstoolConfig.CToolchain toolchain, @@ -100,7 +99,7 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory { Label crosstoolTop, Label ccToolchainLabel, Label stlLabel, - Label sysrootLabel) { + LibcTop libcTop) { this.toolchain = toolchain; this.cacheKeySuffix = cacheKeySuffix; this.commonOptions = buildOptions.get(BuildConfiguration.Options.class); @@ -109,7 +108,7 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory { this.crosstoolTop = crosstoolTop; this.ccToolchainLabel = ccToolchainLabel; this.stlLabel = stlLabel; - this.sysrootLabel = sysrootLabel; + this.libcTop = libcTop; } } @@ -220,7 +219,10 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory { "The label '%s' is not a cc_toolchain rule", ccToolchainLabel)); } - Label sysrootLabel = getSysrootLabel(toolchain, cppOptions.libcTopLabel); + LibcTop.Result libcTopResult = LibcTop.createLibcTop(cppOptions, env, toolchain); + if (libcTopResult.valuesMissing()) { + return null; + } return new CppConfigurationParameters( toolchain, @@ -230,34 +232,6 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory { crosstoolTopLabel, ccToolchainLabel, stlLabel, - sysrootLabel); - } - - @Nullable - public static Label getSysrootLabel(CrosstoolConfig.CToolchain toolchain, Label libcTopLabel) - throws InvalidConfigurationException { - PathFragment defaultSysroot = CppConfiguration.computeDefaultSysroot(toolchain); - - if ((libcTopLabel != null) && (defaultSysroot == null)) { - throw new InvalidConfigurationException( - "The selected toolchain " - + toolchain.getToolchainIdentifier() - + " does not support setting --grte_top."); - } - - if (libcTopLabel != null) { - return libcTopLabel; - } - - if (!toolchain.getDefaultGrteTop().isEmpty()) { - try { - Label grteTopLabel = - new CppOptions.LibcTopLabelConverter().convert(toolchain.getDefaultGrteTop()); - return grteTopLabel; - } catch (OptionsParsingException e) { - throw new InvalidConfigurationException(e.getMessage(), e); - } - } - return null; + libcTopResult.getLibcTop()); } } |