Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ build --tool_java_language_version=21 --tool_java_runtime_version=21

# Delete test data packages, needed for bazel integration tests. Update by running the following command:
# bazel run @rules_bazel_integration_test//tools:update_deleted_packages
build --deleted_packages=aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/testdata,clwb/tests/projects/clang_cl,clwb/tests/projects/clang_cl/main,clwb/tests/projects/external_includes/main,clwb/tests/projects/llvm_toolchain/main,clwb/tests/projects/llvm_toolchain/wasm,clwb/tests/projects/query_sync/main,clwb/tests/projects/simple/main,clwb/tests/projects/target_compatible/main,clwb/tests/projects/virtual_includes/lib/impl_deps,clwb/tests/projects/virtual_includes/lib/raw_files,clwb/tests/projects/virtual_includes/lib/strip_absolut,clwb/tests/projects/virtual_includes/lib/strip_relative,clwb/tests/projects/virtual_includes/main,examples/cpp/simple_project/.clwb/aspects,examples/cpp/simple_project/src,examples/cpp/simple_project/src/lib,examples/go/with_go_source,examples/go/with_go_source/otherlib,examples/go/with_go_source/testa,examples/go/with_go_source/testb,examples/go/with_proto,examples/go/with_proto/go,examples/go/with_proto/go/external,examples/go/with_proto/go/lib,examples/go/with_proto/proto,examples/java/greetings_project,examples/java/greetings_project/greeting_lib,examples/java/greetings_project/hello,examples/java/greetings_project/hi,examples/kotlin/simple_project,examples/python/simple_code_generator/example,examples/python/simple_code_generator/generated,examples/python/simple_code_generator/lib,examples/python/simple_code_generator/rules,examples/python/with_numpy,examples/python/with_numpy/app,examples/python/with_numpy/lib,examples/scala/with_bzlmod/hello,ijwb/tests/projects/simple,testing/test_deps/projects,testing/test_deps/projects/java_and_deps,testing/test_deps/projects/java_and_deps/deps/no_ide,testing/test_deps/projects/java_and_deps/deps/top_level_lib_1,testing/test_deps/projects/java_and_deps/deps/top_level_lib_2,testing/test_deps/projects/java_and_deps/deps/transitive_dep_lib,testing/test_deps/projects/java_and_deps/project,testing/test_deps/projects/java_and_deps/project/java/com/example/sample/nested,testing/test_deps/projects/simple_java,testing/test_deps/projects/simple_java/java/com/example/sample/nested,testing/test_deps/projects/simple_proto/external,testing/test_deps/projects/simple_proto/project
query --deleted_packages=aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/testdata,clwb/tests/projects/clang_cl,clwb/tests/projects/clang_cl/main,clwb/tests/projects/external_includes/main,clwb/tests/projects/llvm_toolchain/main,clwb/tests/projects/llvm_toolchain/wasm,clwb/tests/projects/query_sync/main,clwb/tests/projects/simple/main,clwb/tests/projects/target_compatible/main,clwb/tests/projects/virtual_includes/lib/impl_deps,clwb/tests/projects/virtual_includes/lib/raw_files,clwb/tests/projects/virtual_includes/lib/strip_absolut,clwb/tests/projects/virtual_includes/lib/strip_relative,clwb/tests/projects/virtual_includes/main,examples/cpp/simple_project/.clwb/aspects,examples/cpp/simple_project/src,examples/cpp/simple_project/src/lib,examples/go/with_go_source,examples/go/with_go_source/otherlib,examples/go/with_go_source/testa,examples/go/with_go_source/testb,examples/go/with_proto,examples/go/with_proto/go,examples/go/with_proto/go/external,examples/go/with_proto/go/lib,examples/go/with_proto/proto,examples/java/greetings_project,examples/java/greetings_project/greeting_lib,examples/java/greetings_project/hello,examples/java/greetings_project/hi,examples/kotlin/simple_project,examples/python/simple_code_generator/example,examples/python/simple_code_generator/generated,examples/python/simple_code_generator/lib,examples/python/simple_code_generator/rules,examples/python/with_numpy,examples/python/with_numpy/app,examples/python/with_numpy/lib,examples/scala/with_bzlmod/hello,ijwb/tests/projects/simple,testing/test_deps/projects,testing/test_deps/projects/java_and_deps,testing/test_deps/projects/java_and_deps/deps/no_ide,testing/test_deps/projects/java_and_deps/deps/top_level_lib_1,testing/test_deps/projects/java_and_deps/deps/top_level_lib_2,testing/test_deps/projects/java_and_deps/deps/transitive_dep_lib,testing/test_deps/projects/java_and_deps/project,testing/test_deps/projects/java_and_deps/project/java/com/example/sample/nested,testing/test_deps/projects/simple_java,testing/test_deps/projects/simple_java/java/com/example/sample/nested,testing/test_deps/projects/simple_proto/external,testing/test_deps/projects/simple_proto/project
build --deleted_packages=.bazelbsp,.bazelbsp/aspects,aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/testdata,clwb/tests/projects/clang_cl,clwb/tests/projects/clang_cl/main,clwb/tests/projects/execution/main,clwb/tests/projects/external_includes/main,clwb/tests/projects/llvm_toolchain/main,clwb/tests/projects/llvm_toolchain/wasm,clwb/tests/projects/query_sync/main,clwb/tests/projects/simple/main,clwb/tests/projects/target_compatible/main,clwb/tests/projects/virtual_includes/.clwb/aspects,clwb/tests/projects/virtual_includes/lib/impl_deps,clwb/tests/projects/virtual_includes/lib/raw_files,clwb/tests/projects/virtual_includes/lib/strip_absolut,clwb/tests/projects/virtual_includes/lib/strip_relative,clwb/tests/projects/virtual_includes/main,examples/cpp/simple_project/.clwb/aspects,examples/cpp/simple_project/src,examples/cpp/simple_project/src/lib,examples/go/with_go_source,examples/go/with_go_source/otherlib,examples/go/with_go_source/testa,examples/go/with_go_source/testb,examples/go/with_proto,examples/go/with_proto/go,examples/go/with_proto/go/external,examples/go/with_proto/go/lib,examples/go/with_proto/proto,examples/java/greetings_project,examples/java/greetings_project/.ijwb/aspects,examples/java/greetings_project/greeting_lib,examples/java/greetings_project/hello,examples/java/greetings_project/hi,examples/kotlin/simple_project,examples/python/simple_code_generator/example,examples/python/simple_code_generator/generated,examples/python/simple_code_generator/lib,examples/python/simple_code_generator/rules,examples/python/with_numpy,examples/python/with_numpy/app,examples/python/with_numpy/lib,examples/scala/with_bzlmod/hello,ijwb/tests/projects/simple,testing/test_deps/projects,testing/test_deps/projects/java_and_deps,testing/test_deps/projects/java_and_deps/deps/no_ide,testing/test_deps/projects/java_and_deps/deps/top_level_lib_1,testing/test_deps/projects/java_and_deps/deps/top_level_lib_2,testing/test_deps/projects/java_and_deps/deps/transitive_dep_lib,testing/test_deps/projects/java_and_deps/project,testing/test_deps/projects/java_and_deps/project/java/com/example/sample/nested,testing/test_deps/projects/simple_java,testing/test_deps/projects/simple_java/java/com/example/sample/nested,testing/test_deps/projects/simple_proto/external,testing/test_deps/projects/simple_proto/project
query --deleted_packages=.bazelbsp,.bazelbsp/aspects,aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/testdata,clwb/tests/projects/clang_cl,clwb/tests/projects/clang_cl/main,clwb/tests/projects/execution/main,clwb/tests/projects/external_includes/main,clwb/tests/projects/llvm_toolchain/main,clwb/tests/projects/llvm_toolchain/wasm,clwb/tests/projects/query_sync/main,clwb/tests/projects/simple/main,clwb/tests/projects/target_compatible/main,clwb/tests/projects/virtual_includes/.clwb/aspects,clwb/tests/projects/virtual_includes/lib/impl_deps,clwb/tests/projects/virtual_includes/lib/raw_files,clwb/tests/projects/virtual_includes/lib/strip_absolut,clwb/tests/projects/virtual_includes/lib/strip_relative,clwb/tests/projects/virtual_includes/main,examples/cpp/simple_project/.clwb/aspects,examples/cpp/simple_project/src,examples/cpp/simple_project/src/lib,examples/go/with_go_source,examples/go/with_go_source/otherlib,examples/go/with_go_source/testa,examples/go/with_go_source/testb,examples/go/with_proto,examples/go/with_proto/go,examples/go/with_proto/go/external,examples/go/with_proto/go/lib,examples/go/with_proto/proto,examples/java/greetings_project,examples/java/greetings_project/.ijwb/aspects,examples/java/greetings_project/greeting_lib,examples/java/greetings_project/hello,examples/java/greetings_project/hi,examples/kotlin/simple_project,examples/python/simple_code_generator/example,examples/python/simple_code_generator/generated,examples/python/simple_code_generator/lib,examples/python/simple_code_generator/rules,examples/python/with_numpy,examples/python/with_numpy/app,examples/python/with_numpy/lib,examples/scala/with_bzlmod/hello,ijwb/tests/projects/simple,testing/test_deps/projects,testing/test_deps/projects/java_and_deps,testing/test_deps/projects/java_and_deps/deps/no_ide,testing/test_deps/projects/java_and_deps/deps/top_level_lib_1,testing/test_deps/projects/java_and_deps/deps/top_level_lib_2,testing/test_deps/projects/java_and_deps/deps/transitive_dep_lib,testing/test_deps/projects/java_and_deps/project,testing/test_deps/projects/java_and_deps/project/java/com/example/sample/nested,testing/test_deps/projects/simple_java,testing/test_deps/projects/simple_java/java/com/example/sample/nested,testing/test_deps/projects/simple_proto/external,testing/test_deps/projects/simple_proto/project

