# Copyright (c) 2022, Google, Inc. All rights reserved # # 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. #
# Invoke a protoc command with a custom plugin for protobuf-driven code # generation and build a library from the generated sources. # # args: # MODULE : module name (required) # MODULE_PROTOC_PLUGIN: path to a python protoc plugin (required) # MODULE_PROTOC_PLUGIN_FLAGS: optional flags for the custom plugin # shared via env variable # MODULE_PROTOS: list of PROTO files # MODULE_PROTO_PACKAGE: a path that matches the directory structure of # the PROTO package utilized in the module.
ifeq ($(PROTOC_TOOL),)
$(error No PROTOC_TOOL. Please build the aprotoc or checkout with trusty manifest) endif
ifeq ($(MODULE_PROTOC_PLUGIN),)
$(error No MODULE_PROTOC_PLUGIN provided for $(MODULE)) endif
# WARNING: this implies all sources are under the same package. # TODO(b/259511922): support multiple packages.
MODULE_SRCS := $(call TOBUILDDIR,$(patsubst %.proto,%.c,$(MODULE_PROTOS)))
MODULE_PROTO_OUT_DIR := $(sort $(dir $(subst $(MODULE_PROTO_PACKAGE),,$(MODULE_SRCS))))
# TODO: support multiple, disparate packages; # the output directory for the tool should be at the root of # the package path.
$(MODULE_SRCS): PROTOC_TOOL := $(PROTOC_TOOL)
$(MODULE_SRCS): MODULE_PROTOC_PLUGIN := $(MODULE_PROTOC_PLUGIN)
$(MODULE_SRCS): MODULE_PROTOC_PLUGIN_FLAGS := $(MODULE_PROTOC_PLUGIN_FLAGS)
$(MODULE_SRCS): MODULE_PROTO_PACKAGE := $(MODULE_PROTO_PACKAGE)
$(MODULE_SRCS): MODULE_PROTO_OUT_DIR := $(MODULE_PROTO_OUT_DIR)
$(MODULE_SRCS): $(BUILDDIR)/%.c: %.proto $(MODULE_PROTOC_PLUGIN) $(PROTOC_TOOL)
@$(MKDIR)
@echo generating $@ from PROTO
$(NOECHO)$(PROTOC_TOOL) \
--plugin=protoc-gen-custom-plugin=$(MODULE_PROTOC_PLUGIN) \
--custom-plugin_out=$(MODULE_PROTO_OUT_DIR) \
--custom-plugin_opt=pkg:$(MODULE_PROTO_PACKAGE),$(MODULE_PROTOC_PLUGIN_FLAGS) \
$<
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.