Jason Graffius | 9783fdd | 2020-11-12 23:03:15 -0800 | [diff] [blame] | 1 | # Copyright 2020 The Pigweed Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | # use this file except in compliance with the License. You may obtain a copy of |
| 5 | # the License at |
| 6 | # |
| 7 | # https://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, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations under |
| 13 | # the License. |
| 14 | |
| 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_build/target_types.gni") |
Zihan Chen | cd66a74 | 2021-09-08 15:30:43 -0700 | [diff] [blame] | 18 | import("$dir_pw_protobuf_compiler/proto.gni") |
Jason Graffius | 9783fdd | 2020-11-12 23:03:15 -0800 | [diff] [blame] | 19 | import("protobuf.gni") |
| 20 | |
| 21 | # This file defines a GN source_set for an external installation of protobuf. |
| 22 | # To use, checkout the protobuf source into a directory, then set the build arg |
| 23 | # dir_pw_third_party_protobuf to point to that directory. The protobuf library |
| 24 | # will be available in GN at "$dir_pw_third_party/protobuf". |
| 25 | # |
| 26 | # This is known to work with commit 300dfcc5bf46d0fae35146db2195891df4959e4 in |
| 27 | # the protobuf repository. These targets may not work with other versions. |
| 28 | # |
| 29 | # If the dir_pw_third_party_protobuf build argument is not set, the protobuf |
| 30 | # targets are effectively disabled. |
| 31 | if (dir_pw_third_party_protobuf != "") { |
| 32 | have_pthreads = current_os == "linux" || current_os == "mac" |
| 33 | |
| 34 | config("includes") { |
| 35 | include_dirs = [ "$dir_pw_third_party_protobuf/src" ] |
| 36 | } |
| 37 | |
| 38 | config("defines") { |
| 39 | defines = [ "HAVE_ZLIB=0" ] |
| 40 | if (have_pthreads) { |
| 41 | defines += [ "HAVE_PTHREAD=1" ] |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | config("cc_flags") { |
| 46 | cflags_cc = [ |
| 47 | "-Wno-cast-qual", |
| 48 | "-Wno-shadow", |
| 49 | "-Wno-sign-compare", |
| 50 | "-Wno-unused-parameter", |
| 51 | ] |
| 52 | } |
| 53 | |
| 54 | pw_source_set("libprotobuf_lite") { |
| 55 | sources = [ |
| 56 | "$dir_pw_third_party_protobuf/src/google/protobuf/any_lite.cc", |
| 57 | "$dir_pw_third_party_protobuf/src/google/protobuf/arena.cc", |
| 58 | "$dir_pw_third_party_protobuf/src/google/protobuf/extension_set.cc", |
| 59 | "$dir_pw_third_party_protobuf/src/google/protobuf/generated_enum_util.cc", |
| 60 | "$dir_pw_third_party_protobuf/src/google/protobuf/generated_message_table_driven_lite.cc", |
| 61 | "$dir_pw_third_party_protobuf/src/google/protobuf/generated_message_util.cc", |
| 62 | "$dir_pw_third_party_protobuf/src/google/protobuf/implicit_weak_message.cc", |
| 63 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/coded_stream.cc", |
| 64 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/io_win32.cc", |
| 65 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/strtod.cc", |
| 66 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/zero_copy_stream.cc", |
| 67 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc", |
| 68 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc", |
| 69 | "$dir_pw_third_party_protobuf/src/google/protobuf/map.cc", |
| 70 | "$dir_pw_third_party_protobuf/src/google/protobuf/message_lite.cc", |
| 71 | "$dir_pw_third_party_protobuf/src/google/protobuf/parse_context.cc", |
| 72 | "$dir_pw_third_party_protobuf/src/google/protobuf/repeated_field.cc", |
| 73 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/bytestream.cc", |
| 74 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/common.cc", |
| 75 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/int128.cc", |
| 76 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/status.cc", |
| 77 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/statusor.cc", |
| 78 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/stringpiece.cc", |
| 79 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/stringprintf.cc", |
| 80 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/structurally_valid.cc", |
| 81 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/strutil.cc", |
| 82 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/time.cc", |
| 83 | "$dir_pw_third_party_protobuf/src/google/protobuf/wire_format_lite.cc", |
| 84 | ] |
| 85 | public_configs = [ |
| 86 | ":includes", |
| 87 | ":cc_flags", |
| 88 | ] |
| 89 | configs = [ ":defines" ] |
| 90 | } |
| 91 | |
| 92 | pw_source_set("libprotobuf") { |
| 93 | sources = [ |
| 94 | "$dir_pw_third_party_protobuf/src/google/protobuf/any.cc", |
| 95 | "$dir_pw_third_party_protobuf/src/google/protobuf/any.pb.cc", |
| 96 | "$dir_pw_third_party_protobuf/src/google/protobuf/api.pb.cc", |
| 97 | "$dir_pw_third_party_protobuf/src/google/protobuf/compiler/importer.cc", |
| 98 | "$dir_pw_third_party_protobuf/src/google/protobuf/compiler/parser.cc", |
| 99 | "$dir_pw_third_party_protobuf/src/google/protobuf/descriptor.cc", |
| 100 | "$dir_pw_third_party_protobuf/src/google/protobuf/descriptor.pb.cc", |
| 101 | "$dir_pw_third_party_protobuf/src/google/protobuf/descriptor_database.cc", |
| 102 | "$dir_pw_third_party_protobuf/src/google/protobuf/duration.pb.cc", |
| 103 | "$dir_pw_third_party_protobuf/src/google/protobuf/dynamic_message.cc", |
| 104 | "$dir_pw_third_party_protobuf/src/google/protobuf/empty.pb.cc", |
| 105 | "$dir_pw_third_party_protobuf/src/google/protobuf/extension_set_heavy.cc", |
| 106 | "$dir_pw_third_party_protobuf/src/google/protobuf/field_mask.pb.cc", |
| 107 | "$dir_pw_third_party_protobuf/src/google/protobuf/generated_message_reflection.cc", |
| 108 | "$dir_pw_third_party_protobuf/src/google/protobuf/generated_message_table_driven.cc", |
| 109 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/gzip_stream.cc", |
| 110 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/printer.cc", |
| 111 | "$dir_pw_third_party_protobuf/src/google/protobuf/io/tokenizer.cc", |
| 112 | "$dir_pw_third_party_protobuf/src/google/protobuf/map_field.cc", |
| 113 | "$dir_pw_third_party_protobuf/src/google/protobuf/message.cc", |
| 114 | "$dir_pw_third_party_protobuf/src/google/protobuf/reflection_ops.cc", |
| 115 | "$dir_pw_third_party_protobuf/src/google/protobuf/service.cc", |
| 116 | "$dir_pw_third_party_protobuf/src/google/protobuf/source_context.pb.cc", |
| 117 | "$dir_pw_third_party_protobuf/src/google/protobuf/struct.pb.cc", |
| 118 | "$dir_pw_third_party_protobuf/src/google/protobuf/stubs/substitute.cc", |
| 119 | "$dir_pw_third_party_protobuf/src/google/protobuf/text_format.cc", |
| 120 | "$dir_pw_third_party_protobuf/src/google/protobuf/timestamp.pb.cc", |
| 121 | "$dir_pw_third_party_protobuf/src/google/protobuf/type.pb.cc", |
| 122 | "$dir_pw_third_party_protobuf/src/google/protobuf/unknown_field_set.cc", |
| 123 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/delimited_message_util.cc", |
| 124 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/field_comparator.cc", |
| 125 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/field_mask_util.cc", |
| 126 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/datapiece.cc", |
| 127 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc", |
| 128 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/error_listener.cc", |
| 129 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/field_mask_utility.cc", |
| 130 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/json_escaping.cc", |
| 131 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/json_objectwriter.cc", |
| 132 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/json_stream_parser.cc", |
| 133 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/object_writer.cc", |
| 134 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/proto_writer.cc", |
| 135 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc", |
| 136 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc", |
| 137 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/type_info.cc", |
| 138 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc", |
| 139 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/internal/utility.cc", |
| 140 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/json_util.cc", |
| 141 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/message_differencer.cc", |
| 142 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/time_util.cc", |
| 143 | "$dir_pw_third_party_protobuf/src/google/protobuf/util/type_resolver_util.cc", |
| 144 | "$dir_pw_third_party_protobuf/src/google/protobuf/wire_format.cc", |
| 145 | "$dir_pw_third_party_protobuf/src/google/protobuf/wrappers.pb.cc", |
| 146 | ] |
| 147 | public_deps = [ ":libprotobuf_lite" ] |
| 148 | configs = [ ":defines" ] |
| 149 | } |
Zihan Chen | cd66a74 | 2021-09-08 15:30:43 -0700 | [diff] [blame] | 150 | |
| 151 | pw_proto_library("wellknown_types") { |
| 152 | sources = [ |
| 153 | "$dir_pw_third_party_protobuf/src/google/protobuf/any.proto", |
| 154 | "$dir_pw_third_party_protobuf/src/google/protobuf/api.proto", |
| 155 | "$dir_pw_third_party_protobuf/src/google/protobuf/descriptor.proto", |
| 156 | "$dir_pw_third_party_protobuf/src/google/protobuf/duration.proto", |
| 157 | "$dir_pw_third_party_protobuf/src/google/protobuf/empty.proto", |
| 158 | "$dir_pw_third_party_protobuf/src/google/protobuf/field_mask.proto", |
| 159 | "$dir_pw_third_party_protobuf/src/google/protobuf/source_context.proto", |
| 160 | "$dir_pw_third_party_protobuf/src/google/protobuf/struct.proto", |
| 161 | "$dir_pw_third_party_protobuf/src/google/protobuf/timestamp.proto", |
| 162 | "$dir_pw_third_party_protobuf/src/google/protobuf/type.proto", |
| 163 | "$dir_pw_third_party_protobuf/src/google/protobuf/wrappers.proto", |
| 164 | ] |
| 165 | strip_prefix = "$dir_pw_third_party_protobuf/src/" |
| 166 | } |
Jason Graffius | 9783fdd | 2020-11-12 23:03:15 -0800 | [diff] [blame] | 167 | } else { |
| 168 | # As mentioned above, these targets are effectively disabled if the build |
| 169 | # argument pointing to the protobuf source directory is not set. |
| 170 | group("libprotobuf_lite") { |
| 171 | } |
| 172 | group("libprotobuf") { |
| 173 | } |
| 174 | } |