diff options
author | janakr <janakr@google.com> | 2018-02-14 11:55:24 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-14 11:57:22 -0800 |
commit | d65be8ca28d5cea63144cb9b67104c7f69df64b7 (patch) | |
tree | 9cf93c8983e37d0e72e4c1c3e5814ffed177ea8a /src/main/java | |
parent | addb86cce7389e6734ee4b7dbd01232441aae552 (diff) |
Get rid of unnecessary target retrieval in ToolchainUtil: the label will do just as well as the target.
PiperOrigin-RevId: 185721605
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java index abc002ac57..de14ac60fe 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java @@ -26,8 +26,6 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils; import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.packages.NoSuchTargetException; -import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.ConfiguredValueCreationException; import com.google.devtools.build.lib.skyframe.RegisteredToolchainsFunction.InvalidToolchainLabelException; import com.google.devtools.build.lib.skyframe.ToolchainResolutionFunction.NoToolchainFoundException; @@ -118,9 +116,7 @@ public class ToolchainUtil { */ @Nullable private static PlatformInfo findPlatformInfo( - ValueOrException<ConfiguredValueCreationException> valueOrException, - String platformType, - Environment env) + ValueOrException<ConfiguredValueCreationException> valueOrException, String platformType) throws ConfiguredValueCreationException, ToolchainContextException { ConfiguredTargetValue ctv = (ConfiguredTargetValue) valueOrException.get(); @@ -129,20 +125,10 @@ public class ToolchainUtil { } ConfiguredTarget configuredTarget = ctv.getConfiguredTarget(); - Target target = null; - try { - target = - ((PackageValue) - env.getValue( - PackageValue.key(configuredTarget.getLabel().getPackageIdentifier()))) - .getPackage() - .getTarget(configuredTarget.getLabel().getName()); - } catch (NoSuchTargetException | InterruptedException e) { - throw new IllegalStateException("Unable to get Target when computing PlatformInfo.", e); - } PlatformInfo platformInfo = PlatformProviderUtils.platform(configuredTarget); if (platformInfo == null) { - throw new ToolchainContextException(new InvalidPlatformException(platformType, target)); + throw new ToolchainContextException( + new InvalidPlatformException(platformType, configuredTarget.getLabel())); } return platformInfo; @@ -169,10 +155,9 @@ public class ToolchainUtil { ConfiguredValueCreationException.class); boolean valuesMissing = env.valuesMissing(); try { - PlatformInfo hostPlatform = - findPlatformInfo(values.get(hostPlatformKey), "host platform", env); + PlatformInfo hostPlatform = findPlatformInfo(values.get(hostPlatformKey), "host platform"); PlatformInfo targetPlatform = - findPlatformInfo(values.get(targetPlatformKey), "target platform", env); + findPlatformInfo(values.get(targetPlatformKey), "target platform"); if (valuesMissing) { return null; @@ -275,12 +260,12 @@ public class ToolchainUtil { } /** Exception used when a platform label is not a valid platform. */ - public static final class InvalidPlatformException extends Exception { - public InvalidPlatformException(String platformType, Target target) { + static final class InvalidPlatformException extends Exception { + InvalidPlatformException(String platformType, Label label) { super( String.format( "Target %s was found as the %s, but does not provide PlatformInfo", - target, platformType)); + label, platformType)); } } |