From 304f5cbfac3c8cc272a0c43d3077a4cff0e1cc5a Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Tue, 6 Sep 2016 14:51:11 +0000 Subject: Move bin_dir/genfiles_dir to RuleContext This is so that the repository name can be included in the root. To avoid breaking Bazel's CI which tests the HEAD code against the latest release, none of the Skylark rules in Bazel can be updated to use ctx.{bin,genfiles}_dir yet, we will have to wait for the 0.3.2 release to actually update the call sites. However, this change is to effectively deprecate ctx.configuration.{bin,genfiles}_dir: it undocuments them and I will announce the change on the list. RELNOTES[INC]: bin_dir and genfiles_dir are now properties of ctx, not configuration. That is, to access the bin or genfiles directory from a Skylark rule, use ctx.bin_dir or ctx.genfiles_dir (not ctx.configuration.{bin,genfiles}_dir). At the moment, you can access {bin,genfiles}_dir from either, but the ctx.configuration version will stop working in a future release. -- MOS_MIGRATED_REVID=132319900 --- .../devtools/build/lib/analysis/RuleContext.java | 23 +++++++++++++++++++--- .../lib/analysis/config/BuildConfiguration.java | 8 ++++---- 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index f74ec75055..14de806ac6 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -75,6 +75,7 @@ import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.rules.AliasProvider; import com.google.devtools.build.lib.rules.fileset.FilesetProvider; import com.google.devtools.build.lib.shell.ShellUtils; +import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.FileTypeSet; @@ -519,9 +520,25 @@ public final class RuleContext extends TargetContext * which this target (which must be an OutputFile or a Rule) is associated. */ public Root getBinOrGenfilesDirectory() { - return rule.hasBinaryOutput() - ? getConfiguration().getBinDirectory(rule.getRepository()) - : getConfiguration().getGenfilesDirectory(rule.getRepository()); + return rule.hasBinaryOutput() ? getBinDirectory() : getGenfilesDirectory(); + } + + /** + * Returns the bin directory for this build configuration. + */ + @SkylarkCallable(name = "bin_dir", structField = true, + doc = "The root corresponding to bin directory.") + public Root getBinDirectory() { + return getConfiguration().getBinDirectory(rule.getRepository()); + } + + /** + * Returns the genfiles directory for this build configuration. + */ + @SkylarkCallable(name = "genfiles_dir", structField = true, + doc = "The root corresponding to genfiles directory.") + public Root getGenfilesDirectory() { + return getConfiguration().getGenfilesDirectory(rule.getRepository()); } /** diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java index 05327fdb6c..96823d1849 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java @@ -1926,8 +1926,8 @@ public final class BuildConfiguration { /** * Returns the bin directory for this build configuration. */ - @SkylarkCallable(name = "bin_dir", structField = true, - doc = "The root corresponding to bin directory.") + @SkylarkCallable(name = "bin_dir", structField = true, documented = false) + @Deprecated public Root getBinDirectory() { return outputRoots.binDirectory; } @@ -1963,8 +1963,8 @@ public final class BuildConfiguration { /** * Returns the genfiles directory for this build configuration. */ - @SkylarkCallable(name = "genfiles_dir", structField = true, - doc = "The root corresponding to genfiles directory.") + @SkylarkCallable(name = "genfiles_dir", structField = true, documented = false) + @Deprecated public Root getGenfilesDirectory() { return outputRoots.genfilesDirectory; } -- cgit v1.2.3