Skip to content

Commit fadf893

Browse files
authored
C++ bazel rules for API (#199)
* first try * fixes * build failure test
1 parent 3e3fd02 commit fadf893

File tree

10 files changed

+103
-36
lines changed

10 files changed

+103
-36
lines changed

BUILD

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package(default_visibility = ["//visibility:public"])
22

33
licenses(["notice"])
44

5-
load("@io_bazel_rules_go//go:def.bzl", "gazelle", "go_prefix")
5+
load("@io_bazel_rules_go//go:def.bzl", "go_prefix")
66

77
go_prefix("istio.io/api")
8-
9-
gazelle(name = "gazelle")

WORKSPACE

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,3 @@ go_repositories()
1313
load("//:api.bzl", "go_istio_api_dependencies")
1414

1515
go_istio_api_dependencies()
16-
17-
bind(
18-
name = "protoc",
19-
actual = "@com_github_google_protobuf//:protoc",
20-
)
21-
22-
bind(
23-
name = "protocol_compiler",
24-
actual = "@com_github_google_protobuf//:protoc",
25-
)

api.bzl

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
load("@io_bazel_rules_go//go:def.bzl", "go_repository")
22

3-
def go_istio_api_dependencies():
3+
def protobuf_repositories(bind=True):
4+
PROTOBUF_SHA = "c4083bb3d1231f8a94f2f000434e38528bdff64a" # Oct 10, 2017
5+
6+
native.http_archive(
7+
name = "com_google_protobuf",
8+
strip_prefix = "protobuf-" + PROTOBUF_SHA,
9+
urls = ["https://github.com/google/protobuf/archive/" + PROTOBUF_SHA + ".tar.gz"],
10+
)
11+
12+
native.http_archive(
13+
name = "com_google_protobuf_cc",
14+
strip_prefix = "protobuf-" + PROTOBUF_SHA,
15+
urls = ["https://github.com/google/protobuf/archive/" + PROTOBUF_SHA + ".tar.gz"],
16+
)
17+
18+
native.http_archive(
19+
name = "com_github_google_protobuf",
20+
strip_prefix = "protobuf-" + PROTOBUF_SHA,
21+
urls = ["https://github.com/google/protobuf/archive/" + PROTOBUF_SHA + ".tar.gz"],
22+
)
23+
24+
if bind:
25+
native.bind(
26+
name = "protoc",
27+
actual = "@com_google_protobuf//:protoc",
28+
)
29+
30+
native.bind(
31+
name = "protocol_compiler",
32+
actual = "@com_google_protobuf//:protoc",
33+
)
34+
35+
def go_istio_api_dependencies(bind=True):
36+
protobuf_repositories(bind)
37+
438
native.git_repository(
539
name = "org_pubref_rules_protobuf",
640
commit = "eafd42ce6471ce3ea265729c85e18e6180dea620", # Sept 22, 2017 (genfiles path calculation fix)
741
remote = "https://github.com/pubref/rules_protobuf",
842
)
943

10-
native.git_repository(
11-
name = "com_github_google_protobuf",
12-
commit = "52ab3b07ac9a6889ed0ac9bf21afd8dab8ef0014", # Oct 4, 2016 (match pubref dep)
13-
remote = "https://github.com/google/protobuf.git",
14-
)
15-
1644
go_repository(
1745
name = "com_github_golang_glog",
1846
commit = "23def4e6c14b4da8ac2ed8007337bc5eb5007998", # Jan 26, 2016 (no releases)
@@ -113,7 +141,7 @@ cc_proto_library(
113141
"google/rpc/status.proto",
114142
],
115143
imports = [
116-
"../../external/com_github_google_protobuf/src",
144+
"../../external/com_google_protobuf/src",
117145
],
118146
verbose = 0,
119147
)

gogoproto/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
proto_library(
4+
name = "gogoproto_protos",
5+
srcs = [":gogo.proto"],
6+
deps = [
7+
"@com_google_protobuf//:any_proto",
8+
"@com_google_protobuf//:descriptor_proto",
9+
],
10+
)
11+
12+
genrule(
13+
name = "status_proto",
14+
srcs = ["@com_github_gogo_protobuf//gogoproto:go_default_library_protos"],
15+
outs = ["gogo.proto"],
16+
cmd = "cat $(location @com_github_gogo_protobuf//gogoproto:go_default_library_protos) > $@",
17+
)

google/rpc/BUILD

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,32 @@ gogoslick_proto_library(
1010
"google/protobuf/duration.proto": "github.com/gogo/protobuf/types",
1111
},
1212
imports = [
13-
"external/com_github_google_protobuf/src",
14-
"../../external/com_github_google_protobuf/src",
13+
"external/com_google_protobuf/src",
14+
"../../external/com_google_protobuf/src",
1515
],
1616
inputs = [
17-
"@com_github_google_protobuf//:well_known_protos",
17+
"@com_google_protobuf//:well_known_protos",
1818
],
1919
deps = [
2020
"@com_github_gogo_protobuf//types:go_default_library",
2121
],
2222
verbose = 0,
2323
)
2424

