forked from pactflow/pact-protobuf-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
78 lines (67 loc) · 2.24 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package(default_visibility = ["//visibility:public"])
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@crate_index_protobuf//:defs.bzl", "all_crate_deps")
load("//:toolchains.bzl", "pact_protobuf_plugin_toolchain")
# This will run the build script from the root of the workspace, and
# collect the outputs.
cargo_build_script(
name = "build_script",
srcs = ["build.rs"],
deps = all_crate_deps(build = "True"),
build_script_env = {
"CARGO_PKG_VERSION": "1.0.0",
"CARGO_PKG_VERSION_MAJOR": "1",
"CARGO_PKG_VERSION_MINOR": "0",
"CARGO_PKG_VERSION_PATCH": "0",
"CARGO_PKG_VERSION_PRE": "",
"CARGO_PKG_AUTHORS": "pact",
"CARGO_PKG_DESCRIPTION": "plop",
"CARGO_PKG_HOMEPAGE": "http://perdu.com",
"CARGO_PKG_LICENSE": "free",
"CARGO_PKG_REPOSITORY": "git",
"RUSTDOC": "$(execpath @rust_darwin_x86_64__x86_64-apple-darwin__stable_tools//:rustdoc)",
},
tools = ["@rust_darwin_x86_64__x86_64-apple-darwin__stable_tools//:rustdoc"],
)
rust_library(
name = "pact_protobuf_plugin",
srcs = glob(["src/**/*.rs"]),
deps = all_crate_deps(normal = "True") + [":build_script"]
)
rust_binary(
name = "pact_protobuf_plugin_bin",
srcs = ["src/main.rs"],
deps = all_crate_deps(normal = "True") + [":pact_protobuf_plugin"],
)
filegroup(
name = "pact-plugin",
srcs = ['pact-plugin.json'],
visibility = ["//visibility:public"],
)
pact_protobuf_plugin_toolchain(
name = "toolchain_impl",
protobuf_plugin = ":pact_prototuf_plugin_toolchain",
manifest = ":pact_plugin_json_archive"
)
genrule(
name = "pact_plugin_json_archive",
outs = ["pact-plugin.json"],
srcs = ["@pact_plugin_json_archive//file"],
cmd = "cp $< $@",
)
genrule(
name = "pact_prototuf_plugin_toolchain",
outs = ["pact-protobuf-plugin"],
srcs = ["@pact_prototuf_plugin_archive//file"],
cmd = "gzip -d - < $< > $@",
)
toolchain(
name = "toolchain",
toolchain = ":toolchain_impl",
toolchain_type = ":toolchain_type",
)
toolchain_type(
name = "toolchain_type",
visibility = ["//visibility:public"],
)