common --enable_bzlmod
common --noincompatible_disallow_empty_glob
Expand Down
2 changes: 2 additions & 0 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ def collect_cpp_info(target, ctx, semantics, ide_info, ide_info_file, output_gro
target_copts += semantics.cc.get_default_copts(ctx)

target_copts = _do_starlark_string_expansion(ctx, "copt", target_copts, extra_targets)
args = _do_starlark_string_expansion(ctx, "args", getattr(ctx.rule.attr, "args", []), extra_targets)

compilation_context = target[CcInfo].compilation_context

Expand All @@ -571,6 +572,7 @@ def collect_cpp_info(target, ctx, semantics, ide_info, ide_info_file, output_gro
transitive_system_include_directory = compilation_context.system_includes.to_list() + external_includes,
include_prefix = getattr(ctx.rule.attr, "include_prefix", None),
strip_include_prefix = getattr(ctx.rule.attr, "strip_include_prefix", None),
args = args,
)
ide_info["c_ide_info"] = c_info
resolve_files = compilation_context.headers
Expand Down
28 changes: 23 additions & 5 deletions base/src/com/google/idea/blaze/base/ideinfo/CIdeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public final class CIdeInfo implements ProtoWrapper<IntellijIdeInfo.CIdeInfo> {
private final String includePrefix;
private final String stripIncludePrefix;

private final ImmutableList<String> args;

private CIdeInfo(
ImmutableList<ArtifactLocation> sources,
ImmutableList<ArtifactLocation> headers,
Expand All @@ -48,7 +50,8 @@ private CIdeInfo(
ImmutableList<String> transitiveDefines,
ImmutableList<ExecutionRootPath> transitiveSystemIncludeDirectories,
String includePrefix,
String stripIncludePrefix) {
String stripIncludePrefix,
ImmutableList<String> args) {
this.sources = sources;
this.headers = headers;
this.textualHeaders = textualHeaders;
Expand All @@ -59,6 +62,7 @@ private CIdeInfo(
this.transitiveSystemIncludeDirectories = transitiveSystemIncludeDirectories;
this.includePrefix = includePrefix;
this.stripIncludePrefix = stripIncludePrefix;
this.args = args;
}

static CIdeInfo fromProto(IntellijIdeInfo.CIdeInfo proto) {
Expand All @@ -74,7 +78,8 @@ static CIdeInfo fromProto(IntellijIdeInfo.CIdeInfo proto) {
ProtoWrapper.map(
proto.getTransitiveSystemIncludeDirectoryList(), ExecutionRootPath::fromProto),
proto.getIncludePrefix(),
proto.getStripIncludePrefix());
proto.getStripIncludePrefix(),
ProtoWrapper.internStrings(proto.getArgsList()));
}

@Override
Expand All @@ -90,6 +95,7 @@ public IntellijIdeInfo.CIdeInfo toProto() {
.addAllTransitiveDefine(transitiveDefines)
.addAllTransitiveSystemIncludeDirectory(
ProtoWrapper.mapToProtos(transitiveSystemIncludeDirectories))
.addAllArgs(args)
.build();
}

Expand Down Expand Up @@ -133,6 +139,10 @@ public String getStripIncludePrefix() {
return stripIncludePrefix;
}

public ImmutableList<String> getArgs() {
return args;
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -155,6 +165,8 @@ public static class Builder {
private String includePrefix = "";
private String stripIncludePrefix = "";

private final ImmutableList.Builder<String> args = ImmutableList.builder();

@CanIgnoreReturnValue
public Builder addSources(Iterable<ArtifactLocation> sources) {
this.sources.addAll(sources);
Expand Down Expand Up @@ -247,7 +259,8 @@ public CIdeInfo build() {
transitiveDefines.build(),
transitiveSystemIncludeDirectories.build(),
includePrefix,
stripIncludePrefix);
stripIncludePrefix,
args.build());
}
}

Expand Down Expand Up @@ -279,6 +292,9 @@ public String toString() {
+ " transitiveSystemIncludeDirectories="
+ getTransitiveSystemIncludeDirectories()
+ "\n"
+ " args="
+ getArgs()
+ "\n"
+ '}';
}

Expand All @@ -300,7 +316,8 @@ public boolean equals(Object o) {
transitiveQuoteIncludeDirectories, cIdeInfo.transitiveQuoteIncludeDirectories)
&& Objects.equals(transitiveDefines, cIdeInfo.transitiveDefines)
&& Objects.equals(
transitiveSystemIncludeDirectories, cIdeInfo.transitiveSystemIncludeDirectories);
transitiveSystemIncludeDirectories, cIdeInfo.transitiveSystemIncludeDirectories)
&& Objects.equals(args, cIdeInfo.args);
}

@Override
Expand All @@ -313,6 +330,7 @@ public int hashCode() {
transitiveIncludeDirectories,
transitiveQuoteIncludeDirectories,
transitiveDefines,
transitiveSystemIncludeDirectories);
transitiveSystemIncludeDirectories,
args);
}
}
11 changes: 11 additions & 0 deletions base/src/com/google/idea/blaze/base/ideinfo/TargetMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

