Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

[fix] collect scalac options from toolchain #433

Merged
merged 2 commits into from
Jun 16, 2023
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@


## [Unreleased]

### Fixes 🛠️
- Collect scalac options from the toolchain
| [#433](https://github.com/JetBrains/bazel-bsp/pull/433)

### Performance
- Reduce peak memory footprint
| [#428](https://github.com/JetBrains/bazel-bsp/pull/428)

## [2.7.1]

### Fixes 🛠️
Expand Down
27 changes: 26 additions & 1 deletion install/src/main/resources/aspects.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,32 @@ def extract_scala_info(target, ctx, output_groups):
if not provider:
return None

scalac_opts = getattr(ctx.rule.attr, "scalacopts", [])
# proper solution, but it requires adding scala_toolchain to the aspect
# SCALA_TOOLCHAIN = "@io_bazel_rules_scala//scala:toolchain_type"
# check of _scala_toolchain is necessary, because SCALA_TOOLCHAIN will always be present
# if hasattr(ctx.rule.attr, "_scala_toolchain"):
# common_scalac_opts = ctx.toolchains[SCALA_TOOLCHAIN].scalacopts
# else:
# common_scalac_opts = []
# scalac_opts = common_scalac_opts + getattr(ctx.rule.attr, "scalacopts", [])

scalac_opts = []

# don't bother inspecting non-scala targets
if hasattr(ctx.rule.attr, "_scala_toolchain"):
for action in target.actions:
if action.mnemonic == "Scalac":
found_scalac_opts = False
for arg in action.argv:
if arg == "--ScalacOpts":
found_scalac_opts = True
elif found_scalac_opts:
# Next worker option appeared.
# Currently --ScalacOpts is the last one, but just in case
if arg.startswith("--"):
break
scalac_opts.append(arg)
break

scala_info = struct(
scalac_opts = scalac_opts,
Expand Down