use of com.google.devtools.build.lib.syntax.EvalException in project bazel by bazelbuild.
the class HttpArchiveFunction method getDescriptor.
protected DecompressorDescriptor getDescriptor(Rule rule, Path downloadPath, Path outputDirectory) throws RepositoryFunctionException {
DecompressorDescriptor.Builder builder = DecompressorDescriptor.builder().setTargetKind(rule.getTargetKind()).setTargetName(rule.getName()).setArchivePath(downloadPath).setRepositoryPath(outputDirectory);
WorkspaceAttributeMapper mapper = WorkspaceAttributeMapper.of(rule);
if (mapper.isAttributeValueExplicitlySpecified("strip_prefix")) {
try {
builder.setPrefix(mapper.get("strip_prefix", Type.STRING));
} catch (EvalException e) {
throw new RepositoryFunctionException(e, Transience.PERSISTENT);
}
}
return builder.build();
}
use of com.google.devtools.build.lib.syntax.EvalException in project bazel by bazelbuild.
the class HttpFileFunction method getDescriptor.
@Override
protected DecompressorDescriptor getDescriptor(Rule rule, Path downloadPath, Path outputDirectory) throws RepositoryFunctionException {
WorkspaceAttributeMapper mapper = WorkspaceAttributeMapper.of(rule);
boolean executable = false;
try {
executable = (mapper.isAttributeValueExplicitlySpecified("executable") && mapper.get("executable", Type.BOOLEAN));
} catch (EvalException e) {
throw new RepositoryFunctionException(e, Transience.PERSISTENT);
}
return DecompressorDescriptor.builder().setDecompressor(FileDecompressor.INSTANCE).setTargetKind(rule.getTargetKind()).setTargetName(rule.getName()).setArchivePath(downloadPath).setRepositoryPath(outputDirectory).setExecutable(executable).build();
}
use of com.google.devtools.build.lib.syntax.EvalException in project bazel by bazelbuild.
the class MavenJarFunction method createOutputTree.
private RepositoryDirectoryValue.Builder createOutputTree(Rule rule, Path outputDirectory, MavenServerValue serverValue) throws RepositoryFunctionException, InterruptedException {
Preconditions.checkState(downloader instanceof MavenDownloader);
MavenDownloader mavenDownloader = (MavenDownloader) downloader;
createDirectory(outputDirectory);
String name = rule.getName();
Path repositoryJar;
try {
repositoryJar = mavenDownloader.download(name, WorkspaceAttributeMapper.of(rule), outputDirectory, serverValue);
} catch (IOException e) {
throw new RepositoryFunctionException(e, Transience.TRANSIENT);
} catch (EvalException e) {
throw new RepositoryFunctionException(e, Transience.TRANSIENT);
}
// Add a WORKSPACE file & BUILD file to the Maven jar.
Path result = DecompressorValue.decompress(DecompressorDescriptor.builder().setDecompressor(JarDecompressor.INSTANCE).setTargetKind(MavenJarRule.NAME).setTargetName(name).setArchivePath(repositoryJar).setRepositoryPath(outputDirectory).build());
return RepositoryDirectoryValue.builder().setPath(result);
}
use of com.google.devtools.build.lib.syntax.EvalException in project bazel by bazelbuild.
the class MavenJarFunction method getServer.
private static MavenServerValue getServer(Rule rule, Environment env) throws RepositoryFunctionException, InterruptedException {
WorkspaceAttributeMapper mapper = WorkspaceAttributeMapper.of(rule);
boolean hasRepository = mapper.isAttributeValueExplicitlySpecified("repository");
boolean hasServer = mapper.isAttributeValueExplicitlySpecified("server");
if (hasRepository && hasServer) {
throw new RepositoryFunctionException(new EvalException(rule.getLocation(), rule + " specifies both " + "'repository' and 'server', which are mutually exclusive options"), Transience.PERSISTENT);
}
try {
if (hasRepository) {
return MavenServerValue.createFromUrl(mapper.get("repository", Type.STRING));
} else {
String serverName = DEFAULT_SERVER;
if (hasServer) {
serverName = mapper.get("server", Type.STRING);
}
return (MavenServerValue) env.getValue(MavenServerValue.key(serverName));
}
} catch (EvalException e) {
throw new RepositoryFunctionException(e, Transience.PERSISTENT);
}
}
use of com.google.devtools.build.lib.syntax.EvalException in project bazel by bazelbuild.
the class PostConfiguredTargetFunction method compute.
@Nullable
@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws SkyFunctionException, InterruptedException {
ImmutableMap<ActionAnalysisMetadata, ConflictException> badActions = PrecomputedValue.BAD_ACTIONS.get(env);
ConfiguredTargetValue ctValue = (ConfiguredTargetValue) env.getValue(ConfiguredTargetValue.key((ConfiguredTargetKey) skyKey.argument()));
if (env.valuesMissing()) {
return null;
}
for (ActionAnalysisMetadata action : ctValue.getActions()) {
if (badActions.containsKey(action)) {
throw new ActionConflictFunctionException(badActions.get(action));
}
}
ConfiguredTarget ct = ctValue.getConfiguredTarget();
TargetAndConfiguration ctgValue = new TargetAndConfiguration(ct.getTarget(), ct.getConfiguration());
ImmutableMap<Label, ConfigMatchingProvider> configConditions = getConfigurableAttributeConditions(ctgValue, env);
if (configConditions == null) {
return null;
}
OrderedSetMultimap<Attribute, Dependency> deps;
try {
BuildConfiguration hostConfiguration = buildViewProvider.getSkyframeBuildView().getHostConfiguration(ct.getConfiguration());
SkyframeDependencyResolver resolver = buildViewProvider.getSkyframeBuildView().createDependencyResolver(env);
// We don't track root causes here - this function is only invoked for successfully analyzed
// targets - as long as we redo the exact same steps here as in ConfiguredTargetFunction, this
// can never fail.
deps = resolver.dependentNodeMap(ctgValue, hostConfiguration, /*aspect=*/
null, configConditions);
if (ct.getConfiguration() != null && ct.getConfiguration().useDynamicConfigurations()) {
deps = ConfiguredTargetFunction.getDynamicConfigurations(env, ctgValue, deps, hostConfiguration, ruleClassProvider);
}
} catch (EvalException | ConfiguredTargetFunction.DependencyEvaluationException | InvalidConfigurationException | InconsistentAspectOrderException e) {
throw new PostConfiguredTargetFunctionException(e);
}
env.getValues(Iterables.transform(deps.values(), TO_KEYS));
if (env.valuesMissing()) {
return null;
}
return new PostConfiguredTargetValue(ct);
}
Aggregations