use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BlazeCidrRunConfigurationRunner method getExecutableToDebug.
/**
* Builds blaze C/C++ target in debug mode, and returns the output build artifact.
*
* @throws ExecutionException if no unique output artifact was found.
*/
private File getExecutableToDebug() throws ExecutionException {
BuildResultHelper buildResultHelper = BuildResultHelper.forFiles(file -> true);
ListenableFuture<BuildResult> buildOperation = BlazeBeforeRunCommandHelper.runBlazeBuild(configuration, buildResultHelper, ImmutableList.of("-c", "dbg", "--copt=-O0", "--copt=-g", "--strip=never"), ImmutableList.of("--dynamic_mode=off"), "Building debug binary");
try {
SaveUtil.saveAllFiles();
BuildResult result = buildOperation.get();
if (result.status != BuildResult.Status.SUCCESS) {
throw new ExecutionException("Blaze failure building debug binary");
}
} catch (InterruptedException | CancellationException e) {
buildOperation.cancel(true);
throw new RunCanceledByUserException();
} catch (java.util.concurrent.ExecutionException e) {
throw new ExecutionException(e);
}
List<File> candidateFiles = buildResultHelper.getBuildArtifactsForTarget((Label) configuration.getTarget()).stream().filter(File::canExecute).collect(Collectors.toList());
if (candidateFiles.isEmpty()) {
throw new ExecutionException(String.format("No output artifacts found when building %s", configuration.getTarget()));
}
File file = findExecutable((Label) configuration.getTarget(), candidateFiles);
if (file == null) {
throw new ExecutionException(String.format("More than 1 executable was produced when building %s; don't know which one to debug", configuration.getTarget()));
}
LocalFileSystem.getInstance().refreshIoFiles(ImmutableList.of(file));
return file;
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BlazeCommandRunConfigurationRunManagerImplTest method loadStateAndGetStateElementShouldMatchAfterChangeAndRevert.
@Test
public void loadStateAndGetStateElementShouldMatchAfterChangeAndRevert() {
final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
final Label label = Label.create("//package:rule");
configuration.setTarget(label);
final Element initialElement = runManager.getState();
runManager.loadState(initialElement);
final BlazeCommandRunConfiguration modifiedConfiguration = (BlazeCommandRunConfiguration) runManager.getAllConfigurations()[0];
modifiedConfiguration.setTarget(Label.create("//new:label"));
final Element modifiedElement = runManager.getState();
assertThat(xmlOutputter.outputString(modifiedElement)).isNotEqualTo(xmlOutputter.outputString(initialElement));
runManager.loadState(modifiedElement);
final BlazeCommandRunConfiguration revertedConfiguration = (BlazeCommandRunConfiguration) runManager.getAllConfigurations()[0];
revertedConfiguration.setTarget(label);
final Element revertedElement = runManager.getState();
assertThat(xmlOutputter.outputString(revertedElement)).isEqualTo(xmlOutputter.outputString(initialElement));
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BlazeCommandRunConfigurationRunManagerImplTest method loadStateAndGetStateShouldMatch.
@Test
public void loadStateAndGetStateShouldMatch() {
final Label label = Label.create("//package:rule");
configuration.setTarget(label);
final Element element = runManager.getState();
runManager.loadState(element);
final RunConfiguration[] configurations = runManager.getAllConfigurations();
assertThat(configurations).hasLength(1);
assertThat(configurations[0]).isInstanceOf(BlazeCommandRunConfiguration.class);
final BlazeCommandRunConfiguration readConfiguration = (BlazeCommandRunConfiguration) configurations[0];
assertThat(readConfiguration.getTarget()).isEqualTo(label);
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BlazeCommandRunConfigurationTest method readAndWriteShouldMatch.
@Test
public void readAndWriteShouldMatch() throws Exception {
Label label = Label.create("//package:rule");
configuration.setTarget(label);
Element element = new Element("test");
configuration.writeExternal(element);
BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(project);
readConfiguration.readExternal(element);
assertThat(readConfiguration.getTarget()).isEqualTo(label);
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class TransitiveDependencyMapTest method buildTargetMap.
private static TargetMap buildTargetMap() {
Label simpleA = Label.create("//com/google/example/simple:a");
Label simpleB = Label.create("//com/google/example/simple:b");
Label chainA = Label.create("//com/google/example/chain:a");
Label chainB = Label.create("//com/google/example/chain:b");
Label chainC = Label.create("//com/google/example/chain:c");
Label chainD = Label.create("//com/google/example/chain:d");
Label diamondA = Label.create("//com/google/example/diamond:a");
Label diamondB = Label.create("//com/google/example/diamond:b");
Label diamondBB = Label.create("//com/google/example/diamond:bb");
Label diamondBBB = Label.create("//com/google/example/diamond:bbb");
Label diamondC = Label.create("//com/google/example/diamond:c");
Label diamondCC = Label.create("//com/google/example/diamond:cc");
Label diamondCCC = Label.create("//com/google/example/diamond:ccc");
return TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(simpleA).addDependency(simpleB)).addTarget(TargetIdeInfo.builder().setLabel(simpleB)).addTarget(TargetIdeInfo.builder().setLabel(chainA).addDependency(chainB)).addTarget(TargetIdeInfo.builder().setLabel(chainB).addDependency(chainC)).addTarget(TargetIdeInfo.builder().setLabel(chainC).addDependency(chainD)).addTarget(TargetIdeInfo.builder().setLabel(chainD)).addTarget(TargetIdeInfo.builder().setLabel(diamondA).addDependency(diamondB).addDependency(diamondBB).addDependency(diamondBBB)).addTarget(TargetIdeInfo.builder().setLabel(diamondB).addDependency(diamondC)).addTarget(TargetIdeInfo.builder().setLabel(diamondBB).addDependency(diamondC).addDependency(diamondCC)).addTarget(TargetIdeInfo.builder().setLabel(diamondBBB).addDependency(diamondC).addDependency(diamondCC).addDependency(diamondCCC)).addTarget(TargetIdeInfo.builder().setLabel(diamondC)).addTarget(TargetIdeInfo.builder().setLabel(diamondCC)).addTarget(TargetIdeInfo.builder().setLabel(diamondCCC)).build();
}
Aggregations