Skip to content

Commit 59b7476

Browse files
committed
Support running aspect in Bazel Sandbox
1 parent b66a423 commit 59b7476

File tree

3 files changed

+2
-19
lines changed

3 files changed

+2
-19
lines changed

docs/getting-started.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,6 @@ The `--bazel-scip-java-binary` argument is required due to implementation
354354
details, scip-java runs an [aspect](https://bazel.build/extending/aspects) that
355355
requires the absolute path to the `scip-java` binary.
356356

357-
> The current solution for automatic indexing step is not yet 100% hermetic and,
358-
> therefore, relies on `--spawn_strategy=local` under the hood. Depending on
359-
> your use-case, this might be OK or not. If there is demand for it, it's should
360-
> be possible to make the indexing fully hermetic and compatible with Bazel's
361-
> sandbox with some extra work.
362-
363357
#### Manual - `select`
364358

365359
It's possible to index Bazel codebases by integrating scip-java directly into

scip-java/src/main/resources/scip-java/scip_java.bzl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ many *.scip (https://github.com/sourcegraph/scip) and
1414
These files encode information about which symbols are referenced from which
1515
locations in your source code.
1616
17-
This aspect only works on Linux when using the `local` spawn strategy because
18-
the `run_shell` action writes SemanticDB and SCIP files to the provided
19-
--targetroot argument. It should be possible to avoid this requirement
20-
in the future if there's a strong desire to make the aspect work with the
21-
default (sandboxed) spawn strategy.
22-
2317
Use the command below to merge all of these SCIP files into a single index:
2418
2519
find bazel-bin/ -type f -name '*.scip' | xargs cat > index.scip
@@ -34,7 +28,7 @@ Use `src code-intel upload` to upload the unified SCIP file to Sourcegraph:
3428
3529
Example command to run this aspect directly:
3630
37-
bazel build //... --spawn_strategy=local --aspects path/to/scip_java.bzl%scip_java_aspect --output_groups=scip --define=sourceroot=$(pwd) --define=scip_java_binary=$(which scip-java) --define=java_home=$JAVA_HOME
31+
bazel build //... --aspects path/to/scip_java.bzl%scip_java_aspect --output_groups=scip --define=scip_java_binary=$(which scip-java) --define=java_home=$JAVA_HOME
3832
3933
To learn more about aspects: https://bazel.build/extending/aspects
4034
"""
@@ -140,9 +134,8 @@ def _scip_java(target, ctx):
140134
deps = [javac_action.inputs, annotations.processor_classpath]
141135

142136
ctx.actions.run_shell(
143-
command = "\"{}\" index --no-cleanup --index-semanticdb.allow-empty-index --cwd \"{}\" --targetroot {} --scip-config \"{}\" --output \"{}\"".format(
137+
command = "\"{}\" index --no-cleanup --index-semanticdb.allow-empty-index --targetroot {} --scip-config \"{}\" --output \"{}\"".format(
144138
ctx.var["scip_java_binary"],
145-
ctx.var["sourceroot"],
146139
targetroot.path,
147140
build_config_path.path,
148141
scip_output.path,

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BazelBuildTool.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,9 @@ class BazelBuildTool(index: IndexCommand) extends BuildTool("Bazel", index) {
6363
"bazel",
6464
"build",
6565
"--noshow_progress",
66-
// The local strategy is required for now because we write SemanticDB and SCIP files
67-
// to the provided targetroot directory.
68-
"--spawn_strategy=local",
6966
"--aspects",
7067
s"$aspectLabel%scip_java_aspect",
7168
"--output_groups=scip",
72-
s"--define=sourceroot=${index.workingDirectory}",
7369
s"--define=java_home=$javaHome",
7470
s"--define=scip_java_binary=$scipJavaBinary",
7571
"--verbose_failures"

0 commit comments

Comments
 (0)