From 7ed66f7a31bf5c174f05c295c07fe90cc2aaf2b9 Mon Sep 17 00:00:00 2001 From: nharmata Date: Fri, 2 Aug 2019 09:50:06 -0700 Subject: [PATCH] Automated rollback of commit 956940755a19823b2b12b91ef7f9d9dddc5424cb. PiperOrigin-RevId: 261338193 --- .../analysis/ResolvedToolchainContext.java | 15 +-- .../skylark/SkylarkRuleClassFunctions.java | 31 ++---- .../devtools/build/lib/packages/Package.java | 2 +- .../build/lib/packages/WorkspaceGlobals.java | 36 ++---- src/test/shell/bazel/workspace_test.sh | 105 ------------------ 5 files changed, 19 insertions(+), 170 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ResolvedToolchainContext.java b/src/main/java/com/google/devtools/build/lib/analysis/ResolvedToolchainContext.java index 63e30d9e3982fc..9ecc4106d3094f 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ResolvedToolchainContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/ResolvedToolchainContext.java @@ -24,10 +24,8 @@ import com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils; import com.google.devtools.build.lib.analysis.platform.ToolchainInfo; import com.google.devtools.build.lib.analysis.platform.ToolchainTypeInfo; -import com.google.devtools.build.lib.analysis.skylark.BazelStarlarkContext; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; -import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; import com.google.devtools.build.lib.events.Location; @@ -191,8 +189,7 @@ public void repr(SkylarkPrinter printer) { printer.append(">"); } - private static Label transformKey(Object key, Location loc, StarlarkContext context) - throws EvalException { + private Label transformKey(Object key, Location loc) throws EvalException { if (key instanceof Label) { return (Label) key; } else if (key instanceof ToolchainTypeInfo) { @@ -200,12 +197,8 @@ private static Label transformKey(Object key, Location loc, StarlarkContext cont } else if (key instanceof String) { Label toolchainType; String rawLabel = (String) key; - ImmutableMap repoMapping = ImmutableMap.of(); - if (context instanceof BazelStarlarkContext) { - repoMapping = ((BazelStarlarkContext) context).getRepoMapping(); - } try { - toolchainType = Label.parseAbsolute(rawLabel, repoMapping); + toolchainType = Label.parseAbsolute(rawLabel, ImmutableMap.of()); } catch (LabelSyntaxException e) { throw new EvalException( loc, String.format("Unable to parse toolchain %s: %s", rawLabel, e.getMessage()), e); @@ -223,7 +216,7 @@ private static Label transformKey(Object key, Location loc, StarlarkContext cont @Override public ToolchainInfo getIndex(Object key, Location loc, StarlarkContext context) throws EvalException { - Label toolchainTypeLabel = transformKey(key, loc, context); + Label toolchainTypeLabel = transformKey(key, loc); if (!containsKey(key, loc, context)) { // TODO(bazel-configurability): The list of available toolchain types is confusing in the @@ -246,7 +239,7 @@ public ToolchainInfo getIndex(Object key, Location loc, StarlarkContext context) @Override public boolean containsKey(Object key, Location loc, StarlarkContext context) throws EvalException { - Label toolchainTypeLabel = transformKey(key, loc, context); + Label toolchainTypeLabel = transformKey(key, loc); return requestedToolchainTypeLabels().containsKey(toolchainTypeLabel); } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java index 2e384a73e076e3..2737aa2f4496f1 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java @@ -43,7 +43,6 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.LabelValidator; -import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.AttributeMap; @@ -355,14 +354,9 @@ public BaseFunction rule( builder.setConfiguredTargetFunction(implementation); builder.setRuleDefinitionEnvironmentLabelAndHashCode( funcallEnv.getGlobals().getLabel(), funcallEnv.getTransitiveContentHashCode()); - - ImmutableMap repoMapping = ImmutableMap.of(); - if (context instanceof BazelStarlarkContext) { - repoMapping = ((BazelStarlarkContext) context).getRepoMapping(); - } builder.addRequiredToolchains( collectToolchainLabels( - toolchains.getContents(String.class, "toolchains"), ast.getLocation(), repoMapping)); + toolchains.getContents(String.class, "toolchains"), ast.getLocation())); if (!buildSetting.equals(Runtime.NONE) && !cfg.equals(Runtime.NONE)) { throw new EvalException( @@ -403,8 +397,7 @@ public BaseFunction rule( builder.addExecutionPlatformConstraints( collectConstraintLabels( execCompatibleWith.getContents(String.class, "exec_compatile_with"), - ast.getLocation(), - repoMapping)); + ast.getLocation())); } if (executionPlatformConstraintsAllowed) { @@ -455,14 +448,11 @@ private static void addAttribute( } private static ImmutableList