aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
diff options
context:
space:
mode:
authorGravatar brandjon <brandjon@google.com>2017-04-29 16:03:32 +0200
committerGravatar Vladimir Moskva <vladmos@google.com>2017-04-30 23:14:25 +0200
commitb712f335a945c81a6b77fd48e96103ff09c8967b (patch)
treeb8ac0e5aa200cf19717aa22e51cb9abc457be572 /src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
parente7fe50aa727df9ef0a3d37fa258d017971035515 (diff)
Make Skylark interpreter read Skylark command-line flags
This is the second of two CLs for making command line options able to affect the Skylark interpreter. For the main kinds of evaluation contexts -- package loading, .bzl loading, rule analysis, aspect analysis, and computed defaults -- the SkylarkSemanticsOptions object is retrieved from Skyframe and passed along to the Environment builder. For other contexts such as tests, default values of builtin functions, and standalone Skylark, flags are currently not processed. In the future, we may want to split into separate files the options that affect "pure" Skylark vs the options that affect Bazel-flavored Skylark. One possibility is to subclass SkylarkSemanticsOptions into SkylarkBazelSemanticsOptions, and go through an indirection in SkylarkUtils. We could also pass SkylarkSemanticsOptions to the parser, to support --incompatible_* changes that alter Skylark's syntax. I don't think that's needed at the moment. RELNOTES: None PiperOrigin-RevId: 154628391
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
index 0b7afce7b6..00da7e78da 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
@@ -50,6 +50,7 @@ import com.google.devtools.build.lib.syntax.Environment.Extension;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.ParserInputSource;
import com.google.devtools.build.lib.syntax.SkylarkImport;
+import com.google.devtools.build.lib.syntax.SkylarkSemanticsOptions;
import com.google.devtools.build.lib.syntax.Statement;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.util.Preconditions;
@@ -482,6 +483,11 @@ public class PackageFunction implements SkyFunction {
return null;
}
+ SkylarkSemanticsOptions skylarkSemantics = PrecomputedValue.SKYLARK_SEMANTICS.get(env);
+ if (skylarkSemantics == null) {
+ return null;
+ }
+
SkyKey astLookupKey = ASTFileLookupValue.key(preludeLabel);
ASTFileLookupValue astLookupValue = null;
try {
@@ -508,6 +514,7 @@ public class PackageFunction implements SkyFunction {
buildFilePath,
buildFileValue,
defaultVisibility,
+ skylarkSemantics,
preludeStatements,
packageLookupValue.getRoot(),
env);
@@ -1113,6 +1120,7 @@ public class PackageFunction implements SkyFunction {
Path buildFilePath,
@Nullable FileValue buildFileValue,
RuleVisibility defaultVisibility,
+ SkylarkSemanticsOptions skylarkSemantics,
List<Statement> preludeStatements,
Path packageRoot,
Environment env)
@@ -1206,8 +1214,15 @@ public class PackageFunction implements SkyFunction {
SkyframeHybridGlobber skyframeGlobber = new SkyframeHybridGlobber(packageId, packageRoot,
env, legacyGlobber);
Package.Builder pkgBuilder = packageFactory.createPackageFromPreprocessingAst(
- workspaceName, packageId, buildFilePath, astAfterPreprocessing, importResult.importMap,
- importResult.fileDependencies, defaultVisibility, skyframeGlobber);
+ workspaceName,
+ packageId,
+ buildFilePath,
+ astAfterPreprocessing,
+ importResult.importMap,
+ importResult.fileDependencies,
+ defaultVisibility,
+ skylarkSemantics,
+ skyframeGlobber);
Set<SkyKey> globDepsRequested = ImmutableSet.<SkyKey>builder()
.addAll(globDepsRequestedDuringPreprocessing)
.addAll(skyframeGlobber.getGlobDepsRequested())