blob: 869805208a5f2cfac6852875d6dd814be3dd28ee [file] [log] [blame]
Primiano Tuccifd484232017-10-25 00:15:39 +01001# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080015import("//build_overrides/build.gni")
Primiano Tuccifd484232017-10-25 00:15:39 +010016
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080017if (!build_with_chromium) {
18 import("//build/proto_library.gni")
19} else {
20 import("//third_party/protobuf/proto_library.gni")
21}
22
23# Equivalent to proto_library (generation of .h/.cc from .proto files) but
Primiano Tuccifd484232017-10-25 00:15:39 +010024# enables also generation using the protozero plugin.
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080025# The generated files will have the .pbzero.{cc,h} suffix, as opposed to the
Primiano Tuccifd484232017-10-25 00:15:39 +010026# .pb.{cc,h} of the official proto library.
27template("protozero_library") {
28 proto_library(target_name) {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080029 perfetto_root_path = invoker.perfetto_root_path
30
Primiano Tucci782374f2017-11-27 16:25:20 +000031 generate_cc = false
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080032 generator_plugin_label = perfetto_root_path + "protozero/src/protoc_plugin"
Primiano Tuccifd484232017-10-25 00:15:39 +010033 generator_plugin_suffix = ".pbzero"
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080034
35 if (!defined(invoker.public_configs)) {
36 public_configs = []
37 }
38
Primiano Tucci782374f2017-11-27 16:25:20 +000039 if (defined(invoker.deps)) {
40 deps = invoker.deps
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080041 } else {
42 deps = []
Primiano Tucci782374f2017-11-27 16:25:20 +000043 }
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080044
45 deps += [ perfetto_root_path + "protozero" ]
46
47 public_configs += [ "//protozero:protozero_config" ]
48
Primiano Tuccifd484232017-10-25 00:15:39 +010049 forward_variables_from(invoker,
50 [
51 "defines",
Primiano Tucci782374f2017-11-27 16:25:20 +000052 "generator_plugin_options",
Primiano Tuccifd484232017-10-25 00:15:39 +010053 "include_dirs",
54 "proto_in_dir",
55 "proto_out_dir",
56 "sources",
57 "testonly",
58 "visibility",
59 ])
60 }
61}