2019-08-13 19:23:03 +03:00
|
|
|
# Copyright (c) 2019 The DAML Authors. All rights reserved.
|
2019-04-04 11:33:38 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2019-04-12 14:10:16 +03:00
|
|
|
load("//bazel_tools:scala.bzl", "da_scala_binary", "da_scala_library")
|
2019-04-04 11:33:38 +03:00
|
|
|
|
|
|
|
da_scala_binary(
|
|
|
|
name = "compiler_plugin",
|
|
|
|
srcs = glob(["*.scala"]),
|
2019-07-10 00:17:59 +03:00
|
|
|
main_class = "com.digitalasset.protoc.plugins.scalapb.ScalaPbCompilerPlugin",
|
2019-04-04 11:33:38 +03:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
runtime_deps = [
|
|
|
|
"@com_github_scalapb_scalapb//:scala-library",
|
|
|
|
],
|
|
|
|
deps = [
|
2019-10-28 15:53:14 +03:00
|
|
|
"@maven//:com_google_protobuf_protobuf_java",
|
|
|
|
"@maven//:com_thesamet_scalapb_compilerplugin_2_12",
|
|
|
|
"@maven//:com_thesamet_scalapb_protoc_bridge_2_12",
|
2019-04-04 11:33:38 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# From https://github.com/stackb/rules_proto/blob/3f890f5d6774bd74df28e89b20f34155dfe77732/scala/BUILD.bazel#L78-L97
|
|
|
|
# Curiously this didn't work
|
|
|
|
#
|
|
|
|
# genrule(
|
|
|
|
# name = "gen_protoc_gen_scala",
|
|
|
|
# srcs = ["compiler_plugin_deploy.jar", "@local_jdk//:bin/java"],
|
|
|
|
# outs = ["protoc-gen-scala.sh"],
|
|
|
|
# cmd = """
|
|
|
|
# echo '$(location @local_jdk//:bin/java) -jar $(location protoc_gen_deploy.jar) $$@' > $@
|
|
|
|
# """,
|
|
|
|
# executable = True,
|
|
|
|
# )
|
|
|
|
|
|
|
|
# ======================================================================
|
|
|
|
#
|
|
|
|
# Unable to get either bazel or maybe protoc to call a plugin whose
|
|
|
|
# implementation was fronted by a shell script (from a genrule). So, the only
|
|
|
|
# way this seemed to work was compile an executable that calls 'java -jar
|
|
|
|
# protoc_gen_scala_deploy.jar'. Either figure out how to do this in java
|
|
|
|
# directly or write the wrapper in C++ ot remove the go dependency here.
|
|
|
|
#
|
|
|
|
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
|
|
|
|
|
|
|
go_library(
|
|
|
|
name = "go_default_library",
|
|
|
|
srcs = [
|
|
|
|
"protoc-gen-scalapb.go",
|
|
|
|
],
|
2019-04-04 12:34:15 +03:00
|
|
|
importpath = "github.com/digital-asset/daml/scala/protoc-gen-scalapb",
|
2019-04-04 11:33:38 +03:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
go_binary(
|
|
|
|
name = "protoc-gen-scalapb",
|
|
|
|
data = [
|
|
|
|
":compiler_plugin_deploy.jar",
|
|
|
|
"@bazel_tools//tools/jdk:jre",
|
|
|
|
],
|
|
|
|
embed = [":go_default_library"],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|