-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Skymeld] Move the various skymeld flag check to SkymeldModule.
Also print an INFO message that Skymeld is enabled. PiperOrigin-RevId: 520641129 Change-Id: I9d3301a85aba19569c548ad0828c26326fd504da
- Loading branch information
1 parent
03266a8
commit 986ef7b
Showing
9 changed files
with
99 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/com/google/devtools/build/lib/skyframe/SkymeldModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2023 The Bazel Authors. 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.skyframe; | ||
|
||
import com.google.devtools.build.lib.buildtool.BuildRequestOptions; | ||
import com.google.devtools.build.lib.events.Event; | ||
import com.google.devtools.build.lib.pkgcache.PathPackageLocator; | ||
import com.google.devtools.build.lib.runtime.BlazeModule; | ||
import com.google.devtools.build.lib.runtime.CommandEnvironment; | ||
|
||
/** Module to handle various Skymeld checks. */ | ||
public class SkymeldModule extends BlazeModule { | ||
@Override | ||
public void beforeCommand(CommandEnvironment env) { | ||
env.setMergedAnalysisAndExecution(determineIfMergingAnalysisExecution(env)); | ||
} | ||
|
||
boolean determineIfMergingAnalysisExecution(CommandEnvironment env) { | ||
String commandName = env.getCommandName(); | ||
PathPackageLocator packageLocator = env.getPackageLocator(); | ||
BuildRequestOptions buildRequestOptions = | ||
env.getOptions().getOptions(BuildRequestOptions.class); | ||
// --nobuild means no execution will be carried out, hence it doesn't make sense to interleave | ||
// analysis and execution in that case and --experimental_merged_skyframe_analysis_execution | ||
// should be ignored. | ||
// Aquery and Cquery implicitly set --nobuild, so there's no need to have a warning here: it | ||
// makes no different from the users' perspective. | ||
if (buildRequestOptions != null | ||
&& buildRequestOptions.mergedSkyframeAnalysisExecutionDoNotUseDirectly | ||
&& !buildRequestOptions.performExecutionPhase | ||
&& !(commandName.equals("aquery") || commandName.equals("cquery"))) { | ||
env.getReporter() | ||
.handle( | ||
Event.warn( | ||
"--experimental_merged_skyframe_analysis_execution is incompatible with --nobuild" | ||
+ " and will be ignored.")); | ||
} | ||
boolean plainValueFromFlag = getPlainValueFromFlag(buildRequestOptions); | ||
boolean havingMultiPackagePath = | ||
packageLocator != null && packageLocator.getPathEntries().size() > 1; | ||
// TODO(b/246324830): Skymeld and multi-package_path are incompatible. | ||
if (plainValueFromFlag && havingMultiPackagePath) { | ||
env.getReporter() | ||
.handle( | ||
Event.warn( | ||
"--experimental_merged_skyframe_analysis_execution is " | ||
+ "incompatible with multiple --package_path (" | ||
+ packageLocator.getPathEntries() | ||
+ ") and its value will be ignored.")); | ||
} | ||
return plainValueFromFlag | ||
&& buildRequestOptions.performExecutionPhase | ||
&& !havingMultiPackagePath; | ||
} | ||
|
||
static boolean getPlainValueFromFlag(BuildRequestOptions buildRequestOptions) { | ||
return buildRequestOptions != null | ||
&& buildRequestOptions.mergedSkyframeAnalysisExecutionDoNotUseDirectly; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters