use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method testTargetWithMixedSources.
@Test
public void testTargetWithMixedSources() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:binary"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc"), gen("foo/bar/generated.cc")))).build();
assertThatResolving(projectView, targetMap).producesConfigurationsFor("//foo/bar:binary");
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method testSingleSourceTargetWithSourceDependencies.
@Test
public void testSingleSourceTargetWithSourceDependencies() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:binary"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc"))).addDependency("//foo/bar:library").addDependency("//third_party:library")).addTarget(createCcTarget("//foo/bar:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/library.cc")), ImmutableList.of("SOME_DEFINE=1"))).addTarget(createCcTarget("//third_party:library", Kind.CC_LIBRARY, ImmutableList.of(src("third_party/library.cc")))).build();
assertThatResolving(projectView, targetMap).producesConfigurationsFor("//foo/bar:binary", "//foo/bar:library");
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method testComplexProject.
@Test
public void testComplexProject() {
ProjectView projectView = projectView(directories("foo/bar", "foo/baz"), targets("//foo:test", "//foo/bar:binary", "//foo/baz:test"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo:test", Kind.CC_TEST, ImmutableList.of(src("foo/test.cc"))).addDependency("//foo:library").addDependency("//foo/bar:library").addDependency("//third_party:library")).addTarget(createCcTarget("//foo:library", Kind.CC_TEST, ImmutableList.of(src("foo/library.cc")))).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc")), ImmutableList.of("SOME_DEFINE=1")).addDependency("//foo/bar:library").addDependency("//foo/bar:empty").addDependency("//foo/bar:generated").addDependency("//foo/bar:mixed").addDependency("//third_party:library")).addTarget(createCcTarget("//foo/bar:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/library.cc")), ImmutableList.of("SOME_DEFINE=2"))).addTarget(createCcTarget("//foo/bar:empty", Kind.CC_LIBRARY, ImmutableList.of())).addTarget(createCcTarget("//foo/bar:generated", Kind.CC_LIBRARY, ImmutableList.of(gen("foo/bar/generated.cc")))).addTarget(createCcTarget("//foo/bar:mixed", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/mixed_src.cc"), gen("foo/bar/mixed_gen.cc")), ImmutableList.of("SOME_DEFINE=3"))).addTarget(createCcTarget("//foo/baz:test", Kind.CC_TEST, ImmutableList.of(src("foo/baz/test.cc")), ImmutableList.of("SOME_DEFINE=4")).addDependency("//foo/baz:binary").addDependency("//foo/baz:library").addDependency("//foo/qux:library")).addTarget(createCcTarget("//foo/baz:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/baz/binary.cc")), ImmutableList.of("SOME_DEFINE=5"))).addTarget(createCcTarget("//foo/baz:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/baz/library.cc")), ImmutableList.of("SOME_DEFINE=6"))).addTarget(createCcTarget("//foo/qux:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/qux/library.cc")))).addTarget(createCcTarget("//third_party:library", Kind.CC_LIBRARY, ImmutableList.of(src("third_party/library.cc")))).build();
assertThatResolving(projectView, targetMap).producesConfigurationsFor("//foo/bar:binary", "//foo/bar:library", "//foo/bar:mixed", "//foo/baz:test", "//foo/baz:binary", "//foo/baz:library");
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeResolveConfigurationEquivalenceTest method testEmptyConfigurations.
@Test
public void testEmptyConfigurations() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:one", "//foo/bar:two", "//foo/bar:three"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:one", Kind.CC_BINARY, sources("foo/bar/one.cc"), defines(), includes())).addTarget(createCcTarget("//foo/bar:two", Kind.CC_BINARY, sources("foo/bar/two.cc"), defines(), includes())).addTarget(createCcTarget("//foo/bar:three", Kind.CC_BINARY, sources("foo/bar/three.cc"), defines(), includes())).build();
List<BlazeResolveConfiguration> configurations = resolve(projectView, targetMap);
assertThat(configurations).hasSize(1);
assertThat(get(configurations, "//foo/bar:one and 2 other target(s)")).isNotNull();
for (BlazeResolveConfiguration configuration : configurations) {
assertThat(configuration.getProjectHeadersRoots().getRoots()).isEmpty();
assertThat(getHeaders(configuration, OCLanguageKind.CPP)).isEmpty();
assertThat(configuration.getCompilerMacros()).isEqualTo(macros());
}
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class FastBuildServiceImpl method buildDeployJar.
private ListenableFuture<FastBuildState.BuildOutput> buildDeployJar(Label label, FastBuildParameters buildParameters) {
Label deployJarLabel = createDeployJarLabel(label);
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
// TODO(plumpy): this assumes we're running this build as part of a run action. I try not to
// make that assumption anywhere else, so this should be supplied by the caller.
BlazeConsolePopupBehavior consolePopupBehavior = BlazeUserSettings.getInstance().getSuppressConsoleForRunAction() ? BlazeConsolePopupBehavior.NEVER : BlazeConsolePopupBehavior.ALWAYS;
AspectStrategy aspectStrategy = AspectStrategyProvider.findAspectStrategy(projectDataManager.getBlazeProjectData().blazeVersionData);
BuildResultHelper buildResultHelper = BuildResultHelper.forFiles(file -> file.endsWith(deployJarLabel.targetName().toString()) || aspectStrategy.getAspectOutputFilePredicate().test(file));
ListenableFuture<BuildResult> buildResultFuture = ProgressiveTaskWithProgressIndicator.builder(project).submitTaskWithResult(new ScopedTask<BuildResult>() {
@Override
protected BuildResult execute(BlazeContext context) {
context.push(new IssuesScope(project, /* focusProblemsViewOnIssue */
true)).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(consolePopupBehavior).addConsoleFilters(new IssueOutputFilter(project, workspaceRoot, BlazeInvocationContext.NonSync, true)).build());
context.output(new StatusOutput("Building base deploy jar for fast builds: " + deployJarLabel.targetName()));
BlazeCommand.Builder command = BlazeCommand.builder(buildParameters.blazeBinary(), BlazeCommandName.BUILD).addTargets(label).addTargets(deployJarLabel).addBlazeFlags(buildParameters.blazeFlags()).addBlazeFlags(buildResultHelper.getBuildFlags());
List<String> outputGroups = new ArrayList<>();
// needed to retrieve the deploy jar
outputGroups.add("default");
outputGroups.addAll(aspectStrategy.getOutputGroups(OutputGroup.INFO, ImmutableSet.of(LanguageClass.JAVA)));
aspectStrategy.addAspectAndOutputGroups(command, outputGroups);
int exitCode = ExternalTask.builder(workspaceRoot).addBlazeCommand(command.build()).context(context).stderr(LineProcessingOutputStream.of(BlazeConsoleLineProcessorProvider.getAllStderrLineProcessors(context))).build().run();
return BuildResult.fromExitCode(exitCode);
}
});
ListenableFuture<BuildOutput> buildOutputFuture = transform(buildResultFuture, result -> {
if (result.status != Status.SUCCESS) {
throw new RuntimeException("Blaze failure building deploy jar");
}
ImmutableList<File> deployJarArtifacts = buildResultHelper.getBuildArtifactsForTarget(deployJarLabel);
checkState(deployJarArtifacts.size() == 1);
File deployJar = deployJarArtifacts.get(0);
ImmutableList<File> ideInfoFiles = buildResultHelper.getArtifactsForOutputGroups(aspectStrategy.getOutputGroups(OutputGroup.INFO, ImmutableSet.of(LanguageClass.JAVA)));
ImmutableMap<TargetKey, TargetIdeInfo> targetMap = ideInfoFiles.stream().map(file -> readTargetIdeInfo(aspectStrategy, file)).filter(Objects::nonNull).collect(toImmutableMap(ideInfo -> ideInfo.key, i -> i));
return BuildOutput.create(deployJar, new TargetMap(targetMap));
}, ConcurrencyUtil.getAppExecutorService());
buildOutputFuture.addListener(buildResultHelper::close, ConcurrencyUtil.getAppExecutorService());
return buildOutputFuture;
}
Aggregations