Skip to content

Commit 14736dd

Browse files
Ripped out the remaining Zinc-related code
1 parent f08ffdc commit 14736dd

File tree

10 files changed

+24
-292
lines changed

10 files changed

+24
-292
lines changed

rules/private/phases/phase_test_launcher.bzl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ def phase_test_launcher(ctx, g):
2222
# "When attaching a transition to an outgoing edge (regardless of whether the transition is a
2323
# 1:1 or 1:2+ transition), `ctx.attr` is forced to be a list if it isn't already. The order of
2424
# elements in this list is unspecified."
25-
files = ctx.attr._target_jdk[0][java_common.JavaRuntimeInfo].files.to_list() + [
26-
g.compile.zinc_info.analysis_store,
27-
g.compile.tests_file,
28-
]
25+
files = ctx.attr._target_jdk[0][java_common.JavaRuntimeInfo].files.to_list() + [g.compile.tests_file]
2926

3027
coverage_replacements = {}
3128
coverage_runner_jars = depset(direct = [])
@@ -44,7 +41,6 @@ def phase_test_launcher(ctx, g):
4441
all_jars = [test_jars, runner_jars]
4542

4643
args = ctx.actions.args()
47-
args.add("--analysis_store", g.compile.zinc_info.analysis_store.short_path)
4844
args.add("--tests_file", g.compile.tests_file.short_path)
4945
if ctx.attr.isolation == "classloader":
5046
shared_deps = java_common.merge(_collect(JavaInfo, ctx.attr.shared_deps))

rules/private/phases/phase_zinc_compile.bzl

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ load(
44
"@rules_scala_annex//rules:providers.bzl",
55
_ScalaConfiguration = "ScalaConfiguration",
66
_ZincCompilationInfo = "ZincCompilationInfo",
7-
_ZincConfiguration = "ZincConfiguration",
8-
_ZincDepInfo = "ZincDepInfo",
9-
_ZincInfo = "ZincInfo",
107
)
118

129
#
@@ -17,8 +14,6 @@ load(
1714

1815
def phase_zinc_compile(ctx, g):
1916
toolchain = ctx.toolchains["//rules/scala:toolchain_type"]
20-
analysis_store = ctx.actions.declare_file("{}/analysis_store.gz".format(ctx.label.name))
21-
analysis_store_text = ctx.actions.declare_file("{}/analysis_store.text.gz".format(ctx.label.name))
2217
mains_file = ctx.actions.declare_file("{}.jar.mains.txt".format(ctx.label.name))
2318
used = ctx.actions.declare_file("{}/deps_used.txt".format(ctx.label.name))
2419
tmp = ctx.actions.declare_directory("{}/tmp".format(ctx.label.name))
@@ -34,21 +29,16 @@ def phase_zinc_compile(ctx, g):
3429
)
3530
]
3631

37-
zincs = [dep[_ZincInfo] for dep in ctx.attr.deps if _ZincInfo in dep]
3832
common_scalacopts = toolchain.scala_configuration.global_scalacopts + ctx.attr.scalacopts
3933

4034
args = ctx.actions.args()
41-
if toolchain.zinc_configuration.incremental:
42-
args.add_all(depset(transitive = [zinc.deps for zinc in zincs]), map_each = _compile_analysis)
43-
4435
args.add("--compiler_bridge", toolchain.zinc_configuration.compiler_bridge)
4536
args.add_all("--compiler_classpath", g.classpaths.compiler)
4637
args.add_all("--classpath", g.classpaths.compile)
4738
args.add_all(common_scalacopts, format_each = "--compiler_option=%s")
4839
args.add_all(javacopts, format_each = "--java_compiler_option=%s")
4940
args.add(ctx.label, format = "--label=%s")
5041
args.add("--main_manifest", mains_file)
51-
args.add("--output_analysis_store", analysis_store)
5242
args.add("--output_jar", g.classpaths.jar)
5343
args.add("--output_used", used)
5444
args.add_all("--plugins", g.classpaths.plugin)
@@ -58,29 +48,16 @@ def phase_zinc_compile(ctx, g):
5848

5949
g.semanticdb.arguments_modifier(args)
6050

61-
args.add_all("--", g.classpaths.srcs)
62-
args.set_param_file_format("multiline")
63-
args.use_param_file("@%s", use_always = True)
64-
65-
worker = toolchain.zinc_configuration.compile_worker
66-
6751
inputs = depset(
6852
[toolchain.zinc_configuration.compiler_bridge] + ctx.files.data + ctx.files.srcs,
6953
transitive = [
7054
g.classpaths.plugin,
7155
g.classpaths.compile,
7256
g.classpaths.compiler,
73-
] + ([zinc.deps_files for zinc in zincs] if toolchain.zinc_configuration.incremental else []),
57+
],
7458
)
7559

76-
outputs = [
77-
g.classpaths.jar,
78-
mains_file,
79-
analysis_store,
80-
analysis_store_text,
81-
used,
82-
tmp,
83-
] + g.semanticdb.outputs
60+
outputs = [g.classpaths.jar, mains_file, used, tmp] + g.semanticdb.outputs
8461

