blob: 94966415955e470453407d00433bab327fe56c74 [file] [log] [blame]
# Helper file to convert text format protobuf files to binary format.
# Note: This file is similar to proto_library.gni, but is kept separate because
# - They expect different inputs/outputs: both rules would have to set default
# values for variables that are not really sensible.
# To use this rule, add a target to your gn file defining:
# protoc_proto_dir: The directory where the proto definition can be found.
# protoc_proto_def: Relative path to proto definition from |protoc_proto_dir|.
# protoc_message_name: The fully qualified name of the message contained in
# the protobuf.
# protoc_text_dir: The directory where the text format protobuf[s] can be found.
# protoc_bin_dir: The full path to the output directory. Note that this path is
# not relative to the <(SHARED_INTERMEDIATE_DIR). You must ensure that this
# directory is unique across all platform2 projects to avoid collisions. One
# way to do this is to include your project name in the directory path.
# Finally, specify the protobuf files in text format as the sources. These files
# should have a '.prototxt' file extension.
template("protoc_text_to_bin") {
action_name = "${target_name}_gen"
action_foreach(action_name) {
visibility = [ ":*" ]
# Sources might be generated by actions in deps,
# which must be explicitly specified.
protoc_proto_dir = rebase_path(protoc_proto_dir)
protoc_text_dir = rebase_path(protoc_text_dir)
sources = invoker.sources
script = "//common-mk/"
args = [
outputs = [ "${protoc_bin_dir}/{{source_name_part}}.pbf" ]
source_set(target_name) {
if (defined(invoker.configs)) {
configs += invoker.configs
data = get_target_outputs(":${action_name}")
deps = [ ":${action_name}" ]
if (defined(invoker.deps)) {
deps += invoker.deps