Primiano Tucci | fd48423 | 2017-10-25 00:15:39 +0100 | [diff] [blame] | 1 | # 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 Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 15 | import("//build_overrides/build.gni") |
Primiano Tucci | fd48423 | 2017-10-25 00:15:39 +0100 | [diff] [blame] | 16 | |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 17 | if (!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 Tucci | fd48423 | 2017-10-25 00:15:39 +0100 | [diff] [blame] | 24 | # enables also generation using the protozero plugin. |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 25 | # The generated files will have the .pbzero.{cc,h} suffix, as opposed to the |
Primiano Tucci | fd48423 | 2017-10-25 00:15:39 +0100 | [diff] [blame] | 26 | # .pb.{cc,h} of the official proto library. |
| 27 | template("protozero_library") { |
| 28 | proto_library(target_name) { |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 29 | perfetto_root_path = invoker.perfetto_root_path |
| 30 | |
Primiano Tucci | 782374f | 2017-11-27 16:25:20 +0000 | [diff] [blame] | 31 | generate_cc = false |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 32 | generator_plugin_label = perfetto_root_path + "protozero/src/protoc_plugin" |
Primiano Tucci | fd48423 | 2017-10-25 00:15:39 +0100 | [diff] [blame] | 33 | generator_plugin_suffix = ".pbzero" |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 34 | |
| 35 | if (!defined(invoker.public_configs)) { |
| 36 | public_configs = [] |
| 37 | } |
| 38 | |
Primiano Tucci | 782374f | 2017-11-27 16:25:20 +0000 | [diff] [blame] | 39 | if (defined(invoker.deps)) { |
| 40 | deps = invoker.deps |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 41 | } else { |
| 42 | deps = [] |
Primiano Tucci | 782374f | 2017-11-27 16:25:20 +0000 | [diff] [blame] | 43 | } |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 44 | |
| 45 | deps += [ perfetto_root_path + "protozero" ] |
| 46 | |
| 47 | public_configs += [ "//protozero:protozero_config" ] |
| 48 | |
Primiano Tucci | fd48423 | 2017-10-25 00:15:39 +0100 | [diff] [blame] | 49 | forward_variables_from(invoker, |
| 50 | [ |
| 51 | "defines", |
Primiano Tucci | 782374f | 2017-11-27 16:25:20 +0000 | [diff] [blame] | 52 | "generator_plugin_options", |
Primiano Tucci | fd48423 | 2017-10-25 00:15:39 +0100 | [diff] [blame] | 53 | "include_dirs", |
| 54 | "proto_in_dir", |
| 55 | "proto_out_dir", |
| 56 | "sources", |
| 57 | "testonly", |
| 58 | "visibility", |
| 59 | ]) |
| 60 | } |
| 61 | } |