1
1
load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
2
2
load (
3
3
"@io_bazel_rules_scala//scala:scala_cross_version.bzl" ,
4
+ "extract_major_version" ,
5
+ "extract_minor_version" ,
6
+ "version_suffix" ,
4
7
_default_maven_server_urls = "default_maven_server_urls" ,
5
8
)
6
9
load ("//third_party/repositories:repositories.bzl" , "repositories" )
7
10
load (
8
11
"@io_bazel_rules_scala_config//:config.bzl" ,
9
12
"SCALA_MAJOR_VERSION" ,
10
- "SCALA_MINOR_VERSION" ,
11
- "SCALA_VERSION" ,
13
+ "SCALA_VERSIONS" ,
12
14
)
13
15
14
16
def _dt_patched_compiler_impl (rctx ):
@@ -37,16 +39,18 @@ def _validate_scalac_srcjar(srcjar):
37
39
count += 1
38
40
return count == 1
39
41
40
- def dt_patched_compiler_setup (scala_compiler_srcjar = None ):
41
- patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.patch" % SCALA_MAJOR_VERSION
42
+ def dt_patched_compiler_setup (scala_version , scala_compiler_srcjar = None ):
43
+ scala_major_version = extract_major_version (scala_version )
44
+ scala_minor_version = extract_minor_version (scala_version )
45
+ patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.patch" % scala_major_version
42
46
43
- minor_version = int (SCALA_MINOR_VERSION )
47
+ minor_version = int (scala_minor_version )
44
48
45
- if SCALA_MAJOR_VERSION == "2.12" :
49
+ if scala_major_version == "2.12" :
46
50
if minor_version >= 1 and minor_version <= 7 :
47
- patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.1.patch" % SCALA_MAJOR_VERSION
51
+ patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.1.patch" % scala_major_version
48
52
elif minor_version <= 11 :
49
- patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.8.patch" % SCALA_MAJOR_VERSION
53
+ patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.8.patch" % scala_major_version
50
54
51
55
build_file_content = "\n " .join ([
52
56
"package(default_visibility = [\" //visibility:public\" ])" ,
@@ -56,7 +60,7 @@ def dt_patched_compiler_setup(scala_compiler_srcjar = None):
56
60
")" ,
57
61
])
58
62
default_scalac_srcjar = {
59
- "url" : "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/%s/scala-compiler-%s-sources.jar" % (SCALA_VERSION , SCALA_VERSION ),
63
+ "url" : "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/%s/scala-compiler-%s-sources.jar" % (scala_version , scala_version ),
60
64
}
61
65
srcjar = scala_compiler_srcjar if scala_compiler_srcjar != None else default_scalac_srcjar
62
66
_validate_scalac_srcjar (srcjar ) or fail (
@@ -65,14 +69,14 @@ def dt_patched_compiler_setup(scala_compiler_srcjar = None):
65
69
)
66
70
if "label" in srcjar :
67
71
dt_patched_compiler (
68
- name = "scala_compiler_source" ,
72
+ name = "scala_compiler_source" + version_suffix ( scala_version ) ,
69
73
build_file_content = build_file_content ,
70
74
patch = patch ,
71
75
srcjar = srcjar ["label" ],
72
76
)
73
77
else :
74
78
http_archive (
75
- name = "scala_compiler_source" ,
79
+ name = "scala_compiler_source" + version_suffix ( scala_version ) ,
76
80
build_file_content = build_file_content ,
77
81
patches = [patch ],
78
82
url = srcjar .get ("url" ),
@@ -120,7 +124,8 @@ def rules_scala_setup(scala_compiler_srcjar = None):
120
124
],
121
125
)
122
126
123
- dt_patched_compiler_setup (scala_compiler_srcjar )
127
+ for scala_version in SCALA_VERSIONS :
128
+ dt_patched_compiler_setup (scala_version , scala_compiler_srcjar )
124
129
125
130
ARTIFACT_IDS = [
126
131
"io_bazel_rules_scala_scala_library" ,
0 commit comments