Skip to content

Commit 9abf3b0

Browse files
authored
Documentation update after development of the cross-build (#1588)
* Move the cross-compilation doc to docs/ * Quick-start tutorial for cross-build users
1 parent 47505a5 commit 9abf3b0

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ scala_register_toolchains()
162162
Note: Toolchains are a more flexible way to configure dependencies, so you should prefer that way.
163163
Please also note, that the `overriden_artifacts` parameter is likely to be removed in the future.
164164

165+
### Multiple versions (cross-compilation)
166+
167+
Rules scala supports configuring multiple Scala versions and offers target-level control of which one to use.
168+
169+
Please check [cross-compilation.md](docs/cross-compilation.md) for more details on cross-compilation support.
170+
165171
## Bazel compatible versions
166172

167173
| minimal bazel version | rules_scala gitsha |

cross-compilation-doc.md renamed to docs/cross-compilation.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
# Cross compilation support
22

3-
The support for cross-compilation is currently under development.
3+
Read *Quick start* for an information on how to use cross compilation.
4+
The remaining sections contain more detailed information, useful especially for toolchain & rule developers.
5+
6+
## Quick start
7+
`scala_config` repository rule accepts two parameters related to Scala version:
8+
* `scala_version` – a single, default version;
9+
* `scala_versions` – a list of versions to make available for use.
10+
11+
The first one, `scala_version`, will be used as a default, but it can be overridden for specific targets for any version from the `scala_versions`.
12+
13+
Multiple rules, such as:
14+
- [scala_library](/scala/private/rules/scala_library.bzl)
15+
- [scala_binary](/scala/private/rules/scala_binary.bzl)
16+
- [scala_repl](/scala/private/rules/scala_repl.bzl)
17+
- [scala_test](/scala/private/rules/scala_test.bzl)
18+
19+
support such override via the `scala_version` attribute, e.g.:
20+
```starlark
21+
scala_library(
22+
name = ...
23+
...
24+
scala_version = "2.12.18",
25+
...
26+
)
27+
```
28+
29+
For this library and all its dependencies 2.12.18 compiler will be used, unless explicitly overridden again in another target.
430

531
## Version configuration
632

@@ -84,7 +110,7 @@ scala_library(
84110
)
85111
```
86112

87-
See complete documentation in the [scala_cross_version_select.bzl](scala/scala_cross_version_select.bzl) file
113+
See complete documentation in the [scala_cross_version_select.bzl](/scala/scala_cross_version_select.bzl) file
88114

89115
#### Manually
90116
An example usage of `select()` to provide custom dependency for specific Scala version:
@@ -180,7 +206,8 @@ We can distinguish following tiers:
180206
* No `target_settings` set – not migrated, will work on the default `SCALA_VERSION`; undefined behavior on other versions.
181207
* (all toolchains not mentioned elsewhere)
182208
* `target_settings` set to the `SCALA_VERSION` – not fully migrated; will work only on the default `SCALA_VERSION` and will fail the toolchain resolution on other versions.
183-
* [the main Scala toolchain](scala/BUILD)
184-
* [Scalafmt](scala/scalafmt/BUILD)
185-
* [Scalatest](testing/testing.bzl)
209+
* (no development in progress)
186210
* Multiple toolchain instances with `target_settings` corresponding to each of `SCALA_VERSIONS` – fully migrated; will work in cross-build setup.
211+
* [the main Scala toolchain](/scala/BUILD)
212+
* [Scalafmt](/scala/scalafmt/BUILD)
213+
* [Scalatest](/testing/testing.bzl)

0 commit comments

Comments
 (0)