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