diff --git a/rules/private/phases/phase_zinc_compile.bzl b/rules/private/phases/phase_zinc_compile.bzl index a973906b..88cc66c2 100644 --- a/rules/private/phases/phase_zinc_compile.bzl +++ b/rules/private/phases/phase_zinc_compile.bzl @@ -38,7 +38,9 @@ def phase_zinc_compile(ctx, g): common_scalacopts = toolchain.scala_configuration.global_scalacopts + ctx.attr.scalacopts args = ctx.actions.args() - args.add_all(depset(transitive = [zinc.deps for zinc in zincs]), map_each = _compile_analysis) + if toolchain.zinc_configuration.incremental: + args.add_all(depset(transitive = [zinc.deps for zinc in zincs]), map_each = _compile_analysis) + args.add("--compiler_bridge", toolchain.zinc_configuration.compiler_bridge) args.add_all("--compiler_classpath", g.classpaths.compiler) args.add_all("--classpath", g.classpaths.compile) @@ -69,7 +71,7 @@ def phase_zinc_compile(ctx, g): g.classpaths.plugin, g.classpaths.compile, g.classpaths.compiler, - ] + [zinc.deps_files for zinc in zincs], + ] + ([zinc.deps_files for zinc in zincs] if toolchain.zinc_configuration.incremental else []), ) outputs = [ diff --git a/tests/ijar/BUILD.bazel b/tests/ijar/BUILD.bazel new file mode 100644 index 00000000..690b93ed --- /dev/null +++ b/tests/ijar/BUILD.bazel @@ -0,0 +1,14 @@ +load("@rules_scala_annex//rules:scala.bzl", "scala_library") + +scala_library( + name = "dependency", + srcs = ["Dependency.scala", "DependencyCacheInvalidation.scala"], + scala_toolchain_name = "test_zinc_2_13", +) + +scala_library( + name = "dependent", + srcs = ["Dependent.scala", "DependentCacheInvalidation.scala"], + scala_toolchain_name = "test_zinc_2_13", + deps = [":dependency"], +) \ No newline at end of file diff --git a/tests/ijar/Dependency.scala b/tests/ijar/Dependency.scala new file mode 100644 index 00000000..290628e8 --- /dev/null +++ b/tests/ijar/Dependency.scala @@ -0,0 +1,7 @@ +package anx.ijar + +object Dependency { + def main(args: Array[String]): Unit = { + println("Hello, world!") + } +} \ No newline at end of file diff --git a/tests/ijar/DependencyCacheInvalidation.scala b/tests/ijar/DependencyCacheInvalidation.scala new file mode 100644 index 00000000..46ac3498 --- /dev/null +++ b/tests/ijar/DependencyCacheInvalidation.scala @@ -0,0 +1 @@ +// 3598ab64-b0e5-49af-b12b-471f8d2dddc1 diff --git a/tests/ijar/Dependent.scala b/tests/ijar/Dependent.scala new file mode 100644 index 00000000..daec9c38 --- /dev/null +++ b/tests/ijar/Dependent.scala @@ -0,0 +1,6 @@ +package anx.ijar + +//aaaaaaaa +object Dependent { + def main(args: Array[String]): Unit = Dependency.main(args) +} \ No newline at end of file diff --git a/tests/ijar/DependentCacheInvalidation.scala b/tests/ijar/DependentCacheInvalidation.scala new file mode 100644 index 00000000..56b17c9f --- /dev/null +++ b/tests/ijar/DependentCacheInvalidation.scala @@ -0,0 +1 @@ +// 630feaca-0178-4771-864d-18e932b4b10a diff --git a/tests/ijar/test b/tests/ijar/test new file mode 100755 index 00000000..070cc383 --- /dev/null +++ b/tests/ijar/test @@ -0,0 +1,30 @@ +#!/bin/bash -e +. "$(dirname "$0")"/../common.sh + +invalidate_dependency_cache() { + echo "// $(cat /proc/sys/kernel/random/uuid)" > DependencyCacheInvalidation.scala +} + +invalidate_dependent_cache() { + echo "// $(cat /proc/sys/kernel/random/uuid)" > DependentCacheInvalidation.scala +} + +test_actions_executed() { + scalacompile_runs="$( + bazel build --color no --subcommands "$1" |& \ + grep '^SUBCOMMAND: # //ijar:.* \[.*, mnemonic: ScalaCompile\]$' | \ + wc -l + )" + + if [ "$scalacompile_runs" -ne "$2" ]; then + echo "Expected 1 \`ScalaCompile\` action to be executed, but got $scalacompile_runs" + exit 1 + fi +} + +invalidate_dependency_cache +invalidate_dependent_cache +test_actions_executed //ijar:dependent 2 + +invalidate_dependency_cache +test_actions_executed //ijar:dependent 1 \ No newline at end of file