diff options
author | 2015-09-16 10:08:55 +0000 | |
---|---|---|
committer | 2015-09-16 10:19:24 +0000 | |
commit | 50a705c9f21706953514a21a16a7079090ce048d (patch) | |
tree | 44deec3be0f4d43249d7f455a1da101445934b8c /src/main | |
parent | 86bd4fdc16e0e71504dfe0428c188fdb9efab77f (diff) |
Remove a few minor lib.syntax -> lib.packages dependencies.
We want to move Skylark as down on the dependency graph as possible. The immediate motivation is to move Label to the lib.cmdline package, but this is a good idea nevertheless.
--
MOS_MIGRATED_REVID=103178549
Diffstat (limited to 'src/main')
4 files changed, 40 insertions, 61 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java index 83067b7fbf..eea6b03e35 100644 --- a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java @@ -14,11 +14,14 @@ package com.google.devtools.build.lib.pkgcache; +import com.google.common.base.Splitter; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.Constants; +import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.packages.ConstantRuleVisibility; import com.google.devtools.build.lib.packages.RuleVisibility; -import com.google.devtools.build.lib.syntax.CommaSeparatedPackageNameListConverter; import com.google.devtools.common.options.Converter; import com.google.devtools.common.options.Converters; import com.google.devtools.common.options.Option; @@ -152,4 +155,35 @@ public class PackageCacheOptions extends OptionsBase { category = "undocumented", help = "Allows the command to fetch external dependencies") public boolean fetch; + + /** + * A converter from strings containing comma-separated names of packages to lists of strings. + */ + public static class CommaSeparatedPackageNameListConverter + implements Converter<List<PackageIdentifier>> { + + private static final Splitter COMMA_SPLITTER = Splitter.on(','); + + @Override + public List<PackageIdentifier> convert(String input) throws OptionsParsingException { + if (Strings.isNullOrEmpty(input)) { + return ImmutableList.of(); + } + ImmutableList.Builder<PackageIdentifier> list = ImmutableList.builder(); + for (String s : COMMA_SPLITTER.split(input)) { + try { + list.add(PackageIdentifier.parse(s)); + } catch (LabelSyntaxException e) { + throw new OptionsParsingException(e.getMessage()); + } + } + return list.build(); + } + + @Override + public String getTypeDescription() { + return "comma-separated list of package names"; + } + + } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java index f2bb02c8dc..f9fd58f031 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java @@ -99,7 +99,9 @@ public final class SkylarkRuleConfiguredTargetBuilder { */ private static void addRuleToStackTrace(EvalException ex, Rule rule, BaseFunction ruleImpl) { if (ex instanceof EvalExceptionWithStackTrace) { - ((EvalExceptionWithStackTrace) ex).registerRule(rule, ruleImpl); + ((EvalExceptionWithStackTrace) ex).registerRule( + String.format("%s(name = '%s')", rule.getRuleClass(), rule.getName()), + rule.getLocation(), ruleImpl); } } diff --git a/src/main/java/com/google/devtools/build/lib/syntax/CommaSeparatedPackageNameListConverter.java b/src/main/java/com/google/devtools/build/lib/syntax/CommaSeparatedPackageNameListConverter.java deleted file mode 100644 index 78faf36e30..0000000000 --- a/src/main/java/com/google/devtools/build/lib/syntax/CommaSeparatedPackageNameListConverter.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package com.google.devtools.build.lib.syntax; - -import com.google.common.base.Splitter; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableList; -import com.google.devtools.build.lib.cmdline.LabelSyntaxException; -import com.google.devtools.build.lib.cmdline.PackageIdentifier; -import com.google.devtools.common.options.Converter; -import com.google.devtools.common.options.OptionsParsingException; - -import java.util.List; - -/** - * A converter from strings containing comma-separated names of packages to lists of strings. - */ -public class CommaSeparatedPackageNameListConverter - implements Converter<List<PackageIdentifier>> { - - private static final Splitter SPACE_SPLITTER = Splitter.on(','); - - @Override - public List<PackageIdentifier> convert(String input) throws OptionsParsingException { - if (Strings.isNullOrEmpty(input)) { - return ImmutableList.of(); - } - ImmutableList.Builder<PackageIdentifier> list = ImmutableList.builder(); - for (String s : SPACE_SPLITTER.split(input)) { - try { - list.add(PackageIdentifier.parse(s)); - } catch (LabelSyntaxException e) { - throw new OptionsParsingException(e.getMessage()); - } - } - return list.build(); - } - - @Override - public String getTypeDescription() { - return "comma-separated list of package names"; - } - -} diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java index 9ec686035f..bf25d702f0 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java @@ -16,7 +16,6 @@ package com.google.devtools.build.lib.syntax; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.devtools.build.lib.events.Location; -import com.google.devtools.build.lib.packages.Rule; import java.util.Deque; import java.util.LinkedList; @@ -74,7 +73,7 @@ public class EvalExceptionWithStackTrace extends EvalException { /** * Adds the given {@code Rule} to the stack trace. */ - public void registerRule(Rule rule, BaseFunction ruleImpl) { + public void registerRule(String rule, Location location, BaseFunction ruleImpl) { /* We have to model the transition from BUILD file to bzl file manually since the stack trace * mechanism cannot do that by itself (because, for example, the rule implementation does not * have a corresponding FuncallExpression). @@ -105,8 +104,7 @@ public class EvalExceptionWithStackTrace extends EvalException { * * */ addStackFrame(ruleImpl.getName(), ruleImpl.getLocation()); - addStackFrame(String.format("%s(name = '%s')", rule.getRuleClass(), rule.getName()), - rule.getLocation(), false); + addStackFrame(rule, location, false); } /** |