Skip to content
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

Configure rules behaviour/toolchain attributes via build settings #1570

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

simuons
Copy link
Collaborator

@simuons simuons commented Apr 25, 2024

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_flags boolean 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant