diff options
author | 2017-10-24 22:22:14 +0200 | |
---|---|---|
committer | 2017-10-25 16:46:09 +0200 | |
commit | d73bcf81d367ee998b64661bbb63b2419f3b04d1 (patch) | |
tree | 432d32dd840cf4700d83b07c0f5dba2a34107ab5 /src/main/java/com/google/devtools/build/lib/rules | |
parent | a6ee57af0f43c407b4089cb4f5075498eee29f7b (diff) |
Move CppConfiguration#getStaticRuntimeLibsLabel and #getDynamicRuntimeLibsLabel
to CcToolchainProvider.
PiperOrigin-RevId: 173301847
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
3 files changed, 46 insertions, 45 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java index 230220b0bd..5f9e3d2458 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java @@ -228,6 +228,31 @@ public class CcToolchain implements RuleConfiguredTargetFactory { CppConfiguration cppConfiguration = Preconditions.checkNotNull(ruleContext.getFragment(CppConfiguration.class)); + PlatformConfiguration platformConfig = + Preconditions.checkNotNull(ruleContext.getFragment(PlatformConfiguration.class)); + + CToolchain toolchain = null; + if (platformConfig + .getEnabledToolchainTypes() + .contains(CppHelper.getToolchainTypeFromRuleClass(ruleContext))) { + toolchain = getToolchainFromAttributes(ruleContext, cppConfiguration); + } + + CppToolchainInfo toolchainInfo = null; + if (toolchain != null) { + try { + toolchainInfo = + new CppToolchainInfo( + toolchain, + cppConfiguration.getCrosstoolTopPathFragment(), + cppConfiguration.getCcToolchainRuleLabel()); + } catch (InvalidConfigurationException e) { + ruleContext.throwWithRuleError(e.getMessage()); + } + } else { + toolchainInfo = cppConfiguration.getCppToolchainInfo(); + } + Path fdoZip = ruleContext.getConfiguration().getCompilationMode() == CompilationMode.OPT ? cppConfiguration.getFdoZip() : null; @@ -269,7 +294,7 @@ public class CcToolchain implements RuleConfiguredTargetFactory { // Static runtime inputs. TransitiveInfoCollection staticRuntimeLibDep = selectDep(ruleContext, "static_runtime_libs", - cppConfiguration.getStaticRuntimeLibsLabel()); + toolchainInfo.getStaticRuntimeLibsLabel()); final NestedSet<Artifact> staticRuntimeLinkInputs; final Artifact staticRuntimeLinkMiddleman; if (cppConfiguration.supportsEmbeddedRuntimes()) { @@ -296,7 +321,7 @@ public class CcToolchain implements RuleConfiguredTargetFactory { // Dynamic runtime inputs. TransitiveInfoCollection dynamicRuntimeLibDep = selectDep(ruleContext, "dynamic_runtime_libs", - cppConfiguration.getDynamicRuntimeLibsLabel()); + toolchainInfo.getDynamicRuntimeLibsLabel()); NestedSet<Artifact> dynamicRuntimeLinkSymlinks; List<Artifact> dynamicRuntimeLinkInputs = new ArrayList<>(); Artifact dynamicRuntimeLinkMiddleman; @@ -360,31 +385,6 @@ public class CcToolchain implements RuleConfiguredTargetFactory { ruleContext.ruleError(e.getMessage()); } - PlatformConfiguration platformConfig = - Preconditions.checkNotNull(ruleContext.getFragment(PlatformConfiguration.class)); - - CToolchain toolchain = null; - if (platformConfig - .getEnabledToolchainTypes() - .contains(CppHelper.getToolchainTypeFromRuleClass(ruleContext))) { - toolchain = getToolchainFromAttributes(ruleContext, cppConfiguration); - } - - CppToolchainInfo toolchainInfo = null; - if (toolchain != null) { - try { - toolchainInfo = - new CppToolchainInfo( - toolchain, - cppConfiguration.getCrosstoolTopPathFragment(), - cppConfiguration.getCcToolchainRuleLabel()); - } catch (InvalidConfigurationException e) { - ruleContext.throwWithRuleError(e.getMessage()); - } - } else { - toolchainInfo = cppConfiguration.getCppToolchainInfo(); - } - coverageEnvironment.add( Pair.of( "COVERAGE_GCOV_PATH", toolchainInfo.getToolPathFragment(Tool.GCOV).getPathString())); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java index 097d4674eb..4f9e5ea490 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.config.CompilationMode; import com.google.devtools.build.lib.analysis.platform.ToolchainInfo; +import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; @@ -403,6 +404,24 @@ public final class CcToolchainProvider extends ToolchainInfo { return toolchainInfo.getAbiGlibcVersion(); } + /** + * Returns a label that references the library files needed to statically + * link the C++ runtime (i.e. libgcc.a, libgcc_eh.a, libstdc++.a) for the + * target architecture. + */ + public Label getStaticRuntimeLibsLabel() { + return toolchainInfo.getStaticRuntimeLibsLabel(); + } + + /** + * Returns a label that references the library files needed to dynamically + * link the C++ runtime (i.e. libgcc_s.so, libstdc++.so) for the target + * architecture. + */ + public Label getDynamicRuntimeLibsLabel() { + return toolchainInfo.getDynamicRuntimeLibsLabel(); + } + @SkylarkCallable( name = "unfiltered_compiler_options_do_not_use", doc = diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index 306e456805..7e87ca3f6c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -605,24 +605,6 @@ public class CppConfiguration extends BuildConfiguration.Fragment { } /** - * Returns a label that references the library files needed to statically - * link the C++ runtime (i.e. libgcc.a, libgcc_eh.a, libstdc++.a) for the - * target architecture. - */ - public Label getStaticRuntimeLibsLabel() { - return cppToolchainInfo.getStaticRuntimeLibsLabel(); - } - - /** - * Returns a label that references the library files needed to dynamically - * link the C++ runtime (i.e. libgcc_s.so, libstdc++.so) for the target - * architecture. - */ - public Label getDynamicRuntimeLibsLabel() { - return cppToolchainInfo.getDynamicRuntimeLibsLabel(); - } - - /** * Returns the label of the <code>cc_compiler</code> rule for the C++ configuration. */ public Label getCcToolchainRuleLabel() { |