bazel packages: decentralize StarlarkSemantics
Prior to this change, StarlarkSemantics was a closed set of options,
which meant that it had to enumerate all the optional key/value features
of its client, Bazel. (This of course makes no sense for other clients
such as Copybara.)
This change turns it into an open and extensible set of key/value pairs.
All the Bazel semantics option have been moved to packages.semantics.BuildLanguageOptions.
This removes the last logical dependency of Starlark on Bazel.
Also:
- fix a few places where the old FlagIdentifier names were inconsistent
with the actual flag name.
- add a static check that boolean semantics options have a name that
starts with + or - (to specify the default value).
PiperOrigin-RevId: 330379130
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java
index dd5cbb2..e283291 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java
@@ -39,6 +39,7 @@
import com.google.devtools.build.lib.packages.PackageFactory;
import com.google.devtools.build.lib.packages.StarlarkExportable;
import com.google.devtools.build.lib.packages.WorkspaceFileValue;
+import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import com.google.devtools.build.lib.skyframe.ASTFileLookupFunction.ASTLookupFailedException;
import com.google.devtools.build.lib.skyframe.StarlarkBuiltinsFunction.BuiltinsFailedException;
import com.google.devtools.build.lib.syntax.EvalException;
@@ -851,7 +852,7 @@
throws BzlLoadFailedException, InterruptedException {
if (key instanceof BzlLoadValue.KeyForBuild) {
// TODO(#11437): Remove ability to disable injection by setting flag to empty string.
- if (starlarkSemantics.experimentalBuiltinsBzlPath().isEmpty()) {
+ if (starlarkSemantics.get(BuildLanguageOptions.EXPERIMENTAL_BUILTINS_BZL_PATH).isEmpty()) {
return packageFactory.getUninjectedBuildBzlEnv();
}
StarlarkBuiltinsValue starlarkBuiltinsValue;