-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dt_patches/compiler_sources repo (#1654)
This is part of the Bzlmod prep work from #1482, but also reduces duplication between the `dt_patches/test_dt_patches*/WORKSPACE` files. The structure of the `dt_patches/compiler_sources/extensions.bzl` declarations accommodates the fact that, unlike `WORKSPACE, `MODULE.bazel` files cannot import constants or contain conditional statements. That is to say, there's no way to port the `if SCALA_VERSION.startswith("2.")` expressions from the previous `WORKSPACE` files to Bzlmod. The new `import_compiler_source_repos` macro, however, works for both `WORKSPACE` and Bzlmod builds, as it's trivial to wrap `import_compiler_source_repos` in a module extension.
- Loading branch information
Showing
8 changed files
with
103 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import ../../.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.5.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
workspace(name = "compiler_sources") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
load( | ||
"@io_bazel_rules_scala//scala:scala_cross_version.bzl", | ||
"default_maven_server_urls", | ||
) | ||
load( | ||
"@io_bazel_rules_scala//scala:scala_maven_import_external.bzl", | ||
"scala_maven_import_external", | ||
) | ||
load( | ||
"@io_bazel_rules_scala//third_party/repositories:scala_2_13.bzl", | ||
_scala_2_version = "scala_version", | ||
) | ||
load( | ||
"@io_bazel_rules_scala//third_party/repositories:scala_3_5.bzl", | ||
_scala_3_version = "scala_version", | ||
) | ||
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION") | ||
|
||
_IS_SCALA_2 = SCALA_VERSION.startswith("2.") | ||
_IS_SCALA_3 = SCALA_VERSION.startswith("3.") | ||
|
||
_SCALA_2_VERSION = SCALA_VERSION if _IS_SCALA_2 else _scala_2_version | ||
_SCALA_3_VERSION = SCALA_VERSION if _IS_SCALA_3 else _scala_3_version | ||
|
||
_SCALA_VERSION_ARTIFACTS = { | ||
"scala_compiler": "org.scala-lang:scala3-compiler_3:", | ||
"scala_library": "org.scala-lang:scala3-library_3:", | ||
} if _IS_SCALA_3 else { | ||
"scala_compiler": "org.scala-lang:scala-compiler:", | ||
"scala_library": "org.scala-lang:scala-library:", | ||
} | ||
|
||
_SCALA_2_ARTIFACTS = { | ||
"scala_reflect": "org.scala-lang:scala-reflect:", | ||
"scala2_library": "org.scala-lang:scala-library:", | ||
} | ||
|
||
_SCALA_3_ARTIFACTS = { | ||
"scala3_interfaces": "org.scala-lang:scala3-interfaces:", | ||
"tasty_core": "org.scala-lang:tasty-core_3:", | ||
} | ||
|
||
def _versioned_artifacts(scala_version, artifacts): | ||
return {k: v + scala_version for k, v in artifacts.items()} | ||
|
||
COMPILER_SOURCES_ARTIFACTS = ( | ||
_versioned_artifacts(SCALA_VERSION, _SCALA_VERSION_ARTIFACTS) | | ||
_versioned_artifacts(_SCALA_2_VERSION, _SCALA_2_ARTIFACTS) | | ||
_versioned_artifacts(_SCALA_3_VERSION, _SCALA_3_ARTIFACTS) | | ||
{ | ||
"sbt_compiler_interface": "org.scala-sbt:compiler-interface:1.9.6", | ||
"scala_asm": "org.scala-lang.modules:scala-asm:9.7.0-scala-2", | ||
} | ||
) | ||
|
||
def import_compiler_source_repos(): | ||
for name, artifact in COMPILER_SOURCES_ARTIFACTS.items(): | ||
scala_maven_import_external( | ||
name = name, | ||
artifact = artifact, | ||
licenses = ["notice"], | ||
server_urls = default_maven_server_urls(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar") | ||
|
||
def import_compiler_user_srcjar_repos(): | ||
http_jar( | ||
name = "scala_compiler_srcjar", | ||
sha256 = "95c217cc87ee846b39990e0a9c273824a384dffbac57df84d466f866df4a91ea", | ||
url = "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.16/scala-compiler-2.12.16-sources.jar", | ||
) | ||
|
||
http_jar( | ||
name = "scala3_compiler_srcjar", | ||
sha256 = "3c413efa9a2921ef59da7f065c445ae1b6b97057cbbc6b16957ad052a575a3ce", | ||
url = "https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.4.3/scala3-compiler_3-3.4.3-sources.jar", | ||
) | ||
|
||
def _compiler_user_srcjar_repos_impl(_ctx): | ||
import_compiler_user_srcjar_repos() | ||
|
||
compiler_user_srcjar_repos = module_extension( | ||
implementation = _compiler_user_srcjar_repos_impl, | ||
) |