From 79ff6bebf02fce50b187e7e85db4180e05cd00f4 Mon Sep 17 00:00:00 2001 From: jjudd Date: Mon, 7 Oct 2024 22:56:15 -0600 Subject: [PATCH 01/17] Update jarhelper --- .../build/buildjar/jarhelper/JarCreator.java | 25 +------------------ .../build/buildjar/jarhelper/JarHelper.java | 5 ++-- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarCreator.java b/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarCreator.java index b0bcb2bb4..848165da2 100644 --- a/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarCreator.java +++ b/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarCreator.java @@ -16,7 +16,6 @@ import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; @@ -27,7 +26,6 @@ import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; -import java.util.Collection; import java.util.Map; import java.util.TreeMap; import java.util.jar.Attributes; @@ -98,12 +96,6 @@ public void addDirectory(String directory) { addDirectory(Paths.get(directory)); } - /** @deprecated prefer {@link #addDirectory(Path)} */ - @Deprecated - public void addDirectory(File directory) { - addDirectory(directory.toPath()); - } - /** * Adds the contents of a directory to the Jar file. All files below this directory will be added * to the Jar file using the name relative to the directory as the name for the Jar entry. @@ -159,21 +151,6 @@ void addEntry(Path path, boolean isDirectory) { } } - /** - * Adds a collection of entries to the jar, each with a given source path, and with the resulting - * file in the root of the jar. - * - *
-   * some/long/path.foo => (path.foo, some/long/path.foo)
-   * 
- */ - public void addRootEntries(Collection entries) { - for (String entry : entries) { - Path path = Paths.get(entry); - jarEntries.put(path.getFileName().toString(), path); - } - } - /** * Sets the main.class entry for the manifest. A value of null (the default) will * omit the entry. @@ -273,4 +250,4 @@ public static void main(String[] args) { long stop = System.currentTimeMillis(); System.err.println((stop - start) + "ms."); } -} +} \ No newline at end of file diff --git a/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarHelper.java b/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarHelper.java index 18840bb1a..96a50667a 100644 --- a/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarHelper.java +++ b/third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper/JarHelper.java @@ -39,7 +39,6 @@ public class JarHelper { public static final String MANIFEST_DIR = "META-INF/"; public static final String MANIFEST_NAME = JarFile.MANIFEST_NAME; - public static final String SERVICES_DIR = "META-INF/services/"; /** * Normalize timestamps to 2010-1-1. @@ -199,7 +198,7 @@ protected void writeManifestEntry(JarOutputStream out, byte[] content) throws IO protected void copyEntry(JarOutputStream out, String name, Path path) throws IOException { if (!names.contains(name)) { if (!Files.exists(path)) { - throw new FileNotFoundException(path.toAbsolutePath().normalize() + " (No such file or directory)"); + throw new FileNotFoundException(path.toAbsolutePath() + " (No such file or directory)"); } boolean isDirectory = Files.isDirectory(path); if (isDirectory && !name.endsWith("/")) { @@ -242,4 +241,4 @@ protected void copyEntry(JarOutputStream out, String name, Path path) throws IOE } } } -} +} \ No newline at end of file From e81885b8296fcecdea3a8af83813f0fc32b4119c Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 10 Oct 2024 18:24:54 -0600 Subject: [PATCH 02/17] Update deps in WORKSPACE and reorder them to avoid issues with path mapping Path mapping requires a custom Java toolchain where javac_supports_worker_multiplex_sandboxing is set to True. There was an issue where rules_jvm_external came before rules_java in the WORKSPACE and it called the default rules_java toolchain setup functions, preventing our custom toolchain from being used correctly. This in turn broke path mapping. --- WORKSPACE | 100 +++++++++++++++++++++++++++--------------------- tests/WORKSPACE | 29 +++++++++----- 2 files changed, 76 insertions(+), 53 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index a46ccf3c1..6630c2613 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,6 +2,18 @@ workspace(name = "rules_scala_annex") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +# rules_license +rules_license_tag = "1.0.0" + +http_archive( + name = "rules_license", + sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/{tag}/rules_license-{tag}.tar.gz".format(tag = rules_license_tag), + "https://github.com/bazelbuild/rules_license/releases/download/{tag}/rules_license-{tag}.tar.gz".format(tag = rules_license_tag), + ], +) + # skylib bazel_skylib_tag = "1.7.1" @@ -21,11 +33,26 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() +# rules_java +http_archive( + name = "rules_java", + sha256 = "a9690bc00c538246880d5c83c233e4deb83fe885f54c21bb445eb8116a180b83", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/7.12.2/rules_java-7.12.2.tar.gz", + ], +) + +load("@rules_java//java:repositories.bzl", "rules_java_dependencies") + +rules_java_dependencies() + +register_toolchains("//:repository_default_toolchain_21_definition") + # com_github_bazelbuild_buildtools -buildtools_tag = "7.1.2" +buildtools_tag = "7.3.1" -buildtools_sha256 = "4c63e823e6944c950401f92155416c631a65657dd32e1021451fc015faf22ecb" +buildtools_sha256 = "118602587d5804c720c1617db30f56c93ec7a2bdda5e915125fccf7421e78412" http_archive( name = "com_github_bazelbuild_buildtools", @@ -47,48 +74,12 @@ http_archive( urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"], ) -# io_bazel_rules_go - -rules_go_tag = "v0.43.0" - -rules_go_sha256 = "8e968b5fcea1d2d64071872b12737bbb5514524ee5f0a4f54f5920266c261acb" - -http_archive( - name = "io_bazel_rules_go", - integrity = "sha256-1qtrV+SMCVI+kwUPE2mPcIQoz9XmGSUuNp03evZZdwc=", - urls = [ - "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/{tag}/rules_go-{tag}.zip".format(tag = rules_go_tag), - "https://github.com/bazelbuild/rules_go/releases/download/{tag}/rules_go-{tag}.zip".format(tag = rules_go_tag), - ], -) - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") - -go_rules_dependencies() - -go_register_toolchains(version = "1.17") - -# rules_java -http_archive( - name = "rules_java", - sha256 = "a9690bc00c538246880d5c83c233e4deb83fe885f54c21bb445eb8116a180b83", - urls = [ - "https://github.com/bazelbuild/rules_java/releases/download/7.12.2/rules_java-7.12.2.tar.gz", - ], -) - -load("@rules_java//java:repositories.bzl", "rules_java_dependencies") - -rules_java_dependencies() - -register_toolchains("//:repository_default_toolchain_21_definition") - # rules_jvm_external -rules_jvm_external_tag = "6.1" +rules_jvm_external_tag = "6.5" http_archive( name = "rules_jvm_external", - sha256 = "42a6d48eb2c08089961c715a813304f30dc434df48e371ebdd868fc3636f0e82", + sha256 = "c5b27928eeb8f0761f0805540587660f0ecc6946e9c04bf0d4c89e2f7d332b2b", strip_prefix = "rules_jvm_external-{}".format(rules_jvm_external_tag), url = "https://github.com/bazelbuild/rules_jvm_external/archive/{}.zip".format(rules_jvm_external_tag), ) @@ -185,6 +176,27 @@ load("@rules_proto//proto:setup.bzl", "rules_proto_setup") rules_proto_setup() +# rules_go + +rules_go_tag = "v0.43.0" + +rules_go_sha256 = "d6ab6b57e48c09523e93050f13698f708428cfd5e619252e369d377af6597707" + +http_archive( + name = "io_bazel_rules_go", + sha256 = rules_go_sha256, + urls = [ + "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/{tag}/rules_go-{tag}.zip".format(tag = rules_go_tag), + "https://github.com/bazelbuild/rules_go/releases/download/{tag}/rules_go-{tag}.zip".format(tag = rules_go_tag), + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +go_rules_dependencies() + +go_register_toolchains(version = "1.17") + # Stardoc http_archive( @@ -210,11 +222,11 @@ stardoc_pinned_maven_install() # rules_pkg -rules_pkg_version = "1.0.0" +rules_pkg_version = "1.0.1" http_archive( name = "rules_pkg", - sha256 = "cad05f864a32799f6f9022891de91ac78f30e0fa07dc68abac92a628121b5b11", + sha256 = "d20c951960ed77cb7b341c2a59488534e494d5ad1d30c4818c736d57772a9fef", urls = [ "https://github.com/bazelbuild/rules_pkg/releases/download/{v}/rules_pkg-{v}.tar.gz".format(v = rules_pkg_version), ], @@ -225,11 +237,11 @@ load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") rules_pkg_dependencies() # rules_python - this is needed by rules_jvm_external for some reason -rules_python_tag = "0.33.2" +rules_python_tag = "0.36.0" http_archive( name = "rules_python", - sha256 = "e3f1cc7a04d9b09635afb3130731ed82b5f58eadc8233d4efb59944d92ffc06f", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", strip_prefix = "rules_python-{}".format(rules_python_tag), url = "https://github.com/bazelbuild/rules_python/releases/download/{}/rules_python-{}.tar.gz".format(rules_python_tag, rules_python_tag), ) diff --git a/tests/WORKSPACE b/tests/WORKSPACE index df74abdbc..8f03ca2e9 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -3,6 +3,17 @@ workspace(name = "rules_scala_annex_test") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") +rules_license_tag = "1.0.0" + +http_archive( + name = "rules_license", + sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/{tag}/rules_license-{tag}.tar.gz".format(tag = rules_license_tag), + "https://github.com/bazelbuild/rules_license/releases/download/{tag}/rules_license-{tag}.tar.gz".format(tag = rules_license_tag), + ], +) + # skylib bazel_skylib_tag = "1.7.1" @@ -37,17 +48,12 @@ rules_java_dependencies() register_toolchains("//:repository_default_toolchain_21_definition") -local_repository( - name = "rules_scala_annex", - path = "../", -) - # rules_jvm_external -rules_jvm_external_tag = "6.1" +rules_jvm_external_tag = "6.5" http_archive( name = "rules_jvm_external", - sha256 = "42a6d48eb2c08089961c715a813304f30dc434df48e371ebdd868fc3636f0e82", + sha256 = "c5b27928eeb8f0761f0805540587660f0ecc6946e9c04bf0d4c89e2f7d332b2b", strip_prefix = "rules_jvm_external-{}".format(rules_jvm_external_tag), url = "https://github.com/bazelbuild/rules_jvm_external/archive/{}.zip".format(rules_jvm_external_tag), ) @@ -60,6 +66,11 @@ load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") rules_jvm_external_setup() +local_repository( + name = "rules_scala_annex", + path = "../", +) + load( "@rules_scala_annex//rules/scala:workspace.bzl", "scala_register_toolchains", @@ -218,11 +229,11 @@ http_file( ) # rules_python - this is needed by rules_jvm_external for some reason -rules_python_tag = "0.33.2" +rules_python_tag = "0.36.0" http_archive( name = "rules_python", - sha256 = "e3f1cc7a04d9b09635afb3130731ed82b5f58eadc8233d4efb59944d92ffc06f", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", strip_prefix = "rules_python-{}".format(rules_python_tag), url = "https://github.com/bazelbuild/rules_python/releases/download/{}/rules_python-{}.tar.gz".format(rules_python_tag, rules_python_tag), ) From 53da6cbaee4e9e41d9df537eceb66dcdaec6b03b Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 10 Oct 2024 18:08:51 -0600 Subject: [PATCH 03/17] Misc cleanup --- rules/private/phases/phase_coverage_jacoco.bzl | 7 +++---- rules/private/phases/phase_zinc_compile.bzl | 7 +++---- rules/private/phases/phase_zinc_depscheck.bzl | 7 +++---- rules/scala/private/doc.bzl | 5 ++--- rules/scala_proto/private/core.bzl | 5 ++--- rules/scalafmt/private/test.bzl | 3 +-- .../higherkindness/rules_scala/common/sbt-testing/BUILD | 3 --- tests/.bazelrc | 5 ----- 8 files changed, 14 insertions(+), 28 deletions(-) diff --git a/rules/private/phases/phase_coverage_jacoco.bzl b/rules/private/phases/phase_coverage_jacoco.bzl index 4fa4c86d5..11dc8ecd7 100644 --- a/rules/private/phases/phase_coverage_jacoco.bzl +++ b/rules/private/phases/phase_coverage_jacoco.bzl @@ -16,7 +16,7 @@ def phase_coverage_jacoco(ctx, g): return toolchain = ctx.toolchains["//rules/scala:toolchain_type"] - worker_inputs, _, worker_input_manifests = ctx.resolve_command( + worker_inputs, _ = ctx.resolve_tools( tools = [toolchain.code_coverage_configuration.instrumentation_worker], ) @@ -35,10 +35,9 @@ def phase_coverage_jacoco(ctx, g): args.use_param_file("@%s", use_always = True) ctx.actions.run( mnemonic = "JacocoInstrumenter", - inputs = [in_out_pair[0] for in_out_pair in in_out_pairs] + worker_inputs, + inputs = [in_out_pair[0] for in_out_pair in in_out_pairs] + worker_inputs.to_list(), outputs = [in_out_pair[1] for in_out_pair in in_out_pairs], - executable = toolchain.code_coverage_configuration.instrumentation_worker.files_to_run.executable, - input_manifests = worker_input_manifests, + executable = toolchain.code_coverage_configuration.instrumentation_worker.files_to_run, execution_requirements = _resolve_execution_reqs( ctx, { diff --git a/rules/private/phases/phase_zinc_compile.bzl b/rules/private/phases/phase_zinc_compile.bzl index fdb6bc1ba..2d6e45204 100644 --- a/rules/private/phases/phase_zinc_compile.bzl +++ b/rules/private/phases/phase_zinc_compile.bzl @@ -63,9 +63,9 @@ def phase_zinc_compile(ctx, g): worker = toolchain.zinc_configuration.compile_worker - worker_inputs, _, input_manifests = ctx.resolve_command(tools = [worker]) + worker_inputs, _ = ctx.resolve_tools(tools = [worker]) inputs = depset( - [toolchain.zinc_configuration.compiler_bridge] + ctx.files.data + ctx.files.srcs + worker_inputs, + [toolchain.zinc_configuration.compiler_bridge] + ctx.files.data + ctx.files.srcs + worker_inputs.to_list(), transitive = [ g.classpaths.plugin, g.classpaths.compile, @@ -103,8 +103,7 @@ def phase_zinc_compile(ctx, g): mnemonic = "ScalaCompile", inputs = inputs, outputs = outputs, - executable = worker.files_to_run.executable, - input_manifests = input_manifests, + executable = worker.files_to_run, execution_requirements = _resolve_execution_reqs( ctx, execution_requirements_tags, diff --git a/rules/private/phases/phase_zinc_depscheck.bzl b/rules/private/phases/phase_zinc_depscheck.bzl index e11660cb1..76d9d989f 100644 --- a/rules/private/phases/phase_zinc_depscheck.bzl +++ b/rules/private/phases/phase_zinc_depscheck.bzl @@ -18,7 +18,7 @@ load( def phase_zinc_depscheck(ctx, g): deps_configuration = ctx.toolchains["//rules/scala:toolchain_type"].deps_configuration labeled_jar_groups = depset(transitive = [dep[_LabeledJars].values for dep in ctx.attr.deps]) - worker_inputs, _, worker_input_manifests = ctx.resolve_command(tools = [deps_configuration.worker]) + worker_inputs, _ = ctx.resolve_tools(tools = [deps_configuration.worker]) outputs = [] for name in ("direct", "used"): @@ -42,10 +42,9 @@ def phase_zinc_depscheck(ctx, g): deps_args.use_param_file("@%s", use_always = True) ctx.actions.run( mnemonic = "ScalaCheckDeps", - inputs = [g.compile.used] + worker_inputs, + inputs = [g.compile.used] + worker_inputs.to_list(), outputs = [deps_check], - executable = deps_configuration.worker.files_to_run.executable, - input_manifests = worker_input_manifests, + executable = deps_configuration.worker.files_to_run, execution_requirements = _resolve_execution_reqs( ctx, { diff --git a/rules/scala/private/doc.bzl b/rules/scala/private/doc.bzl index c7f26860d..c50669679 100644 --- a/rules/scala/private/doc.bzl +++ b/rules/scala/private/doc.bzl @@ -55,11 +55,11 @@ def scaladoc_implementation(ctx): args.set_param_file_format("multiline") args.use_param_file("@%s", use_always = True) - runner_inputs, _, input_manifests = ctx.resolve_command(tools = [ctx.attr._runner]) + runner_inputs, _ = ctx.resolve_tools(tools = [ctx.attr._runner]) ctx.actions.run( arguments = [args], - executable = ctx.attr._runner.files_to_run.executable, + executable = ctx.attr._runner.files_to_run, execution_requirements = _resolve_execution_reqs( ctx, { @@ -69,7 +69,6 @@ def scaladoc_implementation(ctx): "supports-worker-cancellation": "1", }, ), - input_manifests = input_manifests, inputs = depset( src_jars + srcs + [toolchain.zinc_configuration.compiler_bridge], transitive = [classpath, compiler_classpath], diff --git a/rules/scala_proto/private/core.bzl b/rules/scala_proto/private/core.bzl index 4c248b414..b8a8cacb3 100644 --- a/rules/scala_proto/private/core.bzl +++ b/rules/scala_proto/private/core.bzl @@ -18,7 +18,7 @@ def scala_proto_library_implementation(ctx): compiler = ctx.toolchains["@rules_scala_annex//rules/scala_proto:compiler_toolchain_type"] - compiler_inputs, _, input_manifests = ctx.resolve_command(tools = [compiler.compiler]) + compiler_inputs, _ = ctx.resolve_tools(tools = [compiler.compiler]) srcjar = ctx.outputs.srcjar @@ -45,9 +45,8 @@ def scala_proto_library_implementation(ctx): mnemonic = "ScalaProtoCompile", inputs = depset(direct = [], transitive = [transitive_sources]), outputs = [gendir], - executable = compiler.compiler.files_to_run.executable, + executable = compiler.compiler.files_to_run, tools = compiler_inputs, - input_manifests = input_manifests, progress_message = "Compiling %{label} protobuf into Scala source", execution_requirements = _resolve_execution_reqs( ctx, diff --git a/rules/scalafmt/private/test.bzl b/rules/scalafmt/private/test.bzl index f05aa69a4..10f2d9b9c 100644 --- a/rules/scalafmt/private/test.bzl +++ b/rules/scalafmt/private/test.bzl @@ -33,7 +33,7 @@ scala_non_default_format_attributes = { def build_format(ctx): files = [] - runner_inputs, _, runner_manifests = ctx.resolve_command(tools = [ctx.attr._fmt]) + runner_inputs, _ = ctx.resolve_tools(tools = [ctx.attr._fmt]) manifest_content = [] for src in ctx.files.srcs: if src.path.endswith(".scala") and src.is_source: @@ -50,7 +50,6 @@ def build_format(ctx): arguments = ["--jvm_flag=-Dfile.encoding=UTF-8", args], executable = ctx.executable._fmt, outputs = [file], - input_manifests = runner_manifests, inputs = [ctx.file.config, src], tools = runner_inputs, execution_requirements = _resolve_execution_reqs( diff --git a/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD b/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD index a460ba065..824e6b178 100644 --- a/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD @@ -24,9 +24,6 @@ scala_library( scala_library( name = "common", srcs = _common_srcs, - deps_used_whitelist = [ - "@annex//:org_scala_lang_scala_library", - ], scala_toolchain_name = "zinc_2_13", visibility = ["//visibility:public"], deps = [ diff --git a/tests/.bazelrc b/tests/.bazelrc index a0dd9087c..f90fae440 100644 --- a/tests/.bazelrc +++ b/tests/.bazelrc @@ -1,8 +1,3 @@ common --config=tests -build --java_language_version="21" -build --java_runtime_version="remotejdk_21" -build --tool_java_language_version="21" -build --tool_java_runtime_version="remotejdk_21" - import %workspace%/../.bazelrc_shared From f3585fc6dae93f05ce057c6f050b75cb36e9960d Mon Sep 17 00:00:00 2001 From: jjudd Date: Fri, 11 Oct 2024 00:16:58 -0600 Subject: [PATCH 04/17] Compare short paths in deps checker to avoid false positives from different configurations Currently we compare the absolute path in the deps checker. This causes us problems when there are configuration specific parts of one input and not the other. This happens when there we've written a configuration specific part of a path to disk and are comparing it to a path mapped argument. I imagine this is not the only place we'll run into issues with this. --- rules/private/phases/phase_zinc_depscheck.bzl | 6 ++++- .../rules_scala/workers/deps/DepsRunner.scala | 25 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/rules/private/phases/phase_zinc_depscheck.bzl b/rules/private/phases/phase_zinc_depscheck.bzl index 76d9d989f..89e88c3c1 100644 --- a/rules/private/phases/phase_zinc_depscheck.bzl +++ b/rules/private/phases/phase_zinc_depscheck.bzl @@ -6,6 +6,7 @@ load( load( "@rules_scala_annex//rules/common:private/utils.bzl", _resolve_execution_reqs = "resolve_execution_reqs", + _short_path = "short_path", ) # @@ -75,4 +76,7 @@ def phase_zinc_depscheck(ctx, g): def _add_args_for_depscheck_labeled_group(labeled_jar_group, deps_args): deps_args.add("--group") deps_args.add(labeled_jar_group.label, format = "_%s") - deps_args.add_all(labeled_jar_group.jars) + + # We do want to use map_each on the jar paths as we don't want the configuration specific + # fragments of those paths. + deps_args.add_all(labeled_jar_group.jars, map_each = _short_path) diff --git a/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala b/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala index 284d13484..eaf8071aa 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala +++ b/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala @@ -62,16 +62,14 @@ object DepsRunner extends WorkerMain[Unit] { private[this] class Group private ( val label: String, - val jars: Set[Path], + val jars: Set[String], ) private[this] object Group { def apply(workDir: Path, prependedLabel: String, jars: Seq[String]): Group = { new Group( prependedLabel.tail, - jars.view.map { jar => - SandboxUtil.getSandboxPath(workDir, Paths.get(jar)) - }.toSet, + jars.toSet, ) } } @@ -117,8 +115,7 @@ object DepsRunner extends WorkerMain[Unit] { InterruptUtil.throwIfInterrupted() val groupLabelToJarPaths = workRequest.groups.map { group => - // Use absolute path because the read mapper uses absolute path. - group.label -> group.jars.map(_.toAbsolutePath().normalize().toString()) + group.label -> group.jars }.toMap def pathsForLabel(depLabel: String): List[String] = { // A label could have no @ prefix, a single @ prefix, or a double @@ prefix. @@ -143,12 +140,22 @@ object DepsRunner extends WorkerMain[Unit] { .readAllLines(workRequest.usedDepsFile) .asScala .view - // Use the read mapper on the used classpath entries in order to keep - // comparisons consistent. + // Get the short path, so we can compare paths without the Bazel configuration sensitive + // parts of the path. We can handle the Zinc machine sensitive parts of the path with the + // AnnexMapper, but we don't have an equivalent for the Bazel configuration sensitive parts. + // So we just toss both out and compare the short path. + // Note that this is dependent upon the Bazel file output structure not changing. .map { usedDep => - readMapper.mapClasspathEntry(Paths.get(usedDep)).toString + FileUtil + .bazelShortPath( + Paths.get( + usedDep.stripPrefix(AnnexMapper.rootPlaceholder.toString() + "/"), + ), + ) + .toString() } .toSet + val labelsToRemove = if (workRequest.checkUsed) { workRequest.directDepLabels .diff(workRequest.usedDepWhitelist) From d04b0cc85bdc7d7539ab2c79f6599f955c313e0e Mon Sep 17 00:00:00 2001 From: jjudd Date: Fri, 11 Oct 2024 04:08:59 -0600 Subject: [PATCH 05/17] Update to exec cfg instead of host --- rules/register_toolchain.bzl | 6 +++--- rules/scala.bzl | 14 +++++++------- rules/scala/private/doc.bzl | 2 +- rules/scala/private/import.bzl | 2 +- rules/scala_proto.bzl | 4 ++-- rules/scalafmt/private/test.bzl | 2 +- .../worker-verbosity/verbosity_spec_worker_run.bzl | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/rules/register_toolchain.bzl b/rules/register_toolchain.bzl index 53f09e387..1b5d7d1a8 100644 --- a/rules/register_toolchain.bzl +++ b/rules/register_toolchain.bzl @@ -149,19 +149,19 @@ off: Don't perform unused dependency checking.""", default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/workers/jacoco/instrumenter", allow_files = True, executable = True, - cfg = "host", + cfg = "exec", ), "_compile_worker": attr.label( default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/workers/zinc/compile", allow_files = True, executable = True, - cfg = "host", + cfg = "exec", ), "_deps_worker": attr.label( default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/workers/deps", allow_files = True, executable = True, - cfg = "host", + cfg = "exec", ), }, implementation = _zinc_configuration_impl, diff --git a/rules/scala.bzl b/rules/scala.bzl index 8816d4b78..e0e5719a1 100644 --- a/rules/scala.bzl +++ b/rules/scala.bzl @@ -55,10 +55,10 @@ _compile_private_attributes = { ), "_host_javabase": attr.label( default = Label("@bazel_tools//tools/jdk:current_java_runtime"), - cfg = "host", + cfg = "exec", ), "_singlejar": attr.label( - cfg = "host", + cfg = "exec", default = "@bazel_tools//tools/jdk:singlejar", executable = True, ), @@ -68,12 +68,12 @@ _compile_private_attributes = { "_jdk": attr.label( default = Label("@bazel_tools//tools/jdk:current_java_runtime"), providers = [java_common.JavaRuntimeInfo], - cfg = "host", + cfg = "exec", ), "_jar_creator": attr.label( default = Label("@rules_scala_annex//third_party/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper:jarcreator_bin"), executable = True, - cfg = "host", + cfg = "exec", ), } @@ -193,11 +193,11 @@ _testing_private_attributes = { # in https://github.com/bazelbuild/bazel/blob/0.22.0/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaTestRule.java#L69-L76 "_jacocorunner": attr.label( default = Label("@bazel_tools//tools/jdk:JacocoCoverage"), - cfg = "host", + cfg = "exec", ), "_lcov_merger": attr.label( default = Label("@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main"), - cfg = "host", + cfg = "exec", ), } @@ -408,7 +408,7 @@ _scala_repl_private_attributes = _dicts.add( _runtime_private_attributes, { "_runner": attr.label( - cfg = "host", + cfg = "exec", executable = True, default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/workers/zinc/repl", ), diff --git a/rules/scala/private/doc.bzl b/rules/scala/private/doc.bzl index c50669679..a7508fbbf 100644 --- a/rules/scala/private/doc.bzl +++ b/rules/scala/private/doc.bzl @@ -11,7 +11,7 @@ load( scaladoc_private_attributes = { "_runner": attr.label( - cfg = "host", + cfg = "exec", executable = True, default = "//src/main/scala/higherkindness/rules_scala/workers/zinc/doc", ), diff --git a/rules/scala/private/import.bzl b/rules/scala/private/import.bzl index c80abc259..762570b83 100644 --- a/rules/scala/private/import.bzl +++ b/rules/scala/private/import.bzl @@ -7,7 +7,7 @@ scala_import_private_attributes = { ), "_host_javabase": attr.label( default = Label("@bazel_tools//tools/jdk:current_java_runtime"), - cfg = "host", + cfg = "exec", ), } diff --git a/rules/scala_proto.bzl b/rules/scala_proto.bzl index 20a084913..bc396cadd 100644 --- a/rules/scala_proto.bzl +++ b/rules/scala_proto.bzl @@ -13,7 +13,7 @@ scala_proto_library = rule( doc = "The proto_library targets you wish to generate Scala from", ), "grpc": attr.bool(), - "_zipper": attr.label(cfg = "host", default = "@bazel_tools//tools/zip:zipper", executable = True), + "_zipper": attr.label(cfg = "exec", default = "@bazel_tools//tools/zip:zipper", executable = True), }, ), doc = """ @@ -42,7 +42,7 @@ scala_proto_toolchain = rule( doc = "The compiler to use to generate Scala form proto sources", allow_files = True, executable = True, - cfg = "host", + cfg = "exec", ), "compiler_supports_workers": attr.bool(default = False), }, diff --git a/rules/scalafmt/private/test.bzl b/rules/scalafmt/private/test.bzl index 10f2d9b9c..a29efdcd4 100644 --- a/rules/scalafmt/private/test.bzl +++ b/rules/scalafmt/private/test.bzl @@ -10,7 +10,7 @@ scala_format_attributes = { doc = "The Scalafmt configuration file.", ), "_fmt": attr.label( - cfg = "host", + cfg = "exec", default = "@rules_scala_annex//rules/scalafmt", executable = True, ), diff --git a/tests/worker-verbosity/verbosity_spec_worker_run.bzl b/tests/worker-verbosity/verbosity_spec_worker_run.bzl index 140e40632..73b3bc726 100644 --- a/tests/worker-verbosity/verbosity_spec_worker_run.bzl +++ b/tests/worker-verbosity/verbosity_spec_worker_run.bzl @@ -31,7 +31,7 @@ verbosity_spec_worker_run = rule( attrs = { "verbosity_spec_worker": attr.label( executable = True, - cfg = "host", + cfg = "exec", allow_files = True, default = Label(":verbosity-spec-worker"), ), From dd739f730ba79691cb8ee423bf47c7fc315d58b5 Mon Sep 17 00:00:00 2001 From: jjudd Date: Mon, 30 Sep 2024 16:41:06 -0600 Subject: [PATCH 06/17] Add support for path mapping --- .bazelrc_shared | 11 +- rules/common/private/utils.bzl | 62 ++++++++-- .../phases/phase_bootstrap_compile.bzl | 116 ++++++++++++++---- rules/private/phases/phase_classpaths.bzl | 9 +- .../private/phases/phase_coverage_jacoco.bzl | 1 + rules/private/phases/phase_test_launcher.bzl | 14 ++- rules/private/phases/phase_zinc_compile.bzl | 4 +- rules/private/phases/phase_zinc_depscheck.bzl | 1 + rules/scala/private/doc.bzl | 14 +-- rules/scala/private/import.bzl | 16 +-- rules/scala/private/repl.bzl | 10 +- rules/scala_proto/private/core.bzl | 15 ++- rules/scalafmt/private/test.bzl | 44 ++++--- tests/compile/error/test | 2 +- tests/compile/zinc-inc/test | 2 +- tests/plugins/classpath/test | 4 +- tests/strategy/local/bazel.rc | 1 - tests/strategy/{local => sandboxed}/BUILD | 0 tests/strategy/{local => sandboxed}/bazel | 0 tests/strategy/sandboxed/bazel.rc | 1 + .../strategy/{local => sandboxed}/code.scala | 0 tests/strategy/{local => sandboxed}/test | 0 .../verbosity_spec_worker_run.bzl | 1 + 23 files changed, 224 insertions(+), 104 deletions(-) delete mode 100644 tests/strategy/local/bazel.rc rename tests/strategy/{local => sandboxed}/BUILD (100%) rename tests/strategy/{local => sandboxed}/bazel (100%) create mode 100644 tests/strategy/sandboxed/bazel.rc rename tests/strategy/{local => sandboxed}/code.scala (100%) rename tests/strategy/{local => sandboxed}/test (100%) diff --git a/.bazelrc_shared b/.bazelrc_shared index efd95ff7a..1400590e2 100644 --- a/.bazelrc_shared +++ b/.bazelrc_shared @@ -4,6 +4,14 @@ common --color=yes # https://github.com/bazelbuild/bazel/issues/18696#issuecomment-2175561503 common --remote_download_all +# TODO: enable path mapping when we move to Bazel 8. There is a bug in 7. See: +# https://github.com/bazelbuild/bazel/issues/23990 +# In the meantime, if you need to test path mapping you should disable multiplex +# workers with the following build option: +#build --noworker_multiplex +#common --experimental_output_paths=strip +#common --modify_execution_info=CppCompile=+supports-path-mapping + build --experimental_strict_action_env build --javacopt="-source 21 -target 21" build --java_language_version="21" @@ -11,7 +19,8 @@ build --java_runtime_version="remotejdk_21" build --tool_java_language_version="21" build --tool_java_runtime_version="remotejdk_21" -build --strategy=ScalaCompile=worker +build --strategy=worker,sandboxed,local + build --worker_max_instances=4 build --worker_sandboxing build --experimental_worker_multiplex_sandboxing diff --git a/rules/common/private/utils.bzl b/rules/common/private/utils.bzl index 65797ebda..47644f20d 100644 --- a/rules/common/private/utils.bzl +++ b/rules/common/private/utils.bzl @@ -42,6 +42,17 @@ def _format_classpath_entry(runfiles_enabled, workspace_prefix, file): return "$(rlocation " + paths.normalize(workspace_prefix + file.short_path) + ")" +def _format_javabin(java_executable, workspace_prefix, runfiles_enabled): + if not paths.is_absolute(java_executable): + java_executable = workspace_prefix + java_executable + java_executable = paths.normalize(java_executable) + + if runfiles_enabled: + prefix = "" if paths.is_absolute(java_executable) else "${JAVA_RUNFILES}/" + return "JAVABIN=${JAVABIN:-" + prefix + java_executable + "}" + else: + return "JAVABIN=${JAVABIN:-$(rlocation " + java_executable + ")}" + def write_launcher( ctx, prefix, @@ -71,15 +82,6 @@ def write_launcher( # elements in this list is unspecified." java_runtime_info = ctx.attr._target_jdk[0][java_common.JavaRuntimeInfo] java_executable = java_runtime_info.java_executable_runfiles_path - if not paths.is_absolute(java_executable): - java_executable = workspace_name + "/" + java_executable - java_executable = paths.normalize(java_executable) - - if runfiles_enabled: - prefix = "" if paths.is_absolute(java_executable) else "${JAVA_RUNFILES}/" - javabin = "JAVABIN=${JAVABIN:-" + prefix + java_executable + "}" - else: - javabin = "JAVABIN=${JAVABIN:-$(rlocation " + java_executable + ")}" template_dict = ctx.actions.template_dict() template_dict.add_joined( @@ -94,7 +96,7 @@ def write_launcher( base_substitutions = { "%runfiles_manifest_only%": "1" if runfiles_enabled else "", "%workspace_prefix%": workspace_prefix, - "%javabin%": "{}\n{}".format(javabin, extra), + "%javabin%": "{}\n{}".format(_format_javabin(java_executable, workspace_prefix, runfiles_enabled), extra), "%needs_runfiles%": "0" if paths.is_absolute(java_runtime_info.java_executable_exec_path) else "1", "%jvm_flags%": " ".join(jvm_flags), "%test_runtime_classpath_file%": "", @@ -159,6 +161,10 @@ def resolve_execution_reqs(ctx, base_exec_reqs): exec_reqs.update(base_exec_reqs) return exec_reqs +def _format_resources_item(item): + key, value = item + return "{}:{}".format(value.path, key) + def action_singlejar( ctx, inputs, @@ -181,7 +187,7 @@ def action_singlejar( if compression: args.add("--compression") args.add_all("--sources", inputs) - args.add_all("--resources", ["{}:{}".format(value.path, key) for key, value in resources.items()]) + args.add_all("--resources", resources.items(), map_each = _format_resources_item) args.add("--output", output) if main_class != None: args.add("--main_class", main_class) @@ -193,9 +199,41 @@ def action_singlejar( ctx.actions.run( arguments = [args], executable = ctx.executable._singlejar, - execution_requirements = resolve_execution_reqs(ctx, {"supports-workers": "0"}), + execution_requirements = resolve_execution_reqs( + ctx, + { + "supports-workers": "0", + "supports-path-mapping": "1", + }, + ), mnemonic = _SINGLE_JAR_MNEMONIC, inputs = all_inputs, outputs = [output], progress_message = progress_message, ) + +def separate_src_jars_srcs_and_other(files): + src_jars = [] + srcs = [] + other_srcs = [] + + for file in files: + if _is_src_jar(file): + src_jars.append(file) + elif _is_src(file): + srcs.append(file) + else: + other_srcs.append(file) + + return (src_jars, srcs, other_srcs) + +def _is_src_jar(file): + return (file.extension.lower() == "srcjar" or file.short_path.lower().endswith("-sources.jar") or + file.short_path.lower().endswith("-src.jar")) + +def _is_src(file): + return file.extension.lower() in ["java", "scala"] + +def short_path(file): + """Convenience function for getting the short_path that was being duplicated in a few files""" + return file.short_path diff --git a/rules/private/phases/phase_bootstrap_compile.bzl b/rules/private/phases/phase_bootstrap_compile.bzl index 0a9bf8982..0f46db80f 100644 --- a/rules/private/phases/phase_bootstrap_compile.bzl +++ b/rules/private/phases/phase_bootstrap_compile.bzl @@ -18,54 +18,116 @@ def phase_bootstrap_compile(ctx, g): inputs = depset( ctx.files.srcs, - transitive = [ctx.attr._jdk[java_common.JavaRuntimeInfo].files, g.classpaths.compile, g.classpaths.compiler], + transitive = [ + ctx.attr._jdk[java_common.JavaRuntimeInfo].files, + g.classpaths.compile, + g.classpaths.compiler, + ], ) tmp = ctx.actions.declare_directory("{}/tmp/classes".format(ctx.label.name)) - compiler_classpath = ":".join([f.path for f in g.classpaths.compiler.to_list()]) - compile_classpath = ":".join([f.path for f in g.classpaths.compile.to_list()]) - srcs = " ".join([f.path for f in g.classpaths.srcs]) - scala_configuration = g.javainfo.scala_info.scala_configuration main_class = "scala.tools.nsc.Main" if int(scala_configuration.version[0]) >= 3: main_class = "dotty.tools.dotc.Main" + compiler_classpath = g.classpaths.compiler.to_list() + compile_classpath = g.classpaths.compile.to_list() + + args = ctx.actions.args() + args.add("--java", ctx.attr._jdk[java_common.JavaRuntimeInfo].java_executable_exec_path) + args.add("--main_class", main_class) + args.add("--jar_creator", ctx.executable._jar_creator) + args.add("--output_jar", g.classpaths.jar) + + if compiler_classpath: + args.add_joined("--compiler_classpath", compiler_classpath, join_with = ":") + else: + fail("Compiler classpath missing for bootstrap compiler") + + if compile_classpath: + args.add_joined("--compile_classpath", compile_classpath, join_with = ":") + + args.add_all("--tmp", [tmp], expand_directories = False) + + if scala_configuration.global_scalacopts: + args.add_joined("--global_scalacopts", scala_configuration.global_scalacopts, join_with = " ") + + if ctx.attr.scalacopts: + args.add_joined("--scalacopts", ctx.attr.scalacopts, join_with = " ") + + if g.classpaths.srcs: + args.add_joined("--srcs", g.classpaths.srcs, join_with = " ") + command = _strip_margin( """ |set -eo pipefail + |while [ $# -gt 0 ]; do + | case "${1}" in + | --java) + | java="${2}" + | ;; + | --compiler_classpath) + | compiler_classpath="${2}" + | ;; + | --main_class) + | main_class="${2}" + | ;; + | --compile_classpath) + | compile_classpath="${2}" + | ;; + | --tmp) + | tmp="${2}" + | ;; + | --global_scalacopts) + | global_scalacopts="${2}" + | ;; + | --scalacopts) + | scalacopts="${2}" + | ;; + | --srcs) + | srcs="${2}" + | ;; + | --jar_creator) + | jar_creator="${2}" + | ;; + | --output_jar) + | output_jar="${2}" + | ;; + | *) + | echo "Error: Invalid argument." + | exit 1 + | esac + | shift + | shift + |done | - |{java} \\ - | -cp {compiler_classpath} \\ - | {main_class} \\ - | -cp {compile_classpath} \\ - | -d {tmp} \\ - | {global_scalacopts} \\ - | {scalacopts} \\ - | {srcs} + |"${java}" \\ + | -cp "${compiler_classpath}" \\ + | "${main_class}" \\ + | -cp "${compile_classpath}" \\ + | -d "${tmp}" \\ + | ${global_scalacopts} \\ + | ${scalacopts} \\ + | ${srcs} | - |{jar_creator} {output_jar} {tmp} 2> /dev/null - |""".format( - compiler_classpath = compiler_classpath, - compile_classpath = compile_classpath, - global_scalacopts = " ".join(scala_configuration.global_scalacopts), - java = ctx.attr._jdk[java_common.JavaRuntimeInfo].java_executable_exec_path, - jar_creator = ctx.executable._jar_creator.path, - main_class = main_class, - output_jar = g.classpaths.jar.path, - scalacopts = " ".join(ctx.attr.scalacopts), - srcs = srcs, - tmp = tmp.path, - ), + |"${jar_creator}" "${output_jar}" "${tmp}" 2> /dev/null + |""", ) ctx.actions.run_shell( + arguments = [args], inputs = inputs, tools = [ctx.executable._jar_creator], mnemonic = "BootstrapScalacompile", outputs = [g.classpaths.jar, tmp], command = command, - execution_requirements = _resolve_execution_reqs(ctx, {}), + execution_requirements = _resolve_execution_reqs( + ctx, + { + "supports-path-mapping": "1", + }, + ), ) diff --git a/rules/private/phases/phase_classpaths.bzl b/rules/private/phases/phase_classpaths.bzl index 8f889860e..1e6d62254 100644 --- a/rules/private/phases/phase_classpaths.bzl +++ b/rules/private/phases/phase_classpaths.bzl @@ -6,6 +6,7 @@ load( "//rules/common:private/utils.bzl", _action_singlejar = "action_singlejar", _collect = "collect", + _separate_src_jars_srcs_and_other = "separate_src_jars_srcs_and_other", ) def phase_classpaths(ctx, g): @@ -57,13 +58,7 @@ def phase_classpaths(ctx, g): _collect(JavaInfo, g.init.scala_configuration.compiler_classpath), ).transitive_runtime_jars - srcs = [file for file in ctx.files.srcs if file.extension.lower() in ["java", "scala"]] - src_jars = [ - file - for file in ctx.files.srcs - if file.path.lower().endswith(".srcjar") or file.path.lower().endswith("-sources.jar") or - file.path.lower().endswith("-src.jar") - ] + src_jars, srcs, _ = _separate_src_jars_srcs_and_other(ctx.files.srcs) jar = ctx.actions.declare_file("{}/classes.jar".format(ctx.label.name)) diff --git a/rules/private/phases/phase_coverage_jacoco.bzl b/rules/private/phases/phase_coverage_jacoco.bzl index 11dc8ecd7..49c5d0472 100644 --- a/rules/private/phases/phase_coverage_jacoco.bzl +++ b/rules/private/phases/phase_coverage_jacoco.bzl @@ -45,6 +45,7 @@ def phase_coverage_jacoco(ctx, g): "supports-workers": "1", "supports-multiplex-sandboxing": "1", "supports-worker-cancellation": "1", + "supports-path-mapping": "1", }, ), arguments = [args], diff --git a/rules/private/phases/phase_test_launcher.bzl b/rules/private/phases/phase_test_launcher.bzl index 8e7395bde..9e73ff0fc 100644 --- a/rules/private/phases/phase_test_launcher.bzl +++ b/rules/private/phases/phase_test_launcher.bzl @@ -2,7 +2,12 @@ load( "@rules_scala_annex//rules/private:coverage_replacements_provider.bzl", _coverage_replacements_provider = "coverage_replacements_provider", ) -load("//rules/common:private/utils.bzl", _collect = "collect", _write_launcher = "write_launcher") +load( + "//rules/common:private/utils.bzl", + _collect = "collect", + _short_path = "short_path", + _write_launcher = "write_launcher", +) # # PHASE: test_launcher @@ -39,7 +44,7 @@ def phase_test_launcher(ctx, g): if ctx.attr.isolation == "classloader": shared_deps = java_common.merge(_collect(JavaInfo, ctx.attr.shared_deps)) args.add("--isolation", "classloader") - args.add_all("--shared_classpath", shared_deps.transitive_runtime_jars, map_each = _test_launcher_short_path) + args.add_all("--shared_classpath", shared_deps.transitive_runtime_jars, map_each = _short_path) elif ctx.attr.isolation == "process": subprocess_executable = ctx.actions.declare_file("{}/subprocess".format(ctx.label.name)) subprocess_runner_jars = ctx.attr.subprocess_runner[0][JavaInfo].transitive_runtime_jars @@ -55,7 +60,7 @@ def phase_test_launcher(ctx, g): files.append(subprocess_executable) args.add("--isolation", "process") args.add("--subprocess_exec", subprocess_executable.short_path) - args.add_all("--", test_jars, map_each = _test_launcher_short_path) + args.add_all("--", test_jars, map_each = _short_path) args.set_param_file_format("multiline") args_file = ctx.actions.declare_file("{}/test.params".format(ctx.label.name)) ctx.actions.write(args_file, args) @@ -88,6 +93,3 @@ def phase_test_launcher(ctx, g): transitive_files = depset([], transitive = all_jars), ), )) - -def _test_launcher_short_path(file): - return file.short_path diff --git a/rules/private/phases/phase_zinc_compile.bzl b/rules/private/phases/phase_zinc_compile.bzl index 2d6e45204..e1e9922a6 100644 --- a/rules/private/phases/phase_zinc_compile.bzl +++ b/rules/private/phases/phase_zinc_compile.bzl @@ -52,7 +52,7 @@ def phase_zinc_compile(ctx, g): args.add("--output_used", used) args.add_all("--plugins", g.classpaths.plugin) args.add_all("--source_jars", g.classpaths.src_jars) - args.add("--tmp", tmp.path) + args.add_all("--tmp", [tmp], expand_directories = False) args.add("--log_level", toolchain.zinc_configuration.log_level) g.semanticdb.arguments_modifier(args) @@ -87,6 +87,7 @@ def phase_zinc_compile(ctx, g): "supports-workers": "1", "supports-multiplex-sandboxing": "1", "supports-worker-cancellation": "1", + "supports-path-mapping": "1", } # Disable several things if incremental compilation features are going to be used @@ -97,6 +98,7 @@ def phase_zinc_compile(ctx, g): execution_requirements_tags["no-cache"] = "1" execution_requirements_tags["no-remote"] = "1" execution_requirements_tags["supports-multiplex-sandboxing"] = "0" + execution_requirements_tags["supports-path-mapping"] = "0" # todo: different execution path for nosrc jar? ctx.actions.run( diff --git a/rules/private/phases/phase_zinc_depscheck.bzl b/rules/private/phases/phase_zinc_depscheck.bzl index 89e88c3c1..9d16e4086 100644 --- a/rules/private/phases/phase_zinc_depscheck.bzl +++ b/rules/private/phases/phase_zinc_depscheck.bzl @@ -53,6 +53,7 @@ def phase_zinc_depscheck(ctx, g): "supports-workers": "1", "supports-multiplex-sandboxing": "1", "supports-worker-cancellation": "1", + "supports-path-mapping": "1", }, ), arguments = [deps_args], diff --git a/rules/scala/private/doc.bzl b/rules/scala/private/doc.bzl index a7508fbbf..12eb0232f 100644 --- a/rules/scala/private/doc.bzl +++ b/rules/scala/private/doc.bzl @@ -7,6 +7,7 @@ load( "//rules/common:private/utils.bzl", _collect = "collect", _resolve_execution_reqs = "resolve_execution_reqs", + _separate_src_jars_srcs_and_other = "separate_src_jars_srcs_and_other", ) scaladoc_private_attributes = { @@ -33,13 +34,7 @@ def scaladoc_implementation(ctx): [dep[JavaInfo].transitive_runtime_jars for dep in ctx.attr.compiler_deps], ) - srcs = [file for file in ctx.files.srcs if file.extension.lower() in ["java", "scala"]] - src_jars = [ - file - for file in ctx.files.srcs - if file.path.lower().endswith(".srcjar") or file.path.lower().endswith("-sources.jar") or - file.path.lower().endswith("-src.jar") - ] + srcs, src_jars, _ = _separate_src_jars_srcs_and_other(ctx.files.srcs) scalacopts = ["-doc-title", ctx.attr.title or ctx.label] + ctx.attr.scalacopts @@ -48,9 +43,9 @@ def scaladoc_implementation(ctx): args.add_all("--compiler_classpath", compiler_classpath) args.add_all("--classpath", classpath) args.add_all(scalacopts, format_each = "--option=%s") - args.add("--output_html", html.path) + args.add_all("--output_html", [html], expand_directories = False) args.add_all("--source_jars", src_jars) - args.add("--tmp", tmp.path) + args.add_all("--tmp", [tmp], expand_directories = False) args.add_all("--", srcs) args.set_param_file_format("multiline") args.use_param_file("@%s", use_always = True) @@ -67,6 +62,7 @@ def scaladoc_implementation(ctx): "supports-workers": "1", "supports-multiplex-sandboxing": "1", "supports-worker-cancellation": "1", + "supports-path-mapping": "1", }, ), inputs = depset( diff --git a/rules/scala/private/import.bzl b/rules/scala/private/import.bzl index 762570b83..96f424cdb 100644 --- a/rules/scala/private/import.bzl +++ b/rules/scala/private/import.bzl @@ -1,5 +1,9 @@ load("@rules_java//toolchains:toolchain_utils.bzl", "find_java_toolchain") load("@rules_scala_annex//rules:providers.bzl", _IntellijInfo = "IntellijInfo") +load( + "//rules/common:private/utils.bzl", + _separate_src_jars_srcs_and_other = "separate_src_jars_srcs_and_other", +) scala_import_private_attributes = { "_java_toolchain": attr.label( @@ -17,17 +21,7 @@ def scala_import_implementation(ctx): ) if ctx.files.jars: - _jar = [] - _src_jar = [] - for jar in ctx.files.jars: - if ( - jar.basename.lower().endswith("-sources.jar") or - jar.basename.lower().endswith("-src.jar") or - jar.basename.lower().endswith(".srcjar") - ): - _src_jar.append(jar) - else: - _jar.append(jar) + _src_jar, _, _jar = _separate_src_jars_srcs_and_other(ctx.files.jars) _src_jar += ctx.files.srcjar output_jar = _jar[0] diff --git a/rules/scala/private/repl.bzl b/rules/scala/private/repl.bzl index e571b80ce..79264128d 100644 --- a/rules/scala/private/repl.bzl +++ b/rules/scala/private/repl.bzl @@ -4,7 +4,12 @@ load( _ScalaConfiguration = "ScalaConfiguration", _ZincConfiguration = "ZincConfiguration", ) -load("//rules/common:private/utils.bzl", "write_launcher", _collect = "collect") +load( + "//rules/common:private/utils.bzl", + "write_launcher", + _collect = "collect", + _short_path = "short_path", +) def scala_repl_implementation(ctx): toolchain = ctx.toolchains["//rules/scala:toolchain_type"] @@ -59,6 +64,3 @@ def scala_repl_implementation(ctx): ), ), ] - -def _short_path(file): - return file.short_path diff --git a/rules/scala_proto/private/core.bzl b/rules/scala_proto/private/core.bzl index b8a8cacb3..dc55eb056 100644 --- a/rules/scala_proto/private/core.bzl +++ b/rules/scala_proto/private/core.bzl @@ -28,7 +28,7 @@ def scala_proto_library_implementation(ctx): ) args = ctx.actions.args() - args.add("--output_dir", gendir.path) + args.add_all("--output_dir", [gendir], expand_directories = False) args.add_all("--proto_paths", transitive_proto_path) if ctx.attr.grpc: args.add("--grpc") @@ -55,19 +55,28 @@ def scala_proto_library_implementation(ctx): "supports-workers": supports_workers, "supports-multiplex-sandboxing": supports_workers, "supports-worker-cancellation": supports_workers, + "supports-path-mapping": supports_workers, }, ), arguments = [args], ) + shell_args = ctx.actions.args() + shell_args.add(ctx.executable._zipper) + shell_args.add_all([gendir], expand_directories = False) + shell_args.add(gendir.short_path) + shell_args.add(srcjar) + ctx.actions.run_shell( inputs = [gendir], outputs = [srcjar], - arguments = [ctx.executable._zipper.path, gendir.path, gendir.short_path, srcjar.path], + arguments = [shell_args], command = """$1 c $4 META-INF/= $(find -L $2 -type f | while read v; do echo ${v#"${2%$3}"}=$v; done)""", progress_message = "Bundling compiled Scala into srcjar for %{label}", tools = [ctx.executable._zipper], - execution_requirements = _resolve_execution_reqs(ctx, {}), + execution_requirements = _resolve_execution_reqs(ctx, { + "supports-path-mapping": "1", + }), ) return [OutputGroupInfo( diff --git a/rules/scalafmt/private/test.bzl b/rules/scalafmt/private/test.bzl index a29efdcd4..cd1d855c2 100644 --- a/rules/scalafmt/private/test.bzl +++ b/rules/scalafmt/private/test.bzl @@ -1,6 +1,7 @@ load( "@rules_scala_annex//rules/common:private/utils.bzl", _resolve_execution_reqs = "resolve_execution_reqs", + _short_path = "short_path", ) scala_format_attributes = { @@ -36,14 +37,14 @@ def build_format(ctx): runner_inputs, _ = ctx.resolve_tools(tools = [ctx.attr._fmt]) manifest_content = [] for src in ctx.files.srcs: - if src.path.endswith(".scala") and src.is_source: + if src.short_path.endswith(".scala") and src.is_source: file = ctx.actions.declare_file(src.short_path) files.append(file) args = ctx.actions.args() args.add("--config") - args.add(ctx.file.config.path) - args.add(src.path) - args.add(file.path) + args.add(ctx.file.config) + args.add(src) + args.add(file) args.set_param_file_format("multiline") args.use_param_file("@%s", use_always = True) ctx.actions.run( @@ -59,6 +60,7 @@ def build_format(ctx): "supports-workers": "1", "supports-multiplex-sandboxing": "1", "supports-worker-cancellation": "1", + "supports-path-mapping": "1", }, ), mnemonic = "ScalaFmt", @@ -71,31 +73,37 @@ def build_format(ctx): return manifest, files def format_runner(ctx, manifest, files): + args = ctx.actions.args() + args.add(ctx.file._runner) + args.add(ctx.workspace_name) + args.add(manifest.short_path) + args.add(ctx.outputs.scalafmt_runner) + ctx.actions.run_shell( inputs = [ctx.file._runner, manifest] + files, outputs = [ctx.outputs.scalafmt_runner], command = "cat $1 | sed -e s#%workspace%#$2# -e s#%manifest%#$3# > $4", - arguments = [ - ctx.file._runner.path, - ctx.workspace_name, - manifest.short_path, - ctx.outputs.scalafmt_runner.path, - ], - execution_requirements = _resolve_execution_reqs(ctx, {}), + arguments = [args], + execution_requirements = _resolve_execution_reqs(ctx, { + "supports-path-mapping": "1", + }), ) def format_tester(ctx, manifest, files): + args = ctx.actions.args() + args.add(ctx.file._testrunner) + args.add(ctx.workspace_name) + args.add(manifest.short_path) + args.add(ctx.outputs.scalafmt_testrunner) + ctx.actions.run_shell( inputs = [ctx.file._testrunner, manifest] + files, outputs = [ctx.outputs.scalafmt_testrunner], command = "cat $1 | sed -e s#%workspace%#$2# -e s#%manifest%#$3# > $4", - arguments = [ - ctx.file._testrunner.path, - ctx.workspace_name, - manifest.short_path, - ctx.outputs.scalafmt_testrunner.path, - ], - execution_requirements = _resolve_execution_reqs(ctx, {}), + arguments = [args], + execution_requirements = _resolve_execution_reqs(ctx, { + "supports-path-mapping": "1", + }), ) def scala_format_test_implementation(ctx): diff --git a/tests/compile/error/test b/tests/compile/error/test index 47ef77944..9bb21e44d 100755 --- a/tests/compile/error/test +++ b/tests/compile/error/test @@ -3,4 +3,4 @@ bazel build --experimental_worker_multiplex_sandboxing --strategy=ScalaCompile=worker :lib 2>&1 | grep -q $'\[\e\[31mError\e\[0m\] compile/error/Example\.scala:' bazel build --noexperimental_worker_multiplex_sandboxing --strategy=ScalaCompile=worker :lib 2>&1 | grep -q $'\[\e\[31mError\e\[0m\] compile/error/Example\.scala:' -bazel build --strategy=ScalaCompile=local :lib 2>&1 | grep -q $'\[\e\[31mError\e\[0m\] compile/error/Example\.scala:' +bazel build --strategy=ScalaCompile=sandboxed :lib 2>&1 | grep -q $'\[\e\[31mError\e\[0m\] compile/error/Example\.scala:' diff --git a/tests/compile/zinc-inc/test b/tests/compile/zinc-inc/test index e9ad54979..3c466d2f6 100755 --- a/tests/compile/zinc-inc/test +++ b/tests/compile/zinc-inc/test @@ -4,6 +4,6 @@ echo "class A$RANDOM" > Example.gen.scala rm -fr "$(bazel info execution_root)/.bazel-zinc" -bazel build --noworker_sandboxing --worker_extra_flag=ScalaCompile=--persistence_dir=.bazel-zinc :lib +bazel build --experimental_output_paths=off --noworker_sandboxing --worker_extra_flag=ScalaCompile=--persistence_dir=.bazel-zinc :lib # TODO: figure out breakage #[ "$(unzip -l "$(bazel info execution_root)/.bazel-zinc/compile/zinc_inc_lib/classes.jar" | grep '\.class' | wc -l | xargs echo)" = 1 ] diff --git a/tests/plugins/classpath/test b/tests/plugins/classpath/test index 7b7b5eb7a..36177b279 100755 --- a/tests/plugins/classpath/test +++ b/tests/plugins/classpath/test @@ -7,8 +7,8 @@ # takes much longer. bazel shutdown # Using a worker here prevents a println this tests needs from making it -# to the command line, so we use standalone instead. -bazel build :inefficient-usage --strategy=ScalaCompile=standalone --nouse_action_cache |& \ +# to the command line, so we use sandboxed instead. +bazel build :inefficient-usage --strategy=ScalaCompile=sandboxed --nouse_action_cache |& \ awk ' BEGIN {z = 2} /slightly inefficient/ {z -= 1} diff --git a/tests/strategy/local/bazel.rc b/tests/strategy/local/bazel.rc deleted file mode 100644 index 55c15497b..000000000 --- a/tests/strategy/local/bazel.rc +++ /dev/null @@ -1 +0,0 @@ -build --strategy=ScalaCompile=local diff --git a/tests/strategy/local/BUILD b/tests/strategy/sandboxed/BUILD similarity index 100% rename from tests/strategy/local/BUILD rename to tests/strategy/sandboxed/BUILD diff --git a/tests/strategy/local/bazel b/tests/strategy/sandboxed/bazel similarity index 100% rename from tests/strategy/local/bazel rename to tests/strategy/sandboxed/bazel diff --git a/tests/strategy/sandboxed/bazel.rc b/tests/strategy/sandboxed/bazel.rc new file mode 100644 index 000000000..79a92d4d5 --- /dev/null +++ b/tests/strategy/sandboxed/bazel.rc @@ -0,0 +1 @@ +build --strategy=ScalaCompile=sandboxed diff --git a/tests/strategy/local/code.scala b/tests/strategy/sandboxed/code.scala similarity index 100% rename from tests/strategy/local/code.scala rename to tests/strategy/sandboxed/code.scala diff --git a/tests/strategy/local/test b/tests/strategy/sandboxed/test similarity index 100% rename from tests/strategy/local/test rename to tests/strategy/sandboxed/test diff --git a/tests/worker-verbosity/verbosity_spec_worker_run.bzl b/tests/worker-verbosity/verbosity_spec_worker_run.bzl index 73b3bc726..eaedbfbb4 100644 --- a/tests/worker-verbosity/verbosity_spec_worker_run.bzl +++ b/tests/worker-verbosity/verbosity_spec_worker_run.bzl @@ -16,6 +16,7 @@ def _impl(ctx): "supports-workers": "1", "supports-multiplex-sandboxing": "1", "supports-worker-cancellation": "1", + "supports-path-mapping": "1", }, progress_message = "Running verbosity spec worker %{label}", executable = ctx.executable.verbosity_spec_worker, From 36f0a1cd0570cc5ed8e28e3cb88e1c2a0290ed9c Mon Sep 17 00:00:00 2001 From: jjudd Date: Tue, 15 Oct 2024 12:04:40 -0600 Subject: [PATCH 07/17] Add mnemonics for actions that don't currently have them --- rules/scala_proto/private/core.bzl | 1 + rules/scalafmt/private/test.bzl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/rules/scala_proto/private/core.bzl b/rules/scala_proto/private/core.bzl index dc55eb056..341101684 100644 --- a/rules/scala_proto/private/core.bzl +++ b/rules/scala_proto/private/core.bzl @@ -77,6 +77,7 @@ def scala_proto_library_implementation(ctx): execution_requirements = _resolve_execution_reqs(ctx, { "supports-path-mapping": "1", }), + mnemonic = "SrcJar", ) return [OutputGroupInfo( diff --git a/rules/scalafmt/private/test.bzl b/rules/scalafmt/private/test.bzl index cd1d855c2..658c2dbe6 100644 --- a/rules/scalafmt/private/test.bzl +++ b/rules/scalafmt/private/test.bzl @@ -87,6 +87,7 @@ def format_runner(ctx, manifest, files): execution_requirements = _resolve_execution_reqs(ctx, { "supports-path-mapping": "1", }), + mnemonic = "CreateScalaFmtRunner", ) def format_tester(ctx, manifest, files): @@ -104,6 +105,7 @@ def format_tester(ctx, manifest, files): execution_requirements = _resolve_execution_reqs(ctx, { "supports-path-mapping": "1", }), + mnemonic = "CreateScalaFmtTester", ) def scala_format_test_implementation(ctx): From 740138e96c47fc74b8f8c9deb4a4e0fe168d89eb Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 14 Nov 2024 18:29:54 -0700 Subject: [PATCH 08/17] Fix bug in adjustCompilerOptions when workDir is " " We replace the string ${workDir} with the workDir path. Problem is, sometimes the workDir path is " " (the current directory). If that's the case, then we replace ${workDir} with a blank string. Using an absolute path prevents that blank string from happening. --- .../rules_scala/workers/common/CommonArguments.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/higherkindness/rules_scala/workers/common/CommonArguments.scala b/src/main/scala/higherkindness/rules_scala/workers/common/CommonArguments.scala index d735b3311..037d7d1b8 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/common/CommonArguments.scala +++ b/src/main/scala/higherkindness/rules_scala/workers/common/CommonArguments.scala @@ -76,8 +76,9 @@ object CommonArguments { ) } + // Use an absolute path here for the work dir to avoid problems when the working directory is " " withPathReplaced - .replace("${workDir}": @nowarn("cat=lint-missing-interpolator"), workDir.toString) + .replace("${workDir}": @nowarn("cat=lint-missing-interpolator"), workDir.toAbsolutePath().normalize().toString()) } /** From e8cc1067dad9fe08007f19d08e5b4d015e6252f5 Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 14 Nov 2024 18:30:12 -0700 Subject: [PATCH 09/17] Fix off by 1 bug in FileUtil.bazelShortPath --- .../higherkindness/rules_scala/workers/common/FileUtil.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/higherkindness/rules_scala/workers/common/FileUtil.scala b/src/main/scala/higherkindness/rules_scala/workers/common/FileUtil.scala index feaefabe6..70ac5ad88 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/common/FileUtil.scala +++ b/src/main/scala/higherkindness/rules_scala/workers/common/FileUtil.scala @@ -75,7 +75,7 @@ object FileUtil { // Handle difference between Bazel's external directory being referred to as .. in the short_path if (replaceExternal && shortPath.subpath(0, 1) == Paths.get("external")) { - Paths.get("..").resolve(shortPath.subpath(1, shortPath.getNameCount() - 1)) + Paths.get("..").resolve(shortPath.subpath(1, shortPath.getNameCount())) } else { shortPath } From d3ebebb16457d1ce3266b4e5a5f563f528f3058e Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 14 Nov 2024 18:30:27 -0700 Subject: [PATCH 10/17] Uncomment indirect dependencies test --- tests/dependencies/indirect/test | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/dependencies/indirect/test b/tests/dependencies/indirect/test index 01c1f8a48..a694b2213 100755 --- a/tests/dependencies/indirect/test +++ b/tests/dependencies/indirect/test @@ -2,19 +2,19 @@ . "$(dirname "$0")"/../../common.sh # TODO: Make this test not flaky -# # used_deps off -# ! bazel build :used_deps_off_c || false -# bazel build :used_deps_off_c |& grep "buildozer 'add deps @\?//dependencies/indirect:used_deps_off_a' //dependencies/indirect:used_deps_off_c" +# used_deps off +! bazel build :used_deps_off_c || false +bazel build :used_deps_off_c |& grep "buildozer 'add deps @\?//dependencies/indirect:used_deps_off_a' //dependencies/indirect:used_deps_off_c" -# # direct_deps off -# ! bazel build :direct_deps_off_c || false -# bazel build :direct_deps_off_c |& grep "buildozer 'remove deps //dependencies/indirect:direct_deps_off_a' //dependencies/indirect:direct_deps_off_b" +# direct_deps off +! bazel build :direct_deps_off_c || false +bazel build :direct_deps_off_c |& grep "buildozer 'remove deps //dependencies/indirect:direct_deps_off_a' //dependencies/indirect:direct_deps_off_b" -# # toggle used_deps and direct_deps via --define -# ! bazel build --define=scala_deps_used=off :define_c || false -# bazel build --define=scala_deps_used=off :define_c |& grep "buildozer 'add deps @\?//dependencies/indirect:define_a' //dependencies/indirect:define_c" +# toggle used_deps and direct_deps via --define +! bazel build --define=scala_deps_used=off :define_c || false +bazel build --define=scala_deps_used=off :define_c |& grep "buildozer 'add deps @\?//dependencies/indirect:define_a' //dependencies/indirect:define_c" -# ! bazel build --define=scala_deps_direct=off :define_c || false -# bazel build --define=scala_deps_direct=off :define_c |& grep "buildozer 'remove deps //dependencies/indirect:define_a' //dependencies/indirect:define_b" +! bazel build --define=scala_deps_direct=off :define_c || false +bazel build --define=scala_deps_direct=off :define_c |& grep "buildozer 'remove deps //dependencies/indirect:define_a' //dependencies/indirect:define_b" -# bazel build --define=scala_deps_used=off --define=scala_deps_direct=off :define_c +bazel build --define=scala_deps_used=off --define=scala_deps_direct=off :define_c From 88124b6702abf41b3f074d1acff452b86da78b12 Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 14 Nov 2024 19:14:02 -0700 Subject: [PATCH 11/17] Upgrade to Bazel 7.4.1 --- .bazelversion | 2 +- .github/workflows/ci.yml | 2 +- docs/stardoc/scala_workspace.md | 2 +- rules/scala/workspace.bzl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bazelversion b/.bazelversion index ba7f754d0..815da58b7 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.4.0 +7.4.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abbd86319..84d1debe1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-24.04] - bazel_version: [bazelbuild/7.4.0] + bazel_version: [bazelbuild/7.4.1] steps: - uses: actions/checkout@v3 - uses: bazel-contrib/setup-bazel@0.9.0 diff --git a/docs/stardoc/scala_workspace.md b/docs/stardoc/scala_workspace.md index 2c76b6dca..570b30976 100644 --- a/docs/stardoc/scala_workspace.md +++ b/docs/stardoc/scala_workspace.md @@ -54,7 +54,7 @@ scala_repositories(java_laun | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| java_launcher_version |

-

| `"7.4.0"` | +| java_launcher_version |

-

| `"7.4.1"` | | java_launcher_template_sha |

-

| `"ee4aa47ae5e639632c67be5cc0ccbc4e941a67a1b884a1ce0c4329357a4b62b2"` | diff --git a/rules/scala/workspace.bzl b/rules/scala/workspace.bzl index 3a944241b..b917aabf0 100644 --- a/rules/scala/workspace.bzl +++ b/rules/scala/workspace.bzl @@ -49,7 +49,7 @@ def scala_artifacts(): ] def scala_repositories( - java_launcher_version = "7.4.0", + java_launcher_version = "7.4.1", java_launcher_template_sha = "ee4aa47ae5e639632c67be5cc0ccbc4e941a67a1b884a1ce0c4329357a4b62b2"): maven_install( name = "annex", From 98a186b83a2b7e41296f55047030e2795909d70c Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 14 Nov 2024 19:36:49 -0700 Subject: [PATCH 12/17] Rename Scala toolchains to avoid conflicts with other repos Because we're using strings, names like zinc_3 would likely conflict in other repos. --- README.md | 4 ++-- WORKSPACE | 2 +- docs/newdocs/scala_versions.md | 14 +++++++------- rules/scala/workspace.bzl | 8 ++++---- rules/scala_proto/BUILD | 2 +- rules/scalafmt/BUILD | 2 +- src/main/scala/BUILD | 12 ++++++------ .../higherkindness/rules_scala/common/args/BUILD | 2 +- .../rules_scala/common/classloaders/BUILD | 2 +- .../higherkindness/rules_scala/common/error/BUILD | 2 +- .../rules_scala/common/interrupt/BUILD | 2 +- .../rules_scala/common/sandbox/BUILD | 2 +- .../rules_scala/common/sbt-testing/BUILD | 4 ++-- .../higherkindness/rules_scala/common/worker/BUILD | 2 +- .../rules_scala/workers/bloop/compile/BUILD | 2 +- .../rules_scala/workers/common/BUILD | 2 +- .../higherkindness/rules_scala/workers/deps/BUILD | 2 +- .../rules_scala/workers/jacoco/instrumenter/BUILD | 2 +- .../rules_scala/workers/zinc/compile/BUILD | 2 +- .../rules_scala/workers/zinc/doc/BUILD | 2 +- .../rules_scala/workers/zinc/repl/BUILD | 2 +- .../rules_scala/workers/zinc/test/BUILD | 2 +- 22 files changed, 38 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 13277f034..874d20610 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ load("@rules_scala_annex//rules/scala:workspace.bzl", "scala_register_toolchains scala_repositories() load("@annex//:defs.bzl", annex_pinned_maven_install = "pinned_maven_install") annex_pinned_maven_install() -scala_register_toolchains(default_scala_toolchain_name = "zinc_3") +scala_register_toolchains(default_scala_toolchain_name = "annex_zinc_3") load("@rules_scala_annex//rules/scalafmt:workspace.bzl", "scalafmt_default_config", "scalafmt_repositories") scalafmt_repositories() @@ -116,7 +116,7 @@ protobuf_deps() # Specify the scala compiler we wish to use; in this case, we'll use the default one specified in rules_scala_annex bind( name = "default_scala", - actual = "@rules_scala_annex//src/main/scala:zinc_2_13", + actual = "@rules_scala_annex//src/main/scala:annex_zinc_2_13", ) ``` diff --git a/WORKSPACE b/WORKSPACE index 6630c2613..beab4a0de 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -101,7 +101,7 @@ load("@annex//:defs.bzl", annex_pinned_maven_install = "pinned_maven_install") annex_pinned_maven_install() -scala_register_toolchains(default_scala_toolchain_name = "zinc_2_13") +scala_register_toolchains(default_scala_toolchain_name = "annex_zinc_2_13") # Scala 2.12 diff --git a/docs/newdocs/scala_versions.md b/docs/newdocs/scala_versions.md index ecaa2cb58..90fafd637 100644 --- a/docs/newdocs/scala_versions.md +++ b/docs/newdocs/scala_versions.md @@ -35,7 +35,7 @@ compiler_classpath_2_13 = [ runtime_classpath_2_13 = ["@scala_library_2_13//jar"] register_bootstrap_toolchain( - name = "bootstrap_2_13", + name = "annex_bootstrap_2_13", compiler_classpath = compiler_classpath_2_13, runtime_classpath = runtime_classpath_2_13, version = "2.13.14", @@ -46,7 +46,7 @@ register_bootstrap_toolchain( scala_library( name = "compiler_bridge_2_13", srcs = ["@compiler_bridge_2_13//:src"], - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = compiler_classpath_2_13 + [ "@scala_annex_org_scala_sbt_compiler_interface//jar", @@ -56,7 +56,7 @@ scala_library( # This augments the configuration to configure the zinc compiler register_zinc_toolchain( - name = "zinc_2_13", + name = "annex_zinc_2_13", compiler_bridge = ":compiler_bridge_2_13", compiler_classpath = compiler_classpath_2_13, runtime_classpath = runtime_classpath_2_13, @@ -72,8 +72,8 @@ load("@rules_scala_annex//rules/scala:workspace.bzl", "scala_register_toolchains ... scala_register_toolchains( - toolchains = ["//:bootstrap_2_13", "//:zinc_2_13"], - default_scala_toolchain_name = "zinc_2_13", + toolchains = ["//:annex_bootstrap_2_13", "//:annex_zinc_2_13"], + default_scala_toolchain_name = "annex_zinc_2_13", ) ... @@ -90,13 +90,13 @@ For example: scala_library( name = "example_compiled_with_scalac", srcs = glob(["**/*.scala"]) - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", ) scala_library( name = "example_compiled_with_zinc", srcs = glob(["**/*.scala"]) - scala_toolchain_name = "zinc_2_13", + scala_toolchain_name = "annex_zinc_2_13", ) # This would use the default toolchain, which we configured via `scala_register_toolchains` above diff --git a/rules/scala/workspace.bzl b/rules/scala/workspace.bzl index b917aabf0..1f41bd276 100644 --- a/rules/scala/workspace.bzl +++ b/rules/scala/workspace.bzl @@ -135,9 +135,9 @@ def scala_register_toolchains(default_scala_toolchain_name, toolchains = []): ) native.register_toolchains( - "//src/main/scala:bootstrap_2_13", - "//src/main/scala:bootstrap_3", - "//src/main/scala:zinc_2_13", - "//src/main/scala:zinc_3", + "//src/main/scala:annex_bootstrap_2_13", + "//src/main/scala:annex_bootstrap_3", + "//src/main/scala:annex_zinc_2_13", + "//src/main/scala:annex_zinc_3", *toolchains ) diff --git a/rules/scala_proto/BUILD b/rules/scala_proto/BUILD index 31db09e76..f577b908c 100644 --- a/rules/scala_proto/BUILD +++ b/rules/scala_proto/BUILD @@ -16,7 +16,7 @@ scala_binary( name = "worker", srcs = ["private/ScalaProtoWorker.scala"], main_class = "annex.scala.proto.ScalaProtoWorker", - scala_toolchain_name = "zinc_3", + scala_toolchain_name = "annex_zinc_3", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/args", diff --git a/rules/scalafmt/BUILD b/rules/scalafmt/BUILD index 7d23e23ab..7cb9bf9fe 100644 --- a/rules/scalafmt/BUILD +++ b/rules/scalafmt/BUILD @@ -21,7 +21,7 @@ scala_binary( name = "scalafmt", srcs = glob(["scalafmt/**/*.scala"]), main_class = "annex.scalafmt.ScalafmtRunner", - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/interrupt", diff --git a/src/main/scala/BUILD b/src/main/scala/BUILD index deda53eea..df4b9d782 100644 --- a/src/main/scala/BUILD +++ b/src/main/scala/BUILD @@ -27,7 +27,7 @@ shared_scala2_global_scalacopts = [ scala2_global_scalacopts = shared_global_scalacopts + shared_scala2_global_scalacopts register_bootstrap_toolchain( - name = "bootstrap_2_13", + name = "annex_bootstrap_2_13", compiler_classpath = compiler_classpath_2_13, global_scalacopts = scala2_global_scalacopts, runtime_classpath = runtime_classpath_2_13, @@ -36,7 +36,7 @@ register_bootstrap_toolchain( ) register_zinc_toolchain( - name = "zinc_2_13", + name = "annex_zinc_2_13", compiler_bridge = "@annex//:org_scala_sbt_compiler_bridge_2_13", compiler_classpath = compiler_classpath_2_13, global_scalacopts = scala2_global_scalacopts, @@ -52,7 +52,7 @@ register_zinc_toolchain( scala_library( name = "scala-sdk", deps_used_whitelist = compiler_classpath_2_13, - scala_toolchain_name = "zinc_3", + scala_toolchain_name = "annex_zinc_3", deps = compiler_classpath_2_13, ) @@ -70,12 +70,12 @@ runtime_classpath_3 = [ scala_library( name = "scala-sdk-3", deps_used_whitelist = compiler_classpath_3, - scala_toolchain_name = "zinc_3", + scala_toolchain_name = "annex_zinc_3", deps = compiler_classpath_3, ) register_bootstrap_toolchain( - name = "bootstrap_3", + name = "annex_bootstrap_3", compiler_classpath = compiler_classpath_3, global_scalacopts = shared_global_scalacopts, runtime_classpath = runtime_classpath_3, @@ -85,7 +85,7 @@ register_bootstrap_toolchain( ) register_zinc_toolchain( - name = "zinc_3", + name = "annex_zinc_3", compiler_bridge = "@annex//:org_scala_lang_scala3_sbt_bridge", compiler_classpath = compiler_classpath_3, global_scalacopts = shared_global_scalacopts, diff --git a/src/main/scala/higherkindness/rules_scala/common/args/BUILD b/src/main/scala/higherkindness/rules_scala/common/args/BUILD index 5ce70f727..588359b83 100644 --- a/src/main/scala/higherkindness/rules_scala/common/args/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/args/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "args", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/error", diff --git a/src/main/scala/higherkindness/rules_scala/common/classloaders/BUILD b/src/main/scala/higherkindness/rules_scala/common/classloaders/BUILD index c89b2ef07..e7773cc2c 100644 --- a/src/main/scala/higherkindness/rules_scala/common/classloaders/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/classloaders/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "classloaders", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], ) diff --git a/src/main/scala/higherkindness/rules_scala/common/error/BUILD b/src/main/scala/higherkindness/rules_scala/common/error/BUILD index 4f06d3f0d..b89781fd2 100644 --- a/src/main/scala/higherkindness/rules_scala/common/error/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/error/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "error", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], ) diff --git a/src/main/scala/higherkindness/rules_scala/common/interrupt/BUILD b/src/main/scala/higherkindness/rules_scala/common/interrupt/BUILD index 68cb40b56..2a82800c0 100644 --- a/src/main/scala/higherkindness/rules_scala/common/interrupt/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/interrupt/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "interrupt", srcs = glob(["*.scala"]), - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], ) diff --git a/src/main/scala/higherkindness/rules_scala/common/sandbox/BUILD b/src/main/scala/higherkindness/rules_scala/common/sandbox/BUILD index fc73df106..2f4eba806 100644 --- a/src/main/scala/higherkindness/rules_scala/common/sandbox/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/sandbox/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "sandbox", srcs = glob(["*.scala"]), - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], ) diff --git a/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD b/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD index 824e6b178..e757a6f6a 100644 --- a/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/sbt-testing/BUILD @@ -12,7 +12,7 @@ _common_srcs = [ scala_library( name = "subprocess", srcs = _subprocess_srcs, - scala_toolchain_name = "zinc_2_13", + scala_toolchain_name = "annex_zinc_2_13", visibility = ["//visibility:public"], deps = [ ":common", @@ -24,7 +24,7 @@ scala_library( scala_library( name = "common", srcs = _common_srcs, - scala_toolchain_name = "zinc_2_13", + scala_toolchain_name = "annex_zinc_2_13", visibility = ["//visibility:public"], deps = [ "@annex//:org_scala_lang_modules_scala_xml_2_13", diff --git a/src/main/scala/higherkindness/rules_scala/common/worker/BUILD b/src/main/scala/higherkindness/rules_scala/common/worker/BUILD index 915d9505c..13f941109 100644 --- a/src/main/scala/higherkindness/rules_scala/common/worker/BUILD +++ b/src/main/scala/higherkindness/rules_scala/common/worker/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "worker", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/error", diff --git a/src/main/scala/higherkindness/rules_scala/workers/bloop/compile/BUILD b/src/main/scala/higherkindness/rules_scala/workers/bloop/compile/BUILD index 3cb276740..37637338f 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/bloop/compile/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/bloop/compile/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_binary( name = "compile", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "zinc_2_13", + scala_toolchain_name = "annex_zinc_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/worker", diff --git a/src/main/scala/higherkindness/rules_scala/workers/common/BUILD b/src/main/scala/higherkindness/rules_scala/workers/common/BUILD index 1f1bcceac..443ed4d5c 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/common/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/common/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "common", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/args", diff --git a/src/main/scala/higherkindness/rules_scala/workers/deps/BUILD b/src/main/scala/higherkindness/rules_scala/workers/deps/BUILD index 20b2b5aa7..c9cf1914f 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/deps/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/deps/BUILD @@ -5,7 +5,7 @@ scala_binary( name = "deps", srcs = glob(["**/*.scala"]), main_class = "higherkindness.rules_scala.workers.deps.DepsRunner", - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/args", diff --git a/src/main/scala/higherkindness/rules_scala/workers/jacoco/instrumenter/BUILD b/src/main/scala/higherkindness/rules_scala/workers/jacoco/instrumenter/BUILD index cda9bb686..9ec6c6840 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/jacoco/instrumenter/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/jacoco/instrumenter/BUILD @@ -5,7 +5,7 @@ scala_binary( name = "instrumenter", srcs = glob(["**/*.scala"]), main_class = "higherkindness.rules_scala.workers.jacoco.instrumenter.JacocoInstrumenter", - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/args", diff --git a/src/main/scala/higherkindness/rules_scala/workers/zinc/compile/BUILD b/src/main/scala/higherkindness/rules_scala/workers/zinc/compile/BUILD index 42b99e546..2e37587ab 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/zinc/compile/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/zinc/compile/BUILD @@ -5,7 +5,7 @@ scala_binary( name = "compile", srcs = glob(["**/*.scala"]), main_class = "higherkindness.rules_scala.workers.zinc.compile.ZincRunner", - scala_toolchain_name = "bootstrap_2_13", + scala_toolchain_name = "annex_bootstrap_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/error", diff --git a/src/main/scala/higherkindness/rules_scala/workers/zinc/doc/BUILD b/src/main/scala/higherkindness/rules_scala/workers/zinc/doc/BUILD index 7c26f6ea7..9bea1c89f 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/zinc/doc/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/zinc/doc/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_binary( name = "doc", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "zinc_2_13", + scala_toolchain_name = "annex_zinc_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/args", diff --git a/src/main/scala/higherkindness/rules_scala/workers/zinc/repl/BUILD b/src/main/scala/higherkindness/rules_scala/workers/zinc/repl/BUILD index 84cc9949c..0d8bbef78 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/zinc/repl/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/zinc/repl/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_binary( name = "repl", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "zinc_2_13", + scala_toolchain_name = "annex_zinc_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/args", diff --git a/src/main/scala/higherkindness/rules_scala/workers/zinc/test/BUILD b/src/main/scala/higherkindness/rules_scala/workers/zinc/test/BUILD index ac42e40b1..9c92aaa06 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/zinc/test/BUILD +++ b/src/main/scala/higherkindness/rules_scala/workers/zinc/test/BUILD @@ -4,7 +4,7 @@ load("//rules:scalafmt.bzl", "scala_format_test") scala_library( name = "test", srcs = glob(["**/*.scala"]), - scala_toolchain_name = "zinc_2_13", + scala_toolchain_name = "annex_zinc_2_13", visibility = ["//visibility:public"], deps = [ "//src/main/scala/higherkindness/rules_scala/common/args", From 0c5905ea1a0b6422facc7323865283f56c7b8c85 Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 14 Nov 2024 21:25:01 -0700 Subject: [PATCH 13/17] Remove Bazel bug workaround as it was fixed in 7.4.0 --- .bazelrc_shared | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.bazelrc_shared b/.bazelrc_shared index 1400590e2..dfdbc10ab 100644 --- a/.bazelrc_shared +++ b/.bazelrc_shared @@ -1,8 +1,7 @@ common --announce_rc common --color=yes -# Fix "Failed to fetch blobs because they do not exist remotely" errors -# https://github.com/bazelbuild/bazel/issues/18696#issuecomment-2175561503 -common --remote_download_all +# TODO: remove this when we move to Bazel 8. This is the default in Bazel 8. +common --experimental_remote_cache_eviction_retries=5 # TODO: enable path mapping when we move to Bazel 8. There is a bug in 7. See: # https://github.com/bazelbuild/bazel/issues/23990 From 2b314e8a0c702170e2c68eeba02bb7b440808745 Mon Sep 17 00:00:00 2001 From: jjudd Date: Thu, 14 Nov 2024 22:26:50 -0700 Subject: [PATCH 14/17] Workaround the sandbox is missing files bug For some reason multiplex sandboxing seems to have issues with files going missing. It's been happening for a while, but intermittently. It got much worse recently. Not sure if this is a rule set bug or a Bazel bug. Regardless, disabling multiplex sandboxing fixes it. --- .bazelrc_shared | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.bazelrc_shared b/.bazelrc_shared index dfdbc10ab..513afef3d 100644 --- a/.bazelrc_shared +++ b/.bazelrc_shared @@ -22,7 +22,13 @@ build --strategy=worker,sandboxed,local build --worker_max_instances=4 build --worker_sandboxing -build --experimental_worker_multiplex_sandboxing +# Disable multiplex sandboxing because there is a bug that causes files which +# should be in the sandbox to not be. Not sure if this is a Bazel bug or a rule +# set bug. Something we need to deal with either way. +# Once we enable path mapping, we should also be able to get rid of the outgoing +# transition that we're currently relying on to prevent an explosion in the number +# of builds. +#build --experimental_worker_multiplex_sandboxing build --experimental_worker_cancellation build --verbose_failures From 231ab520cf13b65e54ab9e530e918a7150207f48 Mon Sep 17 00:00:00 2001 From: jjudd Date: Fri, 15 Nov 2024 17:56:33 -0700 Subject: [PATCH 15/17] Change exec cfg to target cfg for the repl runner. It runs on the target architecture rather than the exec architecture, so this makes more sense. --- rules/scala.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/scala.bzl b/rules/scala.bzl index e0e5719a1..5d2ce994c 100644 --- a/rules/scala.bzl +++ b/rules/scala.bzl @@ -408,7 +408,7 @@ _scala_repl_private_attributes = _dicts.add( _runtime_private_attributes, { "_runner": attr.label( - cfg = "exec", + cfg = "target", executable = True, default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/workers/zinc/repl", ), From 43a08298d6d3d9d86ed0f9e5d1d076ae214e1c17 Mon Sep 17 00:00:00 2001 From: jjudd Date: Fri, 15 Nov 2024 17:57:44 -0700 Subject: [PATCH 16/17] Remove host_javabase as it is deprecated --- rules/scala.bzl | 4 ---- rules/scala/private/import.bzl | 4 ---- 2 files changed, 8 deletions(-) diff --git a/rules/scala.bzl b/rules/scala.bzl index 5d2ce994c..6286d1ba8 100644 --- a/rules/scala.bzl +++ b/rules/scala.bzl @@ -53,10 +53,6 @@ _compile_private_attributes = { cfg = _scala_toolchain_outgoing_transition, default = Label("@bazel_tools//tools/jdk:current_java_toolchain"), ), - "_host_javabase": attr.label( - default = Label("@bazel_tools//tools/jdk:current_java_runtime"), - cfg = "exec", - ), "_singlejar": attr.label( cfg = "exec", default = "@bazel_tools//tools/jdk:singlejar", diff --git a/rules/scala/private/import.bzl b/rules/scala/private/import.bzl index 96f424cdb..33084cc82 100644 --- a/rules/scala/private/import.bzl +++ b/rules/scala/private/import.bzl @@ -9,10 +9,6 @@ scala_import_private_attributes = { "_java_toolchain": attr.label( default = Label("@bazel_tools//tools/jdk:current_java_toolchain"), ), - "_host_javabase": attr.label( - default = Label("@bazel_tools//tools/jdk:current_java_runtime"), - cfg = "exec", - ), } def scala_import_implementation(ctx): From ee6bbb7efae2a4873d1985b7f5b115406bf7562b Mon Sep 17 00:00:00 2001 From: jjudd Date: Fri, 15 Nov 2024 18:47:30 -0700 Subject: [PATCH 17/17] Disable worker sandbox hardening as it seems to cause issues with some javac targets --- .bazelrc_shared | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.bazelrc_shared b/.bazelrc_shared index 513afef3d..c0df5d822 100644 --- a/.bazelrc_shared +++ b/.bazelrc_shared @@ -32,7 +32,9 @@ build --worker_sandboxing build --experimental_worker_cancellation build --verbose_failures -build --experimental_worker_sandbox_hardening +# This is disabled as it was causing some issues with some javac targets when used +# with path mapping. If that is resolved, then we can turn it back on. +#build --experimental_worker_sandbox_hardening build --experimental_use_hermetic_linux_sandbox test --test_output=all