-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move default toolchain dependencies logic to .bzl file #1561
Conversation
Purely refactoring change. Encapsulates the logic of selecting dependencies into a function. Should come in handy in future changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at comments.
|
||
_DEFAULT_DEPS = { | ||
"scala_compile_classpath": { | ||
"any": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this "any" introduced to reduce duplication? I'm afraid this assumption that labels match between scala version might not always hold, leaving "any" obsolete.
I think some duplication here is fine. I would just list all major scala versions and deps lables for each dep_id.
imho that would look simpler. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, any
is here just to avoid duplication.
My goal was to keep the change minimal (here: not changing the logic of producing the relevant labels). This deduplication is not a new concept, as it expresses the same intention as the old version in the BUILD file, e.g.:
_SCALA_COMPILE_CLASSPATH_DEPS = [
"@io_bazel_rules_scala_scala_compiler",
"@io_bazel_rules_scala_scala_library",
] + (["@io_bazel_rules_scala_scala_reflect"] if SCALA_MAJOR_VERSION.startswith("2") else [
"@io_bazel_rules_scala_scala_interfaces",
"@io_bazel_rules_scala_scala_tasty_core",
"@io_bazel_rules_scala_scala_asm",
"@io_bazel_rules_scala_scala_library_2",
])
translated into:
"scala_compile_classpath": {
"any": [
"@io_bazel_rules_scala_scala_compiler",
"@io_bazel_rules_scala_scala_library",
],
"2": [
"@io_bazel_rules_scala_scala_reflect",
],
"3": [
"@io_bazel_rules_scala_scala_interfaces",
"@io_bazel_rules_scala_scala_tasty_core",
"@io_bazel_rules_scala_scala_asm",
"@io_bazel_rules_scala_scala_library_2",
],
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your intent. Probably it's just a matter of personal taste. Since it's private and encapsulated in a function I'm totally fine with that.
scala/BUILD
Outdated
_SEMANTICDB_DEPS = ["@org_scalameta_semanticdb_scalac"] if SCALA_MAJOR_VERSION.startswith("2") else [] | ||
|
||
setup_scala_toolchain( | ||
setup_scala_toolchain_with_default_classpaths( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this new macro really needed? I mean scala_version
attribute eventually should be passed to setup_scala_toolchain
because it will be needed in target_setting
. So maybe default classpaths should be added there if None was passed.
I think it is nice to have deps_id mappings extracted into separate bzl file with lookup exposed function. But for now I would avoid adding new macro and change setup_scala_toolchain
to
setup_scala_toolchain(
name = "default_toolchain",
scala_compile_classpath = default_deps("scala_compile_classpath", SCALA_VERSION),
scala_library_classpath = default_deps("scala_library_classpath", SCALA_VERSION),
scala_macro_classpath = default_deps("scala_macro_classpath", SCALA_VERSION),
use_argument_file_in_runner = True,
)
Similarly to what you did for declare_deps_provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro is not necessary.
So since we have #1566 already merged (scala_version
is now passed to setup_scala_toolchain
), we can already proceed with default classpaths if None
is provided.
I pushed the relevant revision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @aszady!
These should also point to Scala version-specific artifacts. See previous PR: bazelbuild#1561
These should also point to Scala version-specific artifacts. See previous PR: bazelbuild#1561
These should also point to Scala version-specific artifacts. See previous PR: bazelbuild#1561
These should also point to Scala version-specific artifacts. See previous PR: #1561
Description
Purely refactoring change.
Encapsulates the logic of selecting dependencies into a function. Should come in handy in future changes.
Motivation
Originally #1290.
Partitioned from / inspired by #1552.