Skip to content

Commit

Permalink
Removed reconfigure_deps_configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaden Peterson committed Nov 13, 2024
1 parent f4185a2 commit 6939753
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 59 deletions.
38 changes: 0 additions & 38 deletions rules/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,44 +52,6 @@ ScalaRulePhase = provider(
},
)

def _reconfigure_deps_configuration_implementation(ctx):
original_config = ctx.attr.provider[DepsConfiguration]

direct = original_config.direct
if ctx.attr.direct != "inherit":
direct = ctx.attr.direct
used = original_config.used
if ctx.attr.used != "inherit":
used = ctx.attr.used

providers = [DepsConfiguration(
direct = direct,
used = used,
worker = original_config.worker,
)]
if ScalaConfiguration in ctx.attr.provider:
providers += [ctx.attr.provider[ScalaConfiguration]]
if ZincConfiguration in ctx.attr.provider:
providers += [ctx.attr.provider[ZincConfiguration]]
if ScalaRulePhase in ctx.attr.provider:
providers += [ctx.attr.provider[ScalaRulePhase]]

return providers

reconfigure_deps_configuration = rule(
attrs = {
"provider": attr.label(
mandatory = True,
providers = [
[DepsConfiguration],
],
),
"direct": attr.string(default = "inherit"),
"used": attr.string(default = "inherit"),
},
implementation = _reconfigure_deps_configuration_implementation,
)

ZincInfo = provider(
doc = "Zinc-specific outputs.",
fields = {
Expand Down
49 changes: 34 additions & 15 deletions tests/dependencies/indirect/BUILD
Original file line number Diff line number Diff line change
@@ -1,57 +1,76 @@
load("@rules_scala_annex//rules:providers.bzl", "reconfigure_deps_configuration")
load("@rules_scala_annex//rules:register_toolchain.bzl", "register_zinc_toolchain")
load("@rules_scala_annex//rules:scala.bzl", "scala_library")
load("@rules_scala_annex//rules/scala:workspace.bzl", "scala_2_13_version")

# used_deps off
reconfigure_deps_configuration(
name = "scala_used_deps_off",
provider = "//scala:2_13",
used = "off",
register_zinc_toolchain(
name = "test_zinc_2_13_used_deps_off",
compiler_bridge = "@annex//:org_scala_sbt_compiler_bridge_2_13",
compiler_classpath = [
"@annex//:org_scala_lang_scala_compiler",
"@annex//:org_scala_lang_scala_reflect",
"@annex//:org_scala_lang_scala_library",
],
deps_used = "off",
global_scalacopts = ["-Ytasty-reader"],
runtime_classpath = ["@annex//:org_scala_lang_scala_library"],
version = scala_2_13_version,
visibility = ["//visibility:public"],
)

scala_library(
name = "used_deps_off_a",
srcs = ["A.scala"],
scala = ":scala_used_deps_off",
scala_toolchain_name = "test_zinc_2_13_used_deps_off",
)

scala_library(
name = "used_deps_off_b",
srcs = ["B.scala"],
scala = ":scala_used_deps_off",
scala_toolchain_name = "test_zinc_2_13_used_deps_off",
deps = [":used_deps_off_a"],
)

scala_library(
name = "used_deps_off_c",
srcs = ["C.scala"],
scala = ":scala_used_deps_off",
scala_toolchain_name = "test_zinc_2_13_used_deps_off",
deps = [":used_deps_off_b"],
)

# direct_deps off
reconfigure_deps_configuration(
name = "scala_direct_deps_off",
direct = "off",
provider = "//scala:2_13",
register_zinc_toolchain(
name = "test_zinc_2_13_direct_deps_off",
compiler_bridge = "@annex//:org_scala_sbt_compiler_bridge_2_13",
compiler_classpath = [
"@annex//:org_scala_lang_scala_compiler",
"@annex//:org_scala_lang_scala_reflect",
"@annex//:org_scala_lang_scala_library",
],
deps_direct = "off",
global_scalacopts = ["-Ytasty-reader"],
runtime_classpath = ["@annex//:org_scala_lang_scala_library"],
version = scala_2_13_version,
visibility = ["//visibility:public"],
)

scala_library(
name = "direct_deps_off_a",
srcs = ["A.scala"],
scala = ":scala_direct_deps_off",
scala_toolchain_name = "test_zinc_2_13_direct_deps_off",
)

scala_library(
name = "direct_deps_off_b",
srcs = ["B.scala"],
scala = ":scala_direct_deps_off",
scala_toolchain_name = "test_zinc_2_13_direct_deps_off",
deps = [":direct_deps_off_a"],
)

scala_library(
name = "direct_deps_off_c",
srcs = ["C.scala"],
scala = ":scala_direct_deps_off",
scala_toolchain_name = "test_zinc_2_13_direct_deps_off",
deps = [":direct_deps_off_b"],
)

Expand Down
6 changes: 0 additions & 6 deletions tests/scala/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ load("@rules_scala_annex//rules:scala.bzl", "scala_library")
load("@rules_scala_annex//rules/scala:workspace.bzl", "scala_2_13_version", "scala_3_version")
load("@rules_scala_annex//rules/scala:workspace_2_12.bzl", "scala_2_12_version")

alias(
name = "2_13",
actual = ":zinc_2_13",
visibility = ["//visibility:public"],
)

# zinc 2.12

compiler_classpath_2_12 = [
Expand Down

0 comments on commit 6939753

Please sign in to comment.