From d395b05ffc10c6a803042470766691386387141a Mon Sep 17 00:00:00 2001 From: Vaidas Pilkauskas Date: Mon, 14 Sep 2020 15:09:46 +0300 Subject: [PATCH] Add tut deps toolchain --- .../io/bazel/rules_scala/tut_support/BUILD | 2 +- tut_rule/BUILD | 25 +++++++++++++ tut_rule/toolchain/BUILD | 4 ++ tut_rule/toolchain/toolchain.bzl | 37 +++++++++++++++++++ tut_rule/tut.bzl | 2 + 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tut_rule/toolchain/BUILD create mode 100644 tut_rule/toolchain/toolchain.bzl diff --git a/src/scala/io/bazel/rules_scala/tut_support/BUILD b/src/scala/io/bazel/rules_scala/tut_support/BUILD index bc710c665..1c853436d 100644 --- a/src/scala/io/bazel/rules_scala/tut_support/BUILD +++ b/src/scala/io/bazel/rules_scala/tut_support/BUILD @@ -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", ], ) diff --git a/tut_rule/BUILD b/tut_rule/BUILD index e69de29bb..4a1336ac0 100644 --- a/tut_rule/BUILD +++ b/tut_rule/BUILD @@ -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"], +) diff --git a/tut_rule/toolchain/BUILD b/tut_rule/toolchain/BUILD new file mode 100644 index 000000000..be93e65b6 --- /dev/null +++ b/tut_rule/toolchain/BUILD @@ -0,0 +1,4 @@ +toolchain_type( + name = "tut_toolchain_type", + visibility = ["//visibility:public"], +) diff --git a/tut_rule/toolchain/toolchain.bzl b/tut_rule/toolchain/toolchain.bzl new file mode 100644 index 000000000..374528b9d --- /dev/null +++ b/tut_rule/toolchain/toolchain.bzl @@ -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"], +) diff --git a/tut_rule/tut.bzl b/tut_rule/tut.bzl index d1b61ee70..c17d76101 100644 --- a/tut_rule/tut.bzl +++ b/tut_rule/tut.bzl @@ -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", [])