25+
cc_proto_library(
26+
name = "cc_protos",
27+
deps = [":rpc_protos"],
28+
)
29+
30+
proto_library(
31+
name = "rpc_protos",
32+
srcs = [":protos"],
33+
deps = [
34+
"@com_google_protobuf//:any_proto",
35+
"@com_google_protobuf//:duration_proto",
36+
],
37+
)
38+
2539
filegroup(
2640
name = "protos",
2741
srcs = [

mixer/v1/BUILD

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ gogoslick_proto_library(
1010
},
1111
imports = [
1212
"external/com_github_gogo_protobuf",
13-
"external/com_github_google_protobuf/src",
13+
"external/com_google_protobuf/src",
1414
"external/com_github_googleapis_googleapis",
1515
"../../external/com_github_gogo_protobuf",
16-
"../../external/com_github_google_protobuf/src",
16+
"../../external/com_google_protobuf/src",
1717
"../../external/com_github_googleapis_googleapis",
1818
],
1919
inputs = [
20-
"@com_github_google_protobuf//:well_known_protos",
20+
"@com_google_protobuf//:well_known_protos",
2121
"@com_github_googleapis_googleapis//:status_proto",
2222
"@com_github_gogo_protobuf//gogoproto:go_default_library_protos",
2323
],
@@ -33,6 +33,25 @@ gogoslick_proto_library(
3333
],
3434
)
3535

36+
cc_proto_library(
37+
name = "cc_protos",
38+
deps = [":mixer_protos"],
39+
visibility = ["//visibility:public"],
40+
)
41+
42+
proto_library(
43+
name = "mixer_protos",
44+
srcs = [":protos"],
45+
deps = [
46+
"@com_google_protobuf//:any_proto",
47+
"@com_google_protobuf//:duration_proto",
48+
"@com_google_protobuf//:timestamp_proto",
49+
"//gogoproto:gogoproto_protos",
50+
"//google/rpc:rpc_protos",
51+
],
52+
visibility = ["//visibility:public"],
53+
)
54+
3655
filegroup(
3756
name = "protos",
3857
srcs = [

mixer/v1/config/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ gogo_proto_compile(
1616
"mixer/v1/config/descriptor/value_type.proto": "istio.io/api/mixer/v1/config/descriptor",
1717
},
1818
imports = [
19-
"external/com_github_google_protobuf/src",
20-
"../../external/com_github_google_protobuf/src",
19+
"external/com_google_protobuf/src",
20+
"../../external/com_google_protobuf/src",
2121
],
2222
inputs = [
2323
"//mixer/v1/config/descriptor:protos",
24-
"@com_github_google_protobuf//:well_known_protos",
24+
"@com_google_protobuf//:well_known_protos",
2525
],
2626
protos = [
2727
"cfg.proto",

mixer/v1/config/descriptor/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ gogoslick_proto_library(
66
"google/protobuf/duration.proto": "github.com/gogo/protobuf/types",
77
},
88
imports = [
9-
"external/com_github_google_protobuf/src",
10-
"../../external/com_github_google_protobuf/src",
9+
"external/com_google_protobuf/src",
10+
"../../external/com_google_protobuf/src",
1111
],
1212
inputs = [
13-
"@com_github_google_protobuf//:well_known_protos",
13+
"@com_google_protobuf//:well_known_protos",
1414
],
1515
protos = [
1616
":protos",

mixer/v1/template/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ gogoslick_proto_library(
66
"google/protobuf/descriptor.proto": "github.com/gogo/protobuf/protoc-gen-gogo/descriptor",
77
},
88
imports = [
9-
"external/com_github_google_protobuf/src",
10-
"../../external/com_github_google_protobuf/src",
9+
"external/com_google_protobuf/src",
10+
"../../external/com_google_protobuf/src",
1111
],
1212
inputs = [
13-
"@com_github_google_protobuf//:well_known_protos",
13+
"@com_google_protobuf//:well_known_protos",
1414
],
1515
protos = [":protos"],
1616
verbose = 0,

prow/api-presubmit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ set -u
2727
set -x
2828

2929
echo "=== Bazel Build ==="
30+
bazel version
3031
bazel build //...
3132

0 commit comments

Comments
 (0)