本文整理汇总了Java中com.google.devtools.build.lib.events.EventHandler.handle方法的典型用法代码示例。如果您正苦于以下问题:Java EventHandler.handle方法的具体用法?Java EventHandler.handle怎么用?Java EventHandler.handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.devtools.build.lib.events.EventHandler
的用法示例。
在下文中一共展示了EventHandler.handle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCorrectedApiLevel
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* Translates the given API level to the equivalent API level in the NDK.
*/
private String getCorrectedApiLevel(
EventHandler eventHandler, String repositoryName, String apiLevel) {
String correctedApiLevel = apiEquivalencies.get(apiLevel);
if (correctedApiLevel == null) {
// The user specified an API level we don't know about. Default to the most recent API level.
// This relies on the entries being added in sorted order.
String latestApiLevel = Iterables.getLast(apiEquivalencies.keySet());
correctedApiLevel = apiEquivalencies.get(latestApiLevel);
eventHandler.handle(Event.warn(String.format(
"API level %s specified by android_ndk_repository '%s' is not available. "
+ "Using latest known API level %s",
apiLevel, repositoryName, latestApiLevel)));
}
return correctedApiLevel;
}
示例2: maybeReportErrorAboutMissingEdge
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
private static void maybeReportErrorAboutMissingEdge(
Target target, Label depLabel, NoSuchThingException e, EventHandler eventHandler)
throws InterruptedException {
if (e instanceof NoSuchTargetException) {
NoSuchTargetException nste = (NoSuchTargetException) e;
if (depLabel.equals(nste.getLabel())) {
eventHandler.handle(
Event.error(
TargetUtils.getLocationMaybe(target),
TargetUtils.formatMissingEdge(target, depLabel, e)));
}
} else if (e instanceof NoSuchPackageException) {
NoSuchPackageException nspe = (NoSuchPackageException) e;
if (nspe.getPackageId().equals(depLabel.getPackageIdentifier())) {
eventHandler.handle(
Event.error(
TargetUtils.getLocationMaybe(target),
TargetUtils.formatMissingEdge(target, depLabel, e)));
}
}
}
示例3: execTopLevelStatement
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* Executes tol-level statement of this build file in a given Environment.
*
* <p>If, for any reason, execution of a statement cannot be completed, an {@link EvalException}
* is thrown by {@link Eval#exec(Statement)}. This exception is caught here and reported
* through reporter. In effect, there is a
* "try/except" block around every top level statement. Such exceptions are not ignored, though:
* they are visible via the return value. Rules declared in a package containing any error
* (including loading-phase semantical errors that cannot be checked here) must also be considered
* "in error".
*
* <p>Note that this method will not affect the value of {@link #containsErrors()}; that refers
* only to lexer/parser errors.
*
* @return true if no error occurred during execution.
*/
public boolean execTopLevelStatement(Statement stmt, Environment env,
EventHandler eventHandler) throws InterruptedException {
try {
new Eval(env).exec(stmt);
return true;
} catch (EvalException e) {
// Do not report errors caused by a previous parsing error, as it has already been
// reported.
if (e.isDueToIncompleteAST()) {
return false;
}
// When the exception is raised from another file, report first the location in the
// BUILD file (as it is the most probable cause for the error).
Location exnLoc = e.getLocation();
Location nodeLoc = stmt.getLocation();
eventHandler.handle(Event.error(
(exnLoc == null || !nodeLoc.getPath().equals(exnLoc.getPath())) ? nodeLoc : exnLoc,
e.getMessage()));
return false;
}
}
示例4: shutdownHelperPool
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
public static void shutdownHelperPool(EventHandler reporter, ExecutorService pool,
String name) {
pool.shutdownNow();
boolean interrupted = false;
while (true) {
try {
if (!pool.awaitTermination(10, TimeUnit.SECONDS)) {
reporter.handle(Event.warn(name + " threadpool shutdown took greater than ten seconds"));
}
break;
} catch (InterruptedException e) {
interrupted = true;
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
}
示例5: getExpansion
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
private List<String> getExpansion(
EventHandler eventHandler,
ListMultimap<String, RcChunkOfArgs> commandToRcArgs,
String configToExpand)
throws OptionsParsingException {
LinkedHashSet<String> configAncestorSet = new LinkedHashSet<>();
configAncestorSet.add(configToExpand);
List<String> longestChain = new ArrayList<>();
List<String> finalExpansion =
getExpansion(
eventHandler, commandToRcArgs, configAncestorSet, configToExpand, longestChain);
// In order to prevent warning about a long chain of 13 configs at the 10, 11, 12, and 13
// point, we identify the longest chain for this 'high-level' --config found and only warn
// about it once. This may mean we missed a fork where each branch was independently long
// enough to warn, but the single warning should convey the message reasonably.
if (longestChain.size() >= 10) {
eventHandler.handle(
Event.warn(
String.format(
"There is a recursive chain of configs %s configs long: %s. This seems "
+ "excessive, and might be hiding errors.",
longestChain.size(), longestChain)));
}
return finalExpansion;
}
示例6: removeOutputDirectoryLinks
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* Attempts to remove the convenience symlinks in the workspace directory.
*
* <p>Issues a warning if it fails, e.g. because workspaceDirectory is readonly.
* Also cleans up any child directories created by a custom prefix.
*
* @param workspace the runtime's workspace
* @param eventHandler the error eventHandler
* @param symlinkPrefix the symlink prefix which should be removed
* @param productName the product name
*/
public static void removeOutputDirectoryLinks(String workspaceName, Path workspace,
EventHandler eventHandler, String symlinkPrefix, String productName) {
if (NO_CREATE_SYMLINKS_PREFIX.equals(symlinkPrefix)) {
return;
}
List<String> failures = new ArrayList<>();
for (String outputSymlinkName : getOutputSymlinkNames(productName, symlinkPrefix)) {
removeLink(workspace, outputSymlinkName, failures);
}
removeLink(workspace, execRootSymlink(symlinkPrefix, workspaceName), failures);
removeLink(workspace, execRootSymlink(symlinkPrefix, workspace.getBaseName()), failures);
removeLink(workspace, symlinkPrefix + "bin", failures);
removeLink(workspace, symlinkPrefix + "testlogs", failures);
removeLink(workspace, symlinkPrefix + "genfiles", failures);
FileSystemUtils.removeDirectoryAndParents(workspace, PathFragment.create(symlinkPrefix));
if (!failures.isEmpty()) {
eventHandler.handle(Event.warn(String.format(
"failed to remove one or more convenience symlinks for prefix '%s':\n %s", symlinkPrefix,
Joiner.on("\n ").join(failures))));
}
}
示例7: checkInputsForDirectories
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* If the action might read directories as inputs in a way that is unsound wrt dependency
* checking, this method must be called.
*/
protected void checkInputsForDirectories(
EventHandler eventHandler, MetadataProvider metadataProvider) throws ExecException {
// Report "directory dependency checking" warning only for non-generated directories (generated
// ones will be reported earlier).
for (Artifact input : getMandatoryInputs()) {
// Assume that if the file did not exist, we would not have gotten here.
try {
if (input.isSourceArtifact()
&& metadataProvider.getMetadata(input).getType().isDirectory()) {
// TODO(ulfjack): What about dependency checking of special files?
eventHandler.handle(Event.warn(getOwner().getLocation(),
String.format(
"input '%s' to %s is a directory; dependency checking of directories is unsound",
input.prettyPrint(), getOwner().getLabel())));
}
} catch (IOException e) {
throw new UserExecException(e);
}
}
}
示例8: checkForDuplicateLabels
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* Checks if any labels in the given list appear multiple times and reports an appropriate
* error message if so. Returns true if no duplicates were found, false otherwise.
*
* <p> TODO(bazel-team): apply this to all build functions (maybe automatically?), possibly
* integrate with RuleClass.checkForDuplicateLabels.
*/
private static boolean checkForDuplicateLabels(Collection<Label> labels, String owner,
String attrName, Location location, EventHandler eventHandler) {
Set<Label> dupes = CollectionUtils.duplicatedElementsOf(labels);
for (Label dupe : dupes) {
eventHandler.handle(Event.error(location, String.format(
"label '%s' is duplicated in the '%s' list of '%s'", dupe, attrName, owner)));
}
return dupes.isEmpty();
}
示例9: reportInvalidOptions
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
@Override
public void reportInvalidOptions(EventHandler reporter, BuildOptions buildOptions) {
if (options.testShardingStrategy
== TestActionBuilder.TestShardingStrategy.EXPERIMENTAL_HEURISTIC) {
reporter.handle(
Event.warn(
"Heuristic sharding is intended as a one-off experimentation tool for determing the "
+ "benefit from sharding certain tests. Please don't keep this option in your "
+ ".blazerc or continuous build"));
}
}
示例10: checkCompatibility
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* Checks if this license is compatible with distributing a particular target
* in some set of distribution modes.
*
* @param dists the modes of distribution
* @param target the target which is being checked, and which will be used for
* checking exceptions
* @param licensedTarget the target which declared the license being checked.
* @param eventHandler a reporter where any licensing issues discovered should be
* reported
* @param staticallyLinked whether the target is statically linked under this command
* @return true if the license is compatible with the distributions
*/
public boolean checkCompatibility(Set<DistributionType> dists,
Target target, Label licensedTarget, EventHandler eventHandler,
boolean staticallyLinked) {
Location location = (target instanceof Rule) ? ((Rule) target).getLocation() : null;
LicenseType leastRestrictiveLicense;
if (licenseTypes.contains(LicenseType.RESTRICTED_IF_STATICALLY_LINKED)) {
Set<LicenseType> tempLicenses = EnumSet.copyOf(licenseTypes);
tempLicenses.remove(LicenseType.RESTRICTED_IF_STATICALLY_LINKED);
if (staticallyLinked) {
tempLicenses.add(LicenseType.RESTRICTED);
} else {
tempLicenses.add(LicenseType.UNENCUMBERED);
}
leastRestrictiveLicense = leastRestrictive(tempLicenses);
} else {
leastRestrictiveLicense = leastRestrictive(licenseTypes);
}
for (DistributionType dt : dists) {
if (LICENSE_INCOMPATIBILIES.contains(dt, leastRestrictiveLicense)) {
if (!exceptions.contains(target.getLabel())) {
eventHandler.handle(Event.error(location, "Build target '" + target.getLabel()
+ "' is not compatible with license '" + this + "' from target '"
+ licensedTarget + "'"));
return false;
}
} else if (LICENSE_WARNINGS.contains(dt, leastRestrictiveLicense)) {
eventHandler.handle(
Event.warn(location, "Build target '" + target
+ "' has a potential licensing issue "
+ "with a '" + this + "' license from target '" + licensedTarget + "'"));
}
}
return true;
}
示例11: PackageGroup
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
public PackageGroup(
Label label,
Package pkg,
Collection<String> packageSpecifications,
Collection<Label> includes,
EventHandler eventHandler,
Location location) {
this.label = label;
this.location = location;
this.containingPackage = pkg;
this.includes = ImmutableList.copyOf(includes);
// TODO(bazel-team): Consider refactoring so constructor takes a PackageGroupContents.
ImmutableList.Builder<PackageSpecification> packagesBuilder = ImmutableList.builder();
for (String packageSpecification : packageSpecifications) {
PackageSpecification specification = null;
try {
specification =
PackageSpecification.fromString(
label.getPackageIdentifier().getRepository(), packageSpecification);
} catch (PackageSpecification.InvalidPackageSpecificationException e) {
containsErrors = true;
eventHandler.handle(Event.error(location, e.getMessage()));
}
if (specification != null) {
packagesBuilder.add(specification);
}
}
this.packageSpecifications = PackageGroupContents.create(packagesBuilder.build());
}
示例12: validateAst
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
public static boolean validateAst(
Environment env, List<Statement> statements, EventHandler eventHandler) {
try {
validateAst(env, statements);
return true;
} catch (EvalException e) {
if (!e.isDueToIncompleteAST()) {
eventHandler.handle(Event.error(e.getLocation(), e.getMessage()));
}
return false;
}
}
示例13: filterListForObscuringSymlinks
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* @param eventHandler Used for throwing an error if we have an obscuring runlink.
* May be null, in which case obscuring symlinks are silently discarded.
* @param location Location for reporter. Ignored if reporter is null.
* @param workingManifest Manifest to be checked for obscuring symlinks.
* @return map of source file names mapped to their location on disk.
*/
@VisibleForTesting
static Map<PathFragment, Artifact> filterListForObscuringSymlinks(
EventHandler eventHandler, Location location, Map<PathFragment, Artifact> workingManifest) {
Map<PathFragment, Artifact> newManifest = new HashMap<>();
outer:
for (Iterator<Entry<PathFragment, Artifact>> i = workingManifest.entrySet().iterator();
i.hasNext(); ) {
Entry<PathFragment, Artifact> entry = i.next();
PathFragment source = entry.getKey();
Artifact symlink = entry.getValue();
// drop nested entries; warn if this changes anything
int n = source.segmentCount();
for (int j = 1; j < n; ++j) {
PathFragment prefix = source.subFragment(0, n - j);
Artifact ancestor = workingManifest.get(prefix);
if (ancestor != null) {
// This is an obscuring symlink, so just drop it and move on if there's no reporter.
if (eventHandler == null) {
continue outer;
}
PathFragment suffix = source.subFragment(n - j, n);
Path viaAncestor = ancestor.getPath().getRelative(suffix);
Path expected = symlink.getPath();
if (!viaAncestor.equals(expected)) {
eventHandler.handle(Event.warn(location, "runfiles symlink " + source + " -> "
+ expected + " obscured by " + prefix + " -> " + ancestor.getPath()));
}
continue outer;
}
}
newManifest.put(entry.getKey(), entry.getValue());
}
return newManifest;
}
示例14: reportInvalidOptions
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
@Override
public void reportInvalidOptions(EventHandler reporter, BuildOptions buildOptions) {
if (!Collections.disjoint(translationFlags, J2OBJC_BLACKLISTED_TRANSLATION_FLAGS)) {
String errorMsg = String.format(INVALID_TRANSLATION_FLAGS_MSG_TEMPLATE,
Joiner.on(",").join(translationFlags),
Joiner.on(",").join(J2OBJC_BLACKLISTED_TRANSLATION_FLAGS));
reporter.handle(Event.error(errorMsg));
}
}
示例15: debugMessage
import com.google.devtools.build.lib.events.EventHandler; //导入方法依赖的package包/类
/**
* Helper method to print a debugging message, if the given {@link EventHandler} is not {@code
* null}.
*/
private static void debugMessage(
@Nullable EventHandler eventHandler, String template, Object... args) {
if (eventHandler == null) {
return;
}
eventHandler.handle(Event.info("ToolchainResolution: " + String.format(template, args)));
}