`repository_name()` and `package_name()` are available only in loading phase
RELNOTES: None.
@@ -209,11 +209,14 @@ public class SkylarkNativeModule {
+ "<code>package_name()</code> will match the caller BUILD file package. "
+ "This function is equivalent to the deprecated variable <code>PACKAGE_NAME</code>.",
parameters = {},
+ useAst = true,
useEnvironment = true
)
private static final BuiltinFunction packageName =
new BuiltinFunction("package_name") {
- public String invoke(Environment env) throws EvalException, ConversionException {
+ public String invoke(FuncallExpression ast, Environment env)
+ throws EvalException, ConversionException {
+ env.checkLoadingPhase("native.package_name", ast.getLocation());
return (String) env.lookup("PACKAGE_NAME");
}
};
@@ -229,11 +232,14 @@ public class SkylarkNativeModule {
+ "<code>@local</code>. In packages in the main repository, it will be empty. This "
+ "function is equivalent to the deprecated variable <code>REPOSITORY_NAME</code>.",
parameters = {},
+ useAst = true,
useEnvironment = true
)
private static final BuiltinFunction repositoryName =
new BuiltinFunction("repository_name") {
- public String invoke(Environment env) throws EvalException, ConversionException {
+ public String invoke(FuncallExpression ast, Environment env)
+ throws EvalException, ConversionException {
+ env.checkLoadingPhase("native.package_name", ast.getLocation());
return (String) env.lookup("REPOSITORY_NAME");
}
};