8562
if hasattr(ctx.attr, "frameworks"):
8663
tests_file = ctx.actions.declare_file("{}/tests.json".format(ctx.label.name))
@@ -92,6 +69,12 @@ def phase_zinc_compile(ctx, g):
9269
else:
9370
tests_file = None
9471

72+
args.add_all("--", g.classpaths.srcs)
73+
args.set_param_file_format("multiline")
74+
args.use_param_file("@%s", use_always = True)
75+
76+
worker = toolchain.zinc_configuration.compile_worker
77+
9578
execution_requirements_tags = {
9679
"supports-multiplex-workers": "1",
9780
"supports-workers": "1",
@@ -100,16 +83,6 @@ def phase_zinc_compile(ctx, g):
10083
"supports-path-mapping": "1",
10184
}
10285

103-
# Disable several things if incremental compilation features are going to be used
104-
# because incremental compilation require stashing files outside the sandbox that
105-
# Bazel isn't aware of and is less deterministic than ideal.
106-
if toolchain.zinc_configuration.incremental:
107-
execution_requirements_tags["no-sandbox"] = "1"
108-
execution_requirements_tags["no-cache"] = "1"
109-
execution_requirements_tags["no-remote"] = "1"
110-
execution_requirements_tags["supports-multiplex-sandboxing"] = "0"
111-
execution_requirements_tags["supports-path-mapping"] = "0"
112-
11386
# todo: different execution path for nosrc jar?
11487
ctx.actions.run(
11588
arguments = [args],
@@ -126,32 +99,9 @@ def phase_zinc_compile(ctx, g):
12699
for jar in g.javainfo.java_info.outputs.jars:
127100
jars.append(jar.class_jar)
128101
jars.append(jar.ijar)
129-
zinc_info = _ZincInfo(
130-
analysis_store = analysis_store,
131-
deps_files = depset([analysis_store], transitive = [zinc.deps_files for zinc in zincs]),
132-
label = ctx.label,
133-
deps = depset(
134-
[_ZincDepInfo(
135-
analysis_store = analysis_store,
136-
jars = tuple(jars),
137-
label = ctx.label,
138-
)],
139-
transitive = [zinc.deps for zinc in zincs],
140-
),
141-
)
142102

143-
g.out.providers.append(zinc_info)
144103
return _ZincCompilationInfo(
145104
mains_file = mains_file,
146105
tests_file = tests_file,
147106
used = used,
148-
# todo: see about cleaning up & generalizing fields below
149-
zinc_info = zinc_info,
150107
)
151-
152-
def _compile_analysis(analysis):
153-
return [
154-
"--analysis",
155-
"_{}".format(analysis.label),
156-
analysis.analysis_store.path,
157-
] + [jar.path for jar in analysis.jars]

rules/providers.bzl

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ ZincConfiguration = provider(
2525
"compiler_bridge": "compiled Zinc compiler bridge",
2626
"compile_worker": "the worker label for compilation with Zinc",
2727
"log_level": "log level for the Zinc compiler",
28-
"incremental": "whether incremental compilation will be available for this Zinc compiler",
2928
},
3029
)
3130

@@ -52,16 +51,6 @@ ScalaRulePhase = provider(
5251
},
5352
)
5453

55-
ZincInfo = provider(
56-
doc = "Zinc-specific outputs.",
57-
fields = {
58-
"analysis_store": "The analysis store file.",
59-
"deps": "The depset of library dependency outputs.",
60-
"deps_files": "The depset of all Zinc files.",
61-
"label": "The label for this output.",
62-
},
63-
)
64-
6554
# TODO: move these to another file?
6655
# TODO: implement these with an aspect?
6756

@@ -185,15 +174,5 @@ ZincCompilationInfo = provider(
185174
"mains_file": "File containing the main methods of this compilation.",
186175
"tests_file": "File containing discovered tests for use by the test runner. Will be `None` if this isn't a test target.",
187176
"used": "File containing the used deps for this compilation.",
188-
"zinc_info": "a ZincInfo provider for this compilation.",
189-
},
190-
)
191-
192-
ZincDepInfo = provider(
193-
doc = "Information for a dep in a ZincInfo",
194-
fields = {
195-
"analysis_store": "Analysis store for this label",
196-
"jars": "Jars for this label",
197-
"label": "The label for this dep",
198177
},
199178
)

