Configure rules behaviour/toolchain attributes via build settings - #1570
Draft
simuons wants to merge 5 commits into
Draft
Configure rules behaviour/toolchain attributes via build settings#1570simuons wants to merge 5 commits into
simuons wants to merge 5 commits into
Conversation
Rationale: thse settings are orhogonal to scala version. If we will intorduce multiple toolchains for different scala versions then we would need to repeat same attrs for each scala version Toolchains are meant for platform specific tools/flags in our case it loosely maps to scala version Build settings/flags are meant to change behaviour of the rules like strict_deps, use_args_file etc
Unfortunately bazel rules doesn't know if attr was set by user or not bazelbuild/bazel#14434
simuons
force-pushed
the
scala_settings
branch
from
February 12, 2025 08:56
b38e466 to
5558c39
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Configure rules via build settings instead of attributes on toolchain.
Eventually toolchain should contain only attributes that are scala version specific (ie jars, scalac opts, executables)
For backwards compatibility make this behaviour configurable (ie either use attributes on toolchain or build flags) by
//scala/settings:scala_toolchain_flagsboolean flag which defaults to false meaning keep current behaviour.Flags are put under
//scala/settings:*with names matching to toolchain attributes.Motivation
Many scala toolchain attributes are not dependent on scala version, but rather control rules behaviour or enables some features. This becomes more relevant when multiple scala versions are used during the build, which would require setting same attributes to same values for each scala version.
This would prevent having different configs per scala version, but it's doable fairly easily. On the other hand I'm not sure this is needed. For example when strict_deps are enabled most likely it's irrelevant what scala version is used.
TODOS: add docs, add tests, remove toolchains for tests that flip single flag.