forked from cilium/proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.api
105 lines (90 loc) · 4.81 KB
/
Makefile.api
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright 2018 Authors of Cilium
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include Makefile.quiet
# Depends on Envoy dependencies, Envoy must be built first
PROTOC ?= bazel-out/host/bin/external/com_google_protobuf/protoc
ENVOY_API_PROTO_PATH = bazel-proxy/external/envoy/api
CILIUM_PROTO_PATH = .
PROTO_DEPS = \
-I bazel-proxy/external/com_google_protobuf/src \
-I bazel-proxy/external/com_google_googleapis \
-I bazel-proxy/external/com_envoyproxy_protoc_gen_validate \
-I bazel-proxy/external/opencensus_proto \
-I bazel-proxy/external/prometheus_metrics_model \
-I bazel-proxy/external/com_github_cncf_udpa
GO_OUT = go
# Skip draft Envoy APIs that do not compile.
ENVOY_RAW_PROTOS := $(strip $(shell find -H $(ENVOY_API_PROTO_PATH)/envoy \( -name *.proto \) -print))
ENVOY_API_PROTOS := $(subst $(ENVOY_API_PROTO_PATH)/,,$(ENVOY_RAW_PROTOS))
ENVOY_PROTO_SOURCES := $(addprefix $(ENVOY_API_PROTO_PATH)/,$(ENVOY_API_PROTOS))
ENVOY_PROTO_DIRS := $(sort $(dir $(ENVOY_PROTO_SOURCES)))
# Produce a raw list of package mappings
RAW_GO_MAPPINGS := $(foreach proto,$(ENVOY_API_PROTOS),$(proto)=github.com/cilium/proxy/go/$(dir $(proto)))
CILIUM_PROTO_SOURCES := \
cilium/api/accesslog.proto \
cilium/api/bpf_metadata.proto \
cilium/api/l7policy.proto \
cilium/api/network_filter.proto \
cilium/api/npds.proto \
cilium/api/nphds.proto
CILIUM_PROTO_DIRS := $(sort $(dir $(CILIUM_PROTO_SOURCES)))
RAW_GO_MAPPINGS += $(foreach proto,$(CILIUM_PROTO_SOURCES),$(proto)=github.com/cilium/proxy/go/$(dir $(proto)))
# Add mappings to vendored dependencies
RAW_GO_MAPPINGS += gogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto/
RAW_GO_MAPPINGS += google/rpc/status.proto=google.golang.org/genproto/googleapis/rpc/status/
RAW_GO_MAPPINGS += metrics.proto=github.com/prometheus/client_model/go/
RAW_GO_MAPPINGS += udpa/annotations/migrate.proto=github.com/cncf/udpa/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/sensitive.proto=github.com/cncf/udpa/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/status.proto=github.com/cncf/udpa/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/versioning.proto=github.com/cncf/udpa/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/security.proto=github.com/cncf/udpa/go/udpa/annotations/
RAW_GO_MAPPINGS += xds/core/v3/collection_entry.proto=github.com/cncf/udpa/go/xds/core/v3/
RAW_GO_MAPPINGS += xds/core/v3/authority.proto=github.com/cncf/udpa/go/xds/core/v3/
# Add mapping separators and remove the trailing slash
# but first create "/ " and ",M"
file_sep := /
file_sep +=
map_sep := ,M
GO_MAPPINGS := $(patsubst %/,%,$(map_sep)$(subst $(file_sep),$(map_sep),$(RAW_GO_MAPPINGS)))
all: godeps $(ENVOY_API_PROTO_PATH) envoy-go-targets cilium-go-targets
.PHONY: envoy-go-targets
envoy-go-targets: $(ENVOY_PROTO_SOURCES) Makefile.api
$(QUIET)set -e; \
for path in $(ENVOY_PROTO_DIRS) ; do \
$(ECHO_GEN) envoy/$$path; \
$(PROTOC) -I $(ENVOY_API_PROTO_PATH) -I $(CILIUM_PROTO_PATH) $(PROTO_DEPS) --go_out=plugins=grpc$(GO_MAPPINGS):$(GO_OUT) $${path}*.proto; \
done
.PHONY: cilium-go-targets
cilium-go-targets: $(CILIUM_PROTO_SOURCES) Makefile.api
$(QUIET)set -e; \
for path in $(CILIUM_PROTO_DIRS) ; do \
$(ECHO_GEN) envoy/$$path; \
$(PROTOC) -I $(ENVOY_API_PROTO_PATH) -I $(CILIUM_PROTO_PATH) $(PROTO_DEPS) --go_out=plugins=grpc$(GO_MAPPINGS):$(GO_OUT) --validate_out=lang=go$(GO_MAPPINGS):$(GO_OUT) $${path}*.proto; \
done
godeps:
# @envoy//api/bazel/repository_locations.bzl
GO111MODULE=on go get github.com/cncf/udpa@cc1b757b3eddccaaaf0743cbb107742bb7e3ee4f
GO111MODULE=on go get github.com/census-instrumentation/[email protected]
GO111MODULE=on go get github.com/envoyproxy/protoc-gen-validate@872b28c457822ed9c2a5405da3c33f386ac0e86f
GO111MODULE=on go get github.com/prometheus/client_model@60555c9708c786597e6b07bf846d0dc5c2a46f54
# Latest and/or matching cilium/cilium/go.mod:
GO111MODULE=on go get google.golang.org/genproto/...@44e461bb6506
GO111MODULE=on go get google.golang.org/protobuf/[email protected]
GO111MODULE=on go get google.golang.org/[email protected]
GO111MODULE=on go get github.com/golang/[email protected]
GO111MODULE=on go get github.com/golang/protobuf/[email protected]
GO111MODULE=on go install github.com/golang/protobuf/[email protected]
GO111MODULE=on go install github.com/envoyproxy/protoc-gen-validate@872b28c457822ed9c2a5405da3c33f386ac0e86f
go mod tidy
.PHONY: all