Skip to content

Commit

Permalink
Introduce SCALA_VERSIONS (#1557)
Browse files Browse the repository at this point in the history
A variable to hold all (possibly more than one in the future) configured versions of Scala.

Co-authored-by: mkuta <[email protected]>
  • Loading branch information
aszady and mateuszkuta256 authored Mar 25, 2024
1 parent 330081d commit 8f255cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cross-compilation-doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Cross compilation support

The support for cross-compilation is currently under development.

## Version configuration

`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"]`.
5 changes: 5 additions & 0 deletions scala_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ def _validate_supported_scala_version(scala_major_version, scala_minor_version):
fail("Scala version must be newer or equal to 2.12.1 to use compiler dependency tracking.")

def _store_config(repository_ctx):
# Default version
scala_version = repository_ctx.os.environ.get(
"SCALA_VERSION",
repository_ctx.attr.scala_version,
)

# All versions supported
scala_versions = [scala_version]

enable_compiler_dependency_tracking = repository_ctx.os.environ.get(
"ENABLE_COMPILER_DEPENDENCY_TRACKING",
str(repository_ctx.attr.enable_compiler_dependency_tracking),
Expand All @@ -29,6 +33,7 @@ def _store_config(repository_ctx):

config_file_content = "\n".join([
"SCALA_VERSION='" + scala_version + "'",
"SCALA_VERSIONS=" + str(scala_versions),
"SCALA_MAJOR_VERSION='" + scala_major_version + "'",
"SCALA_MINOR_VERSION='" + scala_minor_version + "'",
"ENABLE_COMPILER_DEPENDENCY_TRACKING=" + enable_compiler_dependency_tracking,
Expand Down

0 comments on commit 8f255cd

Please sign in to comment.