Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compile error visibility #75

Open
wants to merge 22 commits into
base: wix-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
656cdc1
[src] Arbitrary deployable JAR task should not upload local results t…
ZachiNachshon Oct 10, 2019
a2092ea
Add Scala support to plugin workspace
liucijus Oct 28, 2019
c2869e4
only filters labels according to parent packages for LanguageClass.C …
ittaiz Nov 14, 2019
c87ef15
derive_targets_from_directories now defaults to false on project import
ittaiz Nov 28, 2019
089b797
Scala source attachment pt1
liucijus Jan 31, 2020
17ea279
Scala source attachment pt2
liucijus Sep 6, 2022
bf2fa41
Scala source attachment pt3
liucijus Nov 11, 2022
71d0a0d
Scala source attahcment pt4
liucijus Nov 11, 2022
433d493
Prelude support (#53)
aradchykov Jan 15, 2020
e510526
Display notification when JDK is not configured.
povilas Feb 25, 2020
c6d27cf
Notify user when bazel binary cannot be executed
povilas Feb 27, 2020
26a3b62
Support full range major version also for EAP
liucijus Jul 21, 2021
5cabe26
Expose ProtoIdeInfo for proto_library during sync
simuons Oct 4, 2021
878e358
Wix Build setup
liucijus Mar 10, 2020
ec051fa
Add env var to pass additional debug flags for Java
liucijus Jul 15, 2022
f9fbadf
Fix handling of Wix specific test configuration
liucijus Aug 12, 2022
c3fc01f
Drop builds for 212 and 213 versions
liucijus Oct 25, 2022
9a80ccb
Fast test supports Scala junit
ittaiz Nov 23, 2022
214bc38
require the output groups
ittaiz Nov 23, 2022
887edf9
Add 2022.3 build
mildagle Dec 2, 2022
dc07ebf
Fast test supports ITs
ittaiz Dec 6, 2022
d0ffb8a
added more info on failure from BspJob compile result, also lowered t…
ittaiz Dec 12, 2022
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
7 changes: 7 additions & 0 deletions .bazelrc.remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build --bes_results_url=https://app.buildbuddy.io/invocation/
build --bes_backend=grpcs://cloud.buildbuddy.io
# build --remote_cache=grpcs://cloud.buildbuddy.io

# build --remote_download_minimal
# build --remote_retries=0
# build --remote_timeout=10
2 changes: 2 additions & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
5.2.0

28 changes: 28 additions & 0 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run all tests
on: [push]
jobs:
build:
name: test with ${{ matrix.ij_product }}
runs-on: ubuntu-20.04
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
ij_product: ['intellij-2022.1', 'intellij-2022.2', 'intellij-2022.3']
experimental: [false]
steps:
- uses: actions/checkout@v2
- name: bazel cache
uses: actions/cache@v2
with:
path: ~/.bazel-repository-cache
key: ${{ github.ref }}
restore-keys: refs/heads/master
- name: run bazel
continue-on-error: ${{ matrix.experimental }}
run: >
bazel --bazelrc=.bazelrc.remote test //:ijwb_ce_tests
--repository_cache=~/.bazel-repository-cache
--define=ij_product=${{ matrix.ij_product }}
--keep_going
--test_output=errors
26 changes: 26 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,29 @@ jvm_maven_import_external(
licenses = ["notice"], # Apache 2.0
server_urls = ["https://repo1.maven.org/maven2"],
)

bazel_version = "31082327bdb64b7bf52dd55ae18d29e920e61025"

bazel_repo_sha256 = "e8e1ac4bcab303f8f99c9b14ad3afbd059b84c516b7e76f6d9b89b8d5175594f"

http_archive(
name = "bazel",
sha256 = bazel_repo_sha256,
strip_prefix = "bazel-" + bazel_version,
url = "https://github.com/bazelbuild/bazel/archive/%s.zip" % bazel_version,
)

http_archive(
name = "io_buildbuddy_buildbuddy_toolchain",
sha256 = "9055a3e6f45773cd61931eba7b7cf35d6477ab6ad8fb2f18bf9815271fc682fe",
strip_prefix = "buildbuddy-toolchain-52aa5d2cc6c9ba7ee4063de35987be7d1b75f8e2",
urls = ["https://github.com/buildbuddy-io/buildbuddy-toolchain/archive/52aa5d2cc6c9ba7ee4063de35987be7d1b75f8e2.tar.gz"],
)

load("@io_buildbuddy_buildbuddy_toolchain//:deps.bzl", "buildbuddy_deps")

buildbuddy_deps()

load("@io_buildbuddy_buildbuddy_toolchain//:rules.bzl", "buildbuddy")

buildbuddy(name = "buildbuddy_toolchain")
9 changes: 9 additions & 0 deletions aspect/fast_build_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def _fast_build_info_impl(target, ctx):
elif java_common.JavaToolchainInfo != platform_common.ToolchainInfo and \
java_common.JavaToolchainInfo in target:
toolchain = target[java_common.JavaToolchainInfo]
elif hasattr(ctx.rule.attr, "java_compile_toolchain") and ctx.rule.attr.java_compile_toolchain and \
java_common.JavaToolchainInfo in ctx.rule.attr.java_compile_toolchain:
toolchain = ctx.rule.attr.java_compile_toolchain[java_common.JavaToolchainInfo]
else:
toolchain = None
if toolchain:
Expand All @@ -53,11 +56,17 @@ def _fast_build_info_impl(target, ctx):
bootclasspath_jars = []
if hasattr(toolchain, "bootclasspath"):
bootclasspath_jars = [artifact_location(f) for f in toolchain.bootclasspath.to_list()]
java_runtime = struct()
if hasattr(toolchain, "java_runtime"):
java_runtime = struct_omit_none(
java_executable_exec_path = toolchain.java_runtime.java_executable_exec_path,
)
info["java_toolchain_info"] = struct_omit_none(
javac_jars = javac_jars,
bootclasspath_jars = bootclasspath_jars,
source_version = toolchain.source_version,
target_version = toolchain.target_version,
java_runtime = java_runtime,
)
if JavaInfo in target:
write_output = True
Expand Down
26 changes: 23 additions & 3 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,14 @@ def get_source_jars(output):
return [output.source_jar]
return []

def library_artifact(java_output):
def library_artifact(java_output, rule_kind = None):
"""Creates a LibraryArtifact representing a given java_output."""
if java_output == None or java_output.class_jar == None:
return None
src_jars = get_source_jars(java_output)

return struct_omit_none(
interface_jar = artifact_location(java_output.ijar),
interface_jar = None,
jar = artifact_location(java_output.class_jar),
source_jar = artifact_location(src_jars[0]) if src_jars else None,
source_jars = [artifact_location(f) for f in src_jars],
Expand Down Expand Up @@ -322,6 +323,24 @@ def _do_starlark_string_expansion(ctx, name, strings, extra_targets = []):
return strings

##### Builders for individual parts of the aspect output
def collect_proto_info(target, ctx, semantics, ide_info, ide_info_file, output_groups):
if not ProtoInfo in target:
return False

proto_info = target[ProtoInfo]
proto_output = depset([proto_info.direct_descriptor_set])

ide_info["proto_ide_info"] = struct_omit_none(
sources = sources_from_target(ctx),
source_root = proto_info.proto_source_root,
strip_import_prefix = ctx.rule.attr.strip_import_prefix,
import_prefix = ctx.rule.attr.import_prefix,
)

update_sync_output_groups(output_groups, "intellij-info-proto", depset([ide_info_file]))
update_sync_output_groups(output_groups, "intellij-compile-proto", proto_output)
update_sync_output_groups(output_groups, "intellij-resolve-proto", proto_output)
return True

def collect_py_info(target, ctx, semantics, ide_info, ide_info_file, output_groups):
"""Updates Python-specific output groups, returns false if not a Python target."""
Expand Down Expand Up @@ -597,7 +616,7 @@ def collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_gr

ide_info_files = []
sources = sources_from_target(ctx)
jars = [library_artifact(output) for output in java_outputs]
jars = [library_artifact(output, ctx.rule.kind) for output in java_outputs]
class_jars = [output.class_jar for output in java_outputs if output and output.class_jar]
output_jars = [jar for output in java_outputs for jar in jars_from_output(output)]
resolve_files = output_jars
Expand Down Expand Up @@ -1117,6 +1136,7 @@ def intellij_info_aspect_impl(target, ctx, semantics):
ide_info["test_info"] = build_test_info(ctx)

handled = False
handled = collect_proto_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
handled = collect_py_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
handled = collect_cpp_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
handled = collect_c_toolchain_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
licenses(["notice"]) # Apache 2.0

load(
"//aspect/testing/rules:intellij_aspect_test_fixture.bzl",
"intellij_aspect_test_fixture",
)

proto_library(
name = "a_proto",
srcs = ["a.proto"],
import_prefix = "test",
strip_import_prefix = "/" + package_name(),
)

proto_library(
name = "b_proto",
srcs = ["b.proto"],
deps = [":a_proto"],
)

intellij_aspect_test_fixture(
name = "fixture",
deps = [":b_proto"],
)

java_test(
name = "ProtoLibraryTest",
srcs = ["ProtoLibraryTest.java"],
data = [
":fixture",
],
deps = [
"//aspect/testing:BazelIntellijAspectTest",
"//aspect/testing:guava",
"//aspect/testing/rules:IntellijAspectTest",
"//aspect/testing/rules:intellij_aspect_test_fixture_java_proto",
"//intellij_platform_sdk:test_libs",
"//proto:intellij_ide_info_java_proto",
"@junit//jar",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2017 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.aspect.proto.pl;

import com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture;
import com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo;
import com.google.idea.blaze.BazelIntellijAspectTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import static com.google.common.truth.Truth.assertThat;

/** Tests for proto_library. */
@RunWith(JUnit4.class)
public class ProtoLibraryTest extends BazelIntellijAspectTest {

@Test
public void testProtoLibrary() throws Exception {
IntellijAspectTestFixture fixture = loadTestFixture(":fixture");

TargetIdeInfo aProto = findTarget(fixture, ":a_proto");
assertThat(aProto).isNotNull();
assertThat(aProto.hasProtoIdeInfo()).isTrue();
assertThat(relativePathsForArtifacts(aProto.getProtoIdeInfo().getSourcesList()))
.containsExactly(testRelative("a.proto"));
assertThat(aProto.getProtoIdeInfo().getSourceRoot())
.isEqualTo(
"bazel-out/darwin-fastbuild/bin/aspect/testing/tests/src/com/google/idea/blaze/aspect/proto/pl/_virtual_imports/a_proto");
assertThat(aProto.getProtoIdeInfo().getImportPrefix()).isEqualTo("test");
assertThat(aProto.getProtoIdeInfo().getStripImportPrefix())
.isEqualTo("/aspect/testing/tests/src/com/google/idea/blaze/aspect/proto/pl");

TargetIdeInfo bProto = findTarget(fixture, ":b_proto");
assertThat(bProto).isNotNull();
assertThat(bProto.hasProtoIdeInfo()).isTrue();
assertThat(relativePathsForArtifacts(bProto.getProtoIdeInfo().getSourcesList()))
.containsExactly(testRelative("b.proto"));
assertThat(bProto.getProtoIdeInfo().getSourceRoot()).isEqualTo(".");
assertThat(bProto.getProtoIdeInfo().getImportPrefix()).isEmpty();
assertThat(bProto.getProtoIdeInfo().getStripImportPrefix()).isEmpty();
assertThat(dependenciesForTarget(bProto)).contains(dep(aProto));

assertThat(getOutputGroupFiles(fixture, "intellij-info-proto"))
.containsExactly(
testRelative(intellijInfoFileName(aProto.getKey())),
testRelative(intellijInfoFileName(bProto.getKey())));

assertThat(getOutputGroupFiles(fixture, "intellij-compile-proto"))
.containsExactly(
testRelative("a_proto-descriptor-set.proto.bin"),
testRelative("b_proto-descriptor-set.proto.bin"));

assertThat(getOutputGroupFiles(fixture, "intellij-resolve-proto"))
.containsExactly(
testRelative("a_proto-descriptor-set.proto.bin"),
testRelative("b_proto-descriptor-set.proto.bin"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syntax = "proto2";
package a;
message A {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
syntax = "proto3";
import "test/a.proto";
package b;
message B {a.A a = 1;}
2 changes: 2 additions & 0 deletions base/src/META-INF/blaze-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@
serviceImplementation="com.google.idea.blaze.base.projectview.ProjectViewStorageManagerImpl"/>
<projectService serviceInterface="com.google.idea.blaze.base.projectview.ProjectViewManager"
serviceImplementation="com.google.idea.blaze.base.projectview.ProjectViewManagerImpl"/>
<projectService serviceInterface="com.google.idea.blaze.base.prelude.PreludeManager"
serviceImplementation="com.google.idea.blaze.base.prelude.PreludeManagerImpl"/>
<applicationService serviceInterface="com.google.idea.blaze.base.sync.aspects.BlazeIdeInterface"
serviceImplementation="com.google.idea.blaze.base.sync.aspects.BlazeIdeInterfaceAspectsImpl"/>
<projectService serviceInterface="com.google.idea.blaze.base.toolwindow.TasksToolWindowService"
Expand Down
31 changes: 29 additions & 2 deletions base/src/com/google/idea/blaze/base/actions/BuildFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@
import com.google.idea.blaze.base.lang.buildfile.search.BlazePackage;
import com.google.idea.blaze.base.model.BlazeProjectData;
import com.google.idea.blaze.base.model.primitives.Label;
import com.google.idea.blaze.base.model.primitives.LanguageClass;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.google.idea.blaze.base.targetmaps.SourceToTargetMap;
import com.google.idea.common.experiments.BoolExperiment;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFileSystemItem;
import com.intellij.psi.PsiManager;
import java.io.File;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Stream;
import javax.annotation.Nullable;

/** BUILD-file utility methods used by actions. */
Expand Down Expand Up @@ -74,9 +77,11 @@ static PsiElement findBuildTarget(Project project, BlazePackage parentPackage, F
if (packagePath == null) {
return null;
}
final Stream<Label> targetLabels = SourceToTargetMap.getInstance(project)
.getTargetsToBuildForSourceFile(file).stream();

Label label =
SourceToTargetMap.getInstance(project).getTargetsToBuildForSourceFile(file).stream()
.filter(l -> l.blazePackage().equals(packagePath))
filterCRelatedLabelsWhichBelongToOtherPackages(file,packagePath, targetLabels)
.findFirst()
.orElse(null);
if (label == null) {
Expand All @@ -98,6 +103,28 @@ static PsiElement findBuildTarget(Project project, BlazePackage parentPackage, F
return null;
}

private static Stream<Label> filterCRelatedLabelsWhichBelongToOtherPackages(File file,
WorkspacePath packagePath, Stream<Label> targetLabels) {
/*
More info:
https://bazelbuild.slack.com/archives/CM8JQCANN/p1566481600003600
Filter was deliberately added to fix an issue with C++ headers.
The original bug was that opening the BUILD file for foo/bar.h caused it to open baz/qux/BUILD
because there’s a cc_library target in baz/qux that includes foo/bar.h in its headers.
The source-to-target look up queries the index for the target during the last sync which compiled the source file.
In this case, it was the cc_library target in baz/qux.
So the fix was to ensure that the BUILD file is always for the parent package (foo/bar).

This is limited to C only since this logic messes up supporting aggregate targets
https://github.com/bazelbuild/intellij/issues/475
*/
LanguageClass fileLanguage = LanguageClass.fromExtension(
FileUtilRt.getExtension(file.getName()).toLowerCase());
return (fileLanguage == LanguageClass.C) ?
targetLabels.filter(l -> l.blazePackage().equals(packagePath)) :
targetLabels;
}

/**
* Returns the label of a macro with name prefixing the target name of a given label with a '_' or
* '-' delimiter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ default ImmutableList<FileNameMatcher> buildLanguageFileTypeMatchers() {
possibleBuildFileNames().forEach(s -> list.add(new ExactFileNameMatcher(s)));
possibleWorkspaceFileNames().forEach(s -> list.add(new ExactFileNameMatcher(s)));
possibleFileExtensions().forEach(s -> list.add(new ExtensionFileNameMatcher(s)));
list.add(new ExactFileNameMatcher("prelude_bazel"));
return list.build();
}

Expand Down
Loading