rules/register_toolchain.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def _zinc_configuration_impl(ctx):
9090
zinc_configuration = ZincConfiguration(
9191
compile_worker = ctx.attr._compile_worker,
9292
compiler_bridge = ctx.file.compiler_bridge,
93-
incremental = ctx.attr.incremental,
9493
log_level = ctx.attr.log_level,
9594
),
9695
deps_configuration = DepsConfiguration(
@@ -135,7 +134,6 @@ off: Don't perform unused dependency checking.""",
135134
),
136135
"global_plugins": attr.label_list(providers = [JavaInfo]),
137136
"global_scalacopts": attr.string_list(),
138-
"incremental": attr.bool(default = False),
139137
"log_level": attr.string(
140138
default = "warn",
141139
values = ["error", "warn", "info", "debug", "none"],

src/main/scala/higherkindness/rules_scala/workers/common/AnalysisUtil.scala

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/main/scala/higherkindness/rules_scala/workers/common/AnnexMapper.scala

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package higherkindness.rules_scala.workers.common
22

33
import com.google.devtools.build.buildjar.jarhelper.JarHelper
44
import java.nio.file.{Path, Paths}
5-
import sbt.internal.inc.{FarmHash, Hash, LastModified, PlainVirtualFile, PlainVirtualFileConverter, Stamper}
5+
import sbt.internal.inc.{FarmHash, Hash, LastModified, PlainVirtualFile, PlainVirtualFileConverter}
66
import xsbti.VirtualFileRef
77
import xsbti.compile.MiniSetup
88
import xsbti.compile.analysis.{ReadMapper, ReadWriteMappers, Stamp, WriteMapper}
99

1010
object AnnexMapper {
1111
val rootPlaceholder = Paths.get("_ROOT_")
12-
def mappers(root: Path, isIncremental: Boolean) = {
13-
new ReadWriteMappers(new AnxReadMapper(root, isIncremental), new AnxWriteMapper(root))
12+
def mappers(root: Path) = {
13+
new ReadWriteMappers(new AnxReadMapper(root), new AnxWriteMapper(root))
1414
}
1515

1616
/**
@@ -27,31 +27,6 @@ object AnnexMapper {
2727
case _ => throw new Exception(s"Unexpected Stamp type encountered when writing. ${stamp.getClass} -- $stamp")
2828
}
2929
}
30-
31-
final def getReadStamp(file: VirtualFileRef, stamp: Stamp, isIncremental: Boolean): Stamp = {
32-
if (isIncremental) {
33-
getIncrementalModeReadStamp(file, stamp)
34-
} else {
35-
stamp
36-
}
37-
}
38-
39-
/**
40-
* When in incremental mode we do not want to rely on the timestamp from the AnalysisStore because we're assuming it
41-
* was set to a constant value when written to the AnalysisStore.
42-
*
43-
* Instead, for any LastModified stamps, we read the file's time stamp from disk.
44-
*/
45-
final def getIncrementalModeReadStamp(file: VirtualFileRef, stamp: Stamp): Stamp = {
46-
stamp match {
47-
case farmHash: FarmHash => farmHash
48-
case hash: Hash => hash
49-
case lastModified: LastModified => {
50-
Stamper.forLastModifiedP(PlainVirtualFileConverter.converter.toPath(file))
51-
}
52-
case _ => throw new Exception(s"Unexpected Stamp type encountered when reading ${stamp.getClass} -- $stamp")
53-
}
54-
}
5530
}
5631

5732
final class AnxWriteMapper(root: Path) extends WriteMapper {
@@ -93,7 +68,7 @@ final class AnxWriteMapper(root: Path) extends WriteMapper {
9368
override def mapMiniSetup(miniSetup: MiniSetup): MiniSetup = miniSetup
9469
}
9570

96-
final class AnxReadMapper(root: Path, isIncremental: Boolean) extends ReadMapper {
71+
final class AnxReadMapper(root: Path) extends ReadMapper {
9772
private val rootAbs = root.toAbsolutePath().normalize()
9873

9974
private def mapFile(virtualFileRef: VirtualFileRef): Path = {
@@ -119,15 +94,9 @@ final class AnxReadMapper(root: Path, isIncremental: Boolean) extends ReadMapper
11994
override def mapOutputDir(outputDir: Path): Path = mapFile(outputDir)
12095
override def mapSourceDir(sourceDir: Path): Path = mapFile(sourceDir)
12196

122-
override def mapSourceStamp(file: VirtualFileRef, sourceStamp: Stamp): Stamp = {
123-
AnnexMapper.getReadStamp(file, sourceStamp, isIncremental)
124-
}
125-
override def mapBinaryStamp(file: VirtualFileRef, binaryStamp: Stamp): Stamp = {
126-
AnnexMapper.getReadStamp(file, binaryStamp, isIncremental)
127-
}
128-
override def mapProductStamp(file: VirtualFileRef, productStamp: Stamp): Stamp = {
129-
AnnexMapper.getReadStamp(file, productStamp, isIncremental)
130-
}
97+
override def mapSourceStamp(file: VirtualFileRef, sourceStamp: Stamp): Stamp = sourceStamp
98+
override def mapBinaryStamp(file: VirtualFileRef, binaryStamp: Stamp): Stamp = binaryStamp
99+
override def mapProductStamp(file: VirtualFileRef, productStamp: Stamp): Stamp = productStamp
131100

132101
override def mapMiniSetup(miniSetup: MiniSetup): MiniSetup = miniSetup
133102
}

0 commit comments

Comments
 (0)