From 7b5b3c12d5244cc0a29bac15f1e0ebee6a9ce5fc Mon Sep 17 00:00:00 2001 From: Steven Parkes Date: Sat, 25 Jan 2020 08:11:07 -0800 Subject: [PATCH] wip --- WORKSPACE | 32 +++++++++++++++++-- scala/scala_configuration.bzl | 8 +++++ src/java/io/bazel/rulesscala/scalac/BUILD.bzl | 5 ++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 4094d66e3..d6be9a3c1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,6 +1,34 @@ workspace(name = "io_bazel_rules_scala") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +##### +# bazel-skylib 0.8.0 released 2019.03.20 (https://github.com/bazelbuild/bazel-skylib/releases/tag/0.8.0) +skylib_version = "0.8.0" + +http_archive( + name = "bazel_skylib", + sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e", + type = "tar.gz", + url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib.{}.tar.gz".format(skylib_version, skylib_version), +) + +load("@io_bazel_rules_scala//scala:rules_jvm_external.bzl", "rules_jvm_external") + +rules_jvm_external() + +load("@io_bazel_rules_scala//scala:scala_configuration.bzl", "scala_configuration") + +scala_configuration() + +load( + "@io_bazel_rules_scala//scala:scala_repositories.bzl", + "scala_repositories", +) + +scala_repositories() +##### + load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") @@ -131,9 +159,9 @@ local_repository( path = "third_party/test/strip_resource_external_workspace", ) -load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_toolchains") +# load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_toolchains") -scala_register_unused_deps_toolchains() +# scala_register_unused_deps_toolchains() register_toolchains("@io_bazel_rules_scala//test/proto:scalapb_toolchain") diff --git a/scala/scala_configuration.bzl b/scala/scala_configuration.bzl index f93194297..58e7fe0f8 100644 --- a/scala/scala_configuration.bzl +++ b/scala/scala_configuration.bzl @@ -50,6 +50,14 @@ def scala_configuration(): ) scala_configuration.append( """ +def versioned_file(file, version): + configuration = scala_version_configuration(version) + components = file.split(".") + components[0] = components[0] + "_{scala_mvn_version}" + glob_string = ".".join(components).format(**configuration) + array = (native.glob([glob_string]) + [file])[0:1] + return array + def scala_configured_string(string): return string.format(**scala_configuration()) diff --git a/src/java/io/bazel/rulesscala/scalac/BUILD.bzl b/src/java/io/bazel/rulesscala/scalac/BUILD.bzl index a3e5ed2fc..726c334b3 100644 --- a/src/java/io/bazel/rulesscala/scalac/BUILD.bzl +++ b/src/java/io/bazel/rulesscala/scalac/BUILD.bzl @@ -2,6 +2,7 @@ load( "@io_bazel_rules_scala_configuration//:scala_configuration.bzl", _scala_configuration = "scala_configuration", _scala_version_configuration = "scala_version_configuration", + _versioned_file = "versioned_file", ) load( ":jvm_export_toolchain.bzl", @@ -23,9 +24,7 @@ def build(): "CompileOptions.java", "Resource.java", "ScalaCInvoker.java", - ] + [ - (native.glob(["ScalacProcessor_{scala_mvn_version}.java".format(**configuration)]) + ["ScalacProcessor.java"])[0], - ], + ] + _versioned_file("ScalacProcessor.java", version), javacopts = [ "-source 1.8", "-target 1.8",