-
Notifications
You must be signed in to change notification settings - Fork 54
/
Makefile.api
123 lines (106 loc) · 6.41 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# 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 API & protoc 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/opentelemetry_proto \
-I bazel-proxy/external/prometheus_metrics_model \
-I bazel-proxy/external/com_github_cncf_xds
GO_OUT = go
# Skip draft Envoy APIs that do not compile.
ENVOY_RAW_PROTOS := $(strip $(shell find -H $(ENVOY_API_PROTO_PATH)/envoy -not -path "*/v*alpha*" -not -path "*/v2/*" \( -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)))
CONTRIB_RAW_PROTOS := $(strip $(shell find -H $(ENVOY_API_PROTO_PATH)/contrib -not -path "*/v3alpha*" \( -name *.proto \) -print))
CONTRIB_API_PROTOS := $(subst $(ENVOY_API_PROTO_PATH)/,,$(CONTRIB_RAW_PROTOS))
CONTRIB_PROTO_SOURCES := $(addprefix $(ENVOY_API_PROTO_PATH)/,$(CONTRIB_API_PROTOS))
CONTRIB_PROTO_DIRS := $(sort $(dir $(CONTRIB_PROTO_SOURCES)))
# Produce a raw list of package mappings
RAW_GO_MAPPINGS += $(foreach proto,$(CONTRIB_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/xds/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/sensitive.proto=github.com/cncf/xds/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/status.proto=github.com/cncf/xds/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/versioning.proto=github.com/cncf/xds/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/security.proto=github.com/cncf/xds/go/udpa/annotations/
RAW_GO_MAPPINGS += udpa/annotations/deprecation.proto=github.com/cncf/xds/go/udpa/annotations/
RAW_GO_MAPPINGS += xds/core/v3/collection_entry.proto=github.com/cncf/xds/go/xds/core/v3/
RAW_GO_MAPPINGS += xds/core/v3/authority.proto=github.com/cncf/xds/go/xds/core/v3/
RAW_GO_MAPPINGS += xds/core/v3/context_params.proto=github.com/cncf/xds/go/xds/core/v3/
RAW_GO_MAPPINGS += xds/core/v3/resource_locator.proto=github.com/cncf/xds/go/xds/core/v3/
RAW_GO_MAPPINGS += xds/annotations/v3/status.proto=github.com/cncf/xds/go/xds/annotations/v3/
RAW_GO_MAPPINGS += opentelemetry/proto/common/v1/common.proto=go.opentelemetry.io/proto/otlp/common/v1/
# Add mapping separators and remove the trailing slash
# but first create "/ " and ",M"
E =
file_sep := / $E
map_sep := ,M
GO_MAPPINGS := $(patsubst %/,%,$(map_sep)$(subst $(file_sep),$(map_sep),$(RAW_GO_MAPPINGS)))
export PATH:=$(HOME)/go/bin:$(PATH)
all: godeps cilium-go-targets
.PHONY: envoy-go-targets
envoy-go-targets: $(ENVOY_PROTO_SOURCES) $(ENVOY_API_PROTO_PATH) 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)" --go_opt=module=github.com/cilium/proxy/go "--validate_out=lang=go$(GO_MAPPINGS):$(GO_OUT)" --validate_opt=module=github.com/envoyproxy/go-control-plane $${path}*.proto; \
done
.PHONY: contrib-go-targets
contrib-go-targets: $(CONTRIB_PROTO_SOURCES) $(ENVOY_API_PROTO_PATH) Makefile.api envoy-go-targets
$(QUIET)set -e; \
for path in $(CONTRIB_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)" --go_opt=module=github.com/cilium/proxy/go "--validate_out=lang=go$(GO_MAPPINGS):$(GO_OUT)/contrib/envoy" --validate_opt=module=github.com/envoyproxy/go-control-plane/envoy $${path}*.proto; \
done
.PHONY: cilium-go-targets
cilium-go-targets: $(CILIUM_PROTO_SOURCES) $(ENVOY_API_PROTO_PATH) Makefile.api contrib-go-targets
$(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)" --go_opt=module=github.com/cilium/proxy/go "--validate_out=lang=go$(GO_MAPPINGS):$(GO_OUT)" --validate_opt=module=github.com/cilium/proxy/go $${path}*.proto; \
done
go mod tidy && go mod vendor
godeps:
# We have Renovate updating Go dependencies for us now
#
# Have to keep using github.com/golang/[email protected] version of protoc-gen-go to retain grpc
# plugin support needed by Envoy API protos.
# - google.golang.org/protobuf version of protoc-gen-go needs a separate protoc plugin for grpc,
# which also changes Go module name generation so that upstream Envoy API protos do not work any more.
# - >v1.5.0 changes the Go module name generation so that upstream Envoy API protos do not work any more.
GO111MODULE=on go install github.com/golang/protobuf/[email protected]
GO111MODULE=on go install github.com/envoyproxy/[email protected]
.PHONY: all