Skip to content

Commit

Permalink
Add tut deps toolchain (bazelbuild#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaidas Pilkauskas authored and Borja Lorente committed Nov 26, 2020
1 parent d352214 commit 41ade82
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/scala/io/bazel/rules_scala/tut_support/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ scala_library(
"//scala/private/toolchain_deps:scala_compile_classpath",
],
deps = [
"//external:io_bazel_rules_scala/dependency/tut/tut_core",
"//src/java/io/bazel/rulesscala/io_utils",
"@io_bazel_rules_scala//tut_rule:tut_core",
],
)

Expand Down
25 changes: 25 additions & 0 deletions tut_rule/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@io_bazel_rules_scala//scala:providers.bzl", "declare_deps_provider")
load("@io_bazel_rules_scala//tut_rule/toolchain:toolchain.bzl", "export_tut_deps", "tut_toolchain")

tut_toolchain(
name = "tut_toolchain_impl",
visibility = ["//visibility:public"],
)

toolchain(
name = "tut_toolchain",
toolchain = ":tut_toolchain_impl",
toolchain_type = "//tut_rule/toolchain:tut_toolchain_type",
)

declare_deps_provider(
name = "tut_core_provider",
deps_id = "tut_core",
deps = ["//external:io_bazel_rules_scala/dependency/tut/tut_core"],
)

export_tut_deps(
name = "tut_core",
deps_id = "tut_core",
visibility = ["//visibility:public"],
)
4 changes: 4 additions & 0 deletions tut_rule/toolchain/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
toolchain_type(
name = "tut_toolchain_type",
visibility = ["//visibility:public"],
)
37 changes: 37 additions & 0 deletions tut_rule/toolchain/toolchain.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
load("@io_bazel_rules_scala//scala:providers.bzl", _DepsInfo = "DepsInfo")
load("//scala/private/toolchain_deps:toolchain_deps.bzl", "expose_toolchain_deps")

def _tut_toolchain_impl(ctx):
toolchain = platform_common.ToolchainInfo(
dep_providers = ctx.attr.dep_providers,
)

return [toolchain]

tut_toolchain = rule(
_tut_toolchain_impl,
attrs = {
"dep_providers": attr.label_list(
default = [
"@io_bazel_rules_scala//tut_rule:tut_core_provider",
],
providers = [_DepsInfo],
),
},
)

def _export_tut_deps(ctx):
return expose_toolchain_deps(
ctx,
"@io_bazel_rules_scala//tut_rule/toolchain:tut_toolchain_type",
)

export_tut_deps = rule(
_export_tut_deps,
attrs = {
"deps_id": attr.string(
mandatory = True,
),
},
toolchains = ["@io_bazel_rules_scala//tut_rule/toolchain:tut_toolchain_type"],
)
2 changes: 2 additions & 0 deletions tut_rule/tut.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def tut_repositories(
actual = "@io_bazel_rules_scala_org_tpolecat_tut_core",
)

native.register_toolchains("@io_bazel_rules_scala//tut_rule:tut_toolchain")

def scala_tut_doc(**kw):
name = kw["name"]
deps = kw.get("deps", [])
Expand Down

0 comments on commit 41ade82

Please sign in to comment.