Skip to content

Commit 6143d10

Browse files
committed
Merge branch 'bzlmod-scala-compiler-sources-repo' into bzlmod
2 parents fae16a0 + 7b63af3 commit 6143d10

File tree

2 files changed

+17
-24
lines changed
  • scala/private/macros
  • third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/compiler

2 files changed

+17
-24
lines changed

scala/private/macros/scala_repositories.bzl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,29 @@ dt_patched_compiler = repository_rule(
2525
implementation = _dt_patched_compiler_impl,
2626
)
2727

28-
_PACKAGE_VISIBILITY_PUBLIC = """package(
29-
default_visibility = [\"//visibility:public\"],
30-
)
31-
"""
32-
33-
_COMPILER_SOURCE_ALIAS_FORMAT = """alias(
34-
name = "src{scala_version_suffix}",
35-
actual = "@scala_compiler_source{scala_version_suffix}//:src",
28+
_COMPILER_SOURCE_ALIAS_TEMPLATE = """alias(
29+
name = "src",
3630
visibility = ["//visibility:public"],
31+
actual = select({{{compiler_sources}
32+
}}),
3733
)
3834
"""
3935

36+
_COMPILER_SOURCES_ENTRY_TEMPLATE = """
37+
"@io_bazel_rules_scala_config//:scala_version{scala_version_suffix}":
38+
"@scala_compiler_source{scala_version_suffix}//:src","""
39+
4040
def _compiler_sources_repo_impl(rctx):
41-
build_content = [_PACKAGE_VISIBILITY_PUBLIC]
42-
build_content.extend([
43-
_COMPILER_SOURCE_ALIAS_FORMAT.format(
41+
sources = [
42+
_COMPILER_SOURCES_ENTRY_TEMPLATE.format(
4443
scala_version_suffix = version_suffix(scala_version),
4544
)
4645
for scala_version in SCALA_VERSIONS
47-
])
48-
49-
rctx.file("BUILD", content = "\n".join(build_content), executable = False)
46+
]
47+
build_content = _COMPILER_SOURCE_ALIAS_TEMPLATE.format(
48+
compiler_sources = "".join(sources),
49+
)
50+
rctx.file("BUILD", content = build_content, executable = False)
5051

5152
compiler_sources_repo = repository_rule(
5253
implementation = _compiler_sources_repo_impl,
@@ -83,8 +84,7 @@ def dt_patched_compiler_setup(scala_version, scala_compiler_srcjar = None):
8384
)
8485

8586
build_file_content = "\n".join([
86-
_PACKAGE_VISIBILITY_PUBLIC,
87-
"",
87+
"package(default_visibility = [\"//visibility:public\"])",
8888
"filegroup(",
8989
" name = \"src\",",
9090
" srcs=[\"scala/tools/nsc/symtab/SymbolLoaders.scala\"],",

third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/compiler/BUILD

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
load("//scala:scala.bzl", "scala_library_for_plugin_bootstrapping")
2-
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSIONS")
3-
load("@io_bazel_rules_scala//scala:scala_cross_version.bzl", "version_suffix")
42

53
scala_library_for_plugin_bootstrapping(
64
name = "dep_reporting_compiler",
7-
srcs = select({
8-
"@io_bazel_rules_scala_config//:scala_version" + version_suffix(v): [
9-
"@scala_compiler_sources//:src%s" % version_suffix(v),
10-
]
11-
for v in SCALA_VERSIONS
12-
}),
5+
srcs = ["@scala_compiler_sources//:src"],
136
scalac_jvm_flags = ["-Xmx128M"], # fixme - workaround for a failing test
147
visibility = ["//visibility:public"],
158
deps = ["//scala/private/toolchain_deps:scala_compile_classpath"],

0 commit comments

Comments
 (0)