https://github.com/cilium/cilium
Raw File
Tip revision: 5e0516a31348f0d9cc1d84b7428f197c3dfefcdb authored by Ian Vernon on 10 April 2018, 21:21:58 UTC
test/k8sT: do not defer deletion of resources within It
Tip revision: 5e0516a
Makefile.api
# 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-envoy/external/envoy_api
CILIUM_PROTO_PATH = .
PROTO_DEPS = \
	-I bazel-envoy/external/com_google_protobuf/src \
	-I bazel-envoy/external/googleapis \
	-I bazel-envoy/external/com_lyft_protoc_gen_validate \
	-I bazel-envoy/external/com_github_gogo_protobuf

GO_OUT = ../pkg/envoy

# Skip draft Envoy APIs that do not compile.
ENVOY_RAW_PROTOS := $(strip $(shell find -H $(ENVOY_API_PROTO_PATH)/envoy \( -name *.proto -and -not -path *service/trace/v2* -and -not -path *service/metrics/v2* \) -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)))
ENVOY_GO_TARGETS := $(addprefix $(GO_OUT)/,$(ENVOY_API_PROTOS:.proto=.pb.go))
# Produce a raw list of package mappings
RAW_GO_MAPPINGS := $(foreach proto,$(ENVOY_API_PROTOS),$(proto)=github.com/cilium/cilium/pkg/envoy/$(dir $(proto)))

CILIUM_PROTO_SOURCES := \
	cilium/accesslog.proto \
	cilium/cilium_bpf_metadata.proto \
	cilium/cilium_l7policy.proto \
	cilium/npds.proto \
	cilium/nphds.proto
CILIUM_PROTO_DIRS := $(sort $(dir $(CILIUM_PROTO_SOURCES)))
CILIUM_GO_TARGETS := $(addprefix $(GO_OUT)/,$(CILIUM_PROTO_SOURCES:.proto=.pb.go)) \
	$(addprefix $(GO_OUT)/,$(CILIUM_PROTO_SOURCES:.proto=.pb.validate.go))
RAW_GO_MAPPINGS += $(foreach proto,$(CILIUM_PROTO_SOURCES),$(proto)=github.com/cilium/cilium/pkg/envoy/$(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/

# 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: $(ENVOY_API_PROTO_PATH) $(ENVOY_GO_TARGETS) $(CILIUM_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

$(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_OUT) $${path}*.proto; \
	done

.PHONY: all
back to top