Skip to content

Commit 782f590

Browse files
authored
Merge pull request #77 from lucidsoftware/do-not-always-provide-transitive-analysis-files
Don't always provide transitive dependencies' analysis files to ZincRunner
2 parents 5b3bd62 + 9d28e81 commit 782f590

7 files changed

+68
-2
lines changed

rules/private/phases/phase_zinc_compile.bzl

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def phase_zinc_compile(ctx, g):
3838
common_scalacopts = toolchain.scala_configuration.global_scalacopts + ctx.attr.scalacopts
3939

4040
args = ctx.actions.args()
41-
args.add_all(depset(transitive = [zinc.deps for zinc in zincs]), map_each = _compile_analysis)
41+
if toolchain.zinc_configuration.incremental:
42+
args.add_all(depset(transitive = [zinc.deps for zinc in zincs]), map_each = _compile_analysis)
43+
4244
args.add("--compiler_bridge", toolchain.zinc_configuration.compiler_bridge)
4345
args.add_all("--compiler_classpath", g.classpaths.compiler)
4446
args.add_all("--classpath", g.classpaths.compile)
@@ -69,7 +71,7 @@ def phase_zinc_compile(ctx, g):
6971
g.classpaths.plugin,
7072
g.classpaths.compile,
7173
g.classpaths.compiler,
72-
] + [zinc.deps_files for zinc in zincs],
74+
] + ([zinc.deps_files for zinc in zincs] if toolchain.zinc_configuration.incremental else []),
7375
)
7476

7577
outputs = [

tests/ijar/BUILD.bazel

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@rules_scala_annex//rules:scala.bzl", "scala_library")
2+
3+
scala_library(
4+
name = "dependency",
5+
srcs = [
6+
"Dependency.scala",
7+
"DependencyCacheInvalidation.scala",
8+
],
9+
scala_toolchain_name = "test_zinc_2_13",
10+
)
11+
12+
scala_library(
13+
name = "dependent",
14+
srcs = [
15+
"Dependent.scala",
16+
"DependentCacheInvalidation.scala",
17+
],
18+
scala_toolchain_name = "test_zinc_2_13",
19+
deps = [":dependency"],
20+
)

tests/ijar/Dependency.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package anx.ijar
2+
3+
object Dependency {
4+
def main(args: Array[String]): Unit = {
5+
println("Hello, world!")
6+
}
7+
}

tests/ijar/DependencyCacheInvalidation.scala

Whitespace-only changes.

tests/ijar/Dependent.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package anx.ijar
2+
3+
object Dependent {
4+
def main(args: Array[String]): Unit = Dependency.main(args)
5+
}

tests/ijar/DependentCacheInvalidation.scala

Whitespace-only changes.

tests/ijar/test

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash -e
2+
. "$(dirname "$0")"/../common.sh
3+
4+
invalidate_dependency_cache() {
5+
echo "// $(cat /proc/sys/kernel/random/uuid)" > DependencyCacheInvalidation.scala
6+
}
7+
8+
invalidate_dependent_cache() {
9+
echo "// $(cat /proc/sys/kernel/random/uuid)" > DependentCacheInvalidation.scala
10+
}
11+
12+
test_actions_executed() {
13+
scalacompile_runs="$(
14+
bazel build --color no --subcommands "$1" |& \
15+
grep '^SUBCOMMAND: # //ijar:.* \[.*, mnemonic: ScalaCompile\]$' | \
16+
wc -l
17+
)"
18+
19+
if [ "$scalacompile_runs" -ne "$2" ]; then
20+
echo "Expected 1 \`ScalaCompile\` action to be executed, but got $scalacompile_runs"
21+
exit 1
22+
fi
23+
}
24+
25+
trap ": > DependencyCacheInvalidation.scala; : > DependentCacheInvalidation.scala" EXIT
26+
27+
invalidate_dependency_cache
28+
invalidate_dependent_cache
29+
test_actions_executed //ijar:dependent 2
30+
31+
invalidate_dependency_cache
32+
test_actions_executed //ijar:dependent 1

0 commit comments

Comments
 (0)