Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cross-compilation-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The support for cross-compilation is currently under development.
`scala_config` creates the repository `@io_bazel_rules_scala_config`.
File created there, `config.bzl`, consists of many variables. In particular:
* `SCALA_VERSION` – representing the default Scala version, e.g. `"3.3.1"`;
* `SCALA_VERSIONS` – representing all configured Scala versions (currently one), e.g. `["3.3.1"]`.
* `SCALA_VERSIONS` – representing all configured Scala versions, e.g. `["2.12.18", "3.3.1"]`.


## Build settings
Expand All @@ -22,6 +22,7 @@ string_setting(
values = ["3.3.1"],
visibility = ["//visibility:public"],
)
...
```
This build setting can be subject of change by [transitions](https://bazel.build/extending/config#user-defined-transitions) (within allowed `values`).

Expand All @@ -32,6 +33,7 @@ config_setting(
name = "scala_version_3_3_1",
flag_values = {":scala_version": "3.3.1"},
)
...
```
The `name` of `config_setting` corresponds to `"scala_version" + version_suffix(scala_version)`.
One may use this config setting in `select()` e.g. to provide dependencies relevant to a currently used Scala version.
Expand Down
13 changes: 12 additions & 1 deletion scala_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def _store_config(repository_ctx):
)

# All versions supported
scala_versions = [scala_version]
scala_versions = repository_ctx.attr.scala_versions
if not scala_versions:
scala_versions = [scala_version]
elif scala_version not in scala_versions:
fail("You have to include the default Scala version (%s) in the `scala_versions` list." % scala_version)

enable_compiler_dependency_tracking = repository_ctx.os.environ.get(
"ENABLE_COMPILER_DEPENDENCY_TRACKING",
Expand Down Expand Up @@ -67,6 +71,11 @@ _config_repository = repository_rule(
attrs = {
"scala_version": attr.string(
mandatory = True,
doc = "Default Scala version",
),
"scala_versions": attr.string_list(
mandatory = True,
doc = "List of all Scala versions to configure. Must include the default one.",
),
"enable_compiler_dependency_tracking": attr.bool(
mandatory = True,
Expand All @@ -77,9 +86,11 @@ _config_repository = repository_rule(

def scala_config(
scala_version = _default_scala_version(),
scala_versions = [],
enable_compiler_dependency_tracking = False):
_config_repository(
name = "io_bazel_rules_scala_config",
scala_version = scala_version,
scala_versions = scala_versions,
enable_compiler_dependency_tracking = enable_compiler_dependency_tracking,
)