From 103c194f69f6720e8d2c6ca4c8fcd5ef61174f17 Mon Sep 17 00:00:00 2001 From: Ryan Ferguson Date: Wed, 2 Oct 2024 12:11:25 -0600 Subject: [PATCH] make rules scala compatible with bazelbsp --- .bazelproject | 3 + .gitignore | 3 + rules/scala/private/provider.bzl | 104 +++++++++++++++++-------------- 3 files changed, 62 insertions(+), 48 deletions(-) diff --git a/.bazelproject b/.bazelproject index 71bdb50fb..5d42e5b6a 100644 --- a/.bazelproject +++ b/.bazelproject @@ -9,3 +9,6 @@ targets: additional_languages: scala + +enabled_rules: + rules_scala_annex diff --git a/.gitignore b/.gitignore index 747870f5c..9a42b936f 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ target/ /.vscode/ /bazel.iml *.iml +/.bazelbsp/ +/.bsp/ +/.metals/ diff --git a/rules/scala/private/provider.bzl b/rules/scala/private/provider.bzl index f377e3083..9a8fc7e39 100644 --- a/rules/scala/private/provider.bzl +++ b/rules/scala/private/provider.bzl @@ -15,53 +15,61 @@ load( ) def configure_bootstrap_scala_implementation(ctx): - return [ - _ScalaConfiguration( - compiler_classpath = ctx.attr.compiler_classpath, - global_plugins = ctx.attr.global_plugins, - global_scalacopts = ctx.attr.global_scalacopts, - runtime_classpath = ctx.attr.runtime_classpath, - semanticdb_bundle = ctx.attr.semanticdb_bundle, - use_ijar = ctx.attr.use_ijar, - version = ctx.attr.version, - ), - _ScalaRulePhase( - phases = [ - ("=", "compile", "compile", _phase_bootstrap_compile), - ], - ), - ] + scala_configuration = _ScalaConfiguration( + compiler_classpath = ctx.attr.compiler_classpath, + global_plugins = ctx.attr.global_plugins, + global_scalacopts = ctx.attr.global_scalacopts, + runtime_classpath = ctx.attr.runtime_classpath, + semanticdb_bundle = ctx.attr.semanticdb_bundle, + use_ijar = ctx.attr.use_ijar, + version = ctx.attr.version, + ) + return struct( + scala_configuration = scala_configuration, + providers = [ + scala_configuration, + _ScalaRulePhase( + phases = [ + ("=", "compile", "compile", _phase_bootstrap_compile), + ], + ), + ], + ) def configure_zinc_scala_implementation(ctx): - return [ - _ScalaConfiguration( - compiler_classpath = ctx.attr.compiler_classpath, - global_plugins = ctx.attr.global_plugins, - global_scalacopts = ctx.attr.global_scalacopts, - runtime_classpath = ctx.attr.runtime_classpath, - semanticdb_bundle = ctx.attr.semanticdb_bundle, - use_ijar = ctx.attr.use_ijar, - version = ctx.attr.version, - ), - _CodeCoverageConfiguration( - instrumentation_worker = ctx.attr._code_coverage_instrumentation_worker, - ), - _ZincConfiguration( - compile_worker = ctx.attr._compile_worker, - compiler_bridge = ctx.file.compiler_bridge, - log_level = ctx.attr.log_level, - incremental = ctx.attr.incremental, - ), - _DepsConfiguration( - direct = ctx.attr.deps_direct, - used = ctx.attr.deps_used, - worker = ctx.attr._deps_worker, - ), - _ScalaRulePhase( - phases = [ - ("=", "compile", "compile", _phase_zinc_compile), - ("-", "compile", "semanticdb", _phase_semanticdb), - ("+", "compile", "depscheck", _phase_zinc_depscheck), - ], - ), - ] + scala_configuration = _ScalaConfiguration( + compiler_classpath = ctx.attr.compiler_classpath, + global_plugins = ctx.attr.global_plugins, + global_scalacopts = ctx.attr.global_scalacopts, + runtime_classpath = ctx.attr.runtime_classpath, + semanticdb_bundle = ctx.attr.semanticdb_bundle, + use_ijar = ctx.attr.use_ijar, + version = ctx.attr.version, + ) + return struct( + scala_configuration = scala_configuration, + providers = [ + scala_configuration, + _CodeCoverageConfiguration( + instrumentation_worker = ctx.attr._code_coverage_instrumentation_worker, + ), + _ZincConfiguration( + compile_worker = ctx.attr._compile_worker, + compiler_bridge = ctx.file.compiler_bridge, + log_level = ctx.attr.log_level, + incremental = ctx.attr.incremental, + ), + _DepsConfiguration( + direct = ctx.attr.deps_direct, + used = ctx.attr.deps_used, + worker = ctx.attr._deps_worker, + ), + _ScalaRulePhase( + phases = [ + ("=", "compile", "compile", _phase_zinc_compile), + ("-", "compile", "semanticdb", _phase_semanticdb), + ("+", "compile", "depscheck", _phase_zinc_depscheck), + ], + ), + ], + )