import com.google.common.base.Functions;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.intellij.model.ProjectData;
import com.google.idea.blaze.base.model.primitives.Label;
import java.util.Map.Entry;
import java.util.Objects;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -50,6 +53,14 @@ public TargetIdeInfo get(TargetKey key) {
return targetMap.get(key);
}

public ImmutableList<TargetIdeInfo> get(Label label) {
return targetMap.entrySet()
.stream()
.filter(it -> it.getKey().getLabel().equals(label))
.map(Entry::getValue)
.collect(ImmutableList.toImmutableList());
}

public boolean contains(TargetKey key) {
return targetMap.containsKey(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.idea.blaze.base.run.targetfinder.TargetFinder;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.project.Project;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -58,19 +59,20 @@ protected ConfigurationFactory getConfigurationFactory() {
}

@Override
public void setupConfiguration(RunConfiguration configuration, Label label) {
public void setupConfiguration(DataContext context, RunConfiguration configuration, Label label) {
BlazeCommandRunConfiguration blazeConfig = (BlazeCommandRunConfiguration) configuration;
TargetInfo target = findProjectTarget(configuration.getProject(), label);
blazeConfig.setTargetInfo(target);
if (target == null) {
return;
}

BlazeCommandRunConfigurationCommonState state =
blazeConfig.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
final var state = blazeConfig.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (state != null) {
state.readContext(context);
state.getCommandState().setCommand(commandForRuleType(target.getRuleType()));
}

blazeConfig.setGeneratedName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;

Expand All @@ -43,13 +45,13 @@ public RunnerAndConfigurationSettings createForTarget(
Project project, RunManager runManager, Label target) {
ConfigurationFactory factory = getConfigurationFactory();
RunConfiguration configuration = factory.createTemplateConfiguration(project, runManager);
setupConfiguration(configuration, target);
setupConfiguration(SimpleDataContext.EMPTY_CONTEXT, configuration, target);
return runManager.createConfiguration(configuration, factory);
}

/** The factory used to create configurations. */
protected abstract ConfigurationFactory getConfigurationFactory();

/** Initialize the configuration for the given target. */
public abstract void setupConfiguration(RunConfiguration configuration, Label target);
public abstract void setupConfiguration(DataContext context, RunConfiguration configuration, Label target);
}
Loading