@@ -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+
4040def _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
5152compiler_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\" ]," ,
0 commit comments