Home | History | Annotate | Download | only in protobuf
      1 # Copyright 2014 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 if (is_win) {
      6   config_h_dir = "vsprojects"
      7 } else {
      8   config_h_dir = "."
      9 }
     10 
     11 config("protobuf_config") {
     12   include_dirs = [
     13     "src",
     14     config_h_dir,
     15   ]
     16   defines = [
     17     "PROTOBUF_USE_DLLS",
     18     "GOOGLE_PROTOBUF_NO_RTTI",
     19     "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
     20   ]
     21 
     22   if (is_win) {
     23     # TODO(jschuh): http://crbug.com/167187 size_t -> int.
     24     cflags = [ "/wd4267" ]
     25   }
     26 }
     27 
     28 # This condif should be applied to targets using generated code from the proto
     29 # compiler. It sets up the include directories properly.
     30 config("using_proto") {
     31   include_dirs = [
     32     "$root_gen_dir/protoc_out",
     33   ]
     34 }
     35 
     36 protobuf_lite_sources = [
     37   "src/google/protobuf/extension_set.cc",
     38   "src/google/protobuf/extension_set.h",
     39   "src/google/protobuf/generated_message_util.cc",
     40   "src/google/protobuf/generated_message_util.h",
     41   "src/google/protobuf/io/coded_stream.cc",
     42   "src/google/protobuf/io/coded_stream.h",
     43   "src/google/protobuf/io/coded_stream_inl.h",
     44   "src/google/protobuf/io/zero_copy_stream.cc",
     45   "src/google/protobuf/io/zero_copy_stream.h",
     46   "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
     47   "src/google/protobuf/io/zero_copy_stream_impl_lite.h",
     48   "src/google/protobuf/message_lite.cc",
     49   "src/google/protobuf/message_lite.h",
     50   "src/google/protobuf/repeated_field.cc",
     51   "src/google/protobuf/repeated_field.h",
     52   "src/google/protobuf/stubs/atomicops.h",
     53   "src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
     54   "src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
     55   "src/google/protobuf/stubs/atomicops_internals_macosx.h",
     56   "src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
     57   "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
     58   "src/google/protobuf/stubs/atomicops_internals_x86_gcc.h",
     59   "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
     60   "src/google/protobuf/stubs/atomicops_internals_x86_msvc.h",
     61   "src/google/protobuf/stubs/common.cc",
     62   "src/google/protobuf/stubs/common.h",
     63   "src/google/protobuf/stubs/hash.h",
     64   "src/google/protobuf/stubs/map-util.h",
     65   "src/google/protobuf/stubs/once.cc",
     66   "src/google/protobuf/stubs/once.h",
     67   "src/google/protobuf/stubs/platform_macros.h",
     68   "src/google/protobuf/unknown_field_set.cc",
     69   "src/google/protobuf/unknown_field_set.h",
     70   "src/google/protobuf/wire_format_lite.cc",
     71   "src/google/protobuf/wire_format_lite.h",
     72   "src/google/protobuf/wire_format_lite_inl.h",
     73   "$config_h_dir/config.h",
     74 ]
     75 
     76 protobuf_lite_cflags = []
     77 if (is_win) {
     78   protobuf_lite_cflags = [
     79     "/wd4018",  # signed/unsigned mismatch in comparison
     80     "/wd4244",  # implicit conversion, possible loss of data
     81     "/wd4355",  # 'this' used in base member initializer list
     82     "/wd4267",  # size_t to int truncation
     83     "/wd4291",  # no matching operator delete for a placement new
     84   ]
     85 }
     86 
     87 source_set("protobuf_lite") {
     88   sources = protobuf_lite_sources
     89 
     90   configs -= [ "//build/config/compiler:chromium_code" ]
     91   configs += [ "//build/config/compiler:no_chromium_code" ]
     92   if (is_win) {
     93     configs -= [ "//build/config/win:lean_and_mean" ]
     94   }
     95   public_configs = [ ":protobuf_config" ]
     96 
     97   cflags = protobuf_lite_cflags
     98 
     99   # Required for component builds. See http://crbug.com/172800.
    100   defines = [ "LIBPROTOBUF_EXPORTS" ]
    101 }
    102 
    103 # This is the full, heavy protobuf lib that's needed for c++ .protos that don't
    104 # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
    105 # into that category. Do not use in Chrome code.
    106 
    107 source_set("protobuf_full") {
    108   # Prevent people from depending on this outside our file.
    109   visibility = [ ":*" ]
    110 
    111   sources = protobuf_lite_sources
    112   sources += [
    113     "src/google/protobuf/descriptor.h",
    114     "src/google/protobuf/descriptor.pb.h",
    115     "src/google/protobuf/descriptor_database.h",
    116     "src/google/protobuf/dynamic_message.h",
    117     "src/google/protobuf/generated_enum_reflection.h",
    118     "src/google/protobuf/generated_message_reflection.h",
    119     "src/google/protobuf/message.h",
    120     "src/google/protobuf/reflection_ops.h",
    121     "src/google/protobuf/service.h",
    122     "src/google/protobuf/text_format.h",
    123     "src/google/protobuf/wire_format.h",
    124     "src/google/protobuf/io/gzip_stream.h",
    125     "src/google/protobuf/io/printer.h",
    126     "src/google/protobuf/io/tokenizer.h",
    127     "src/google/protobuf/io/zero_copy_stream_impl.h",
    128     "src/google/protobuf/compiler/code_generator.h",
    129     "src/google/protobuf/compiler/command_line_interface.h",
    130     "src/google/protobuf/compiler/importer.h",
    131     "src/google/protobuf/compiler/java/java_doc_comment.cc",
    132     "src/google/protobuf/compiler/java/java_doc_comment.h",
    133     "src/google/protobuf/compiler/parser.h",
    134 
    135     "src/google/protobuf/stubs/strutil.cc",
    136     "src/google/protobuf/stubs/strutil.h",
    137     "src/google/protobuf/stubs/substitute.cc",
    138     "src/google/protobuf/stubs/substitute.h",
    139     "src/google/protobuf/stubs/stl_util.h",
    140     "src/google/protobuf/stubs/stringprintf.cc",
    141     "src/google/protobuf/stubs/stringprintf.h",
    142     "src/google/protobuf/stubs/structurally_valid.cc",
    143     "src/google/protobuf/stubs/template_util.h",
    144     "src/google/protobuf/stubs/type_traits.h",
    145 
    146     "src/google/protobuf/descriptor.cc",
    147     "src/google/protobuf/descriptor.pb.cc",
    148     "src/google/protobuf/descriptor_database.cc",
    149     "src/google/protobuf/dynamic_message.cc",
    150     "src/google/protobuf/extension_set_heavy.cc",
    151     "src/google/protobuf/generated_message_reflection.cc",
    152     "src/google/protobuf/message.cc",
    153     "src/google/protobuf/reflection_ops.cc",
    154     "src/google/protobuf/service.cc",
    155     "src/google/protobuf/text_format.cc",
    156     "src/google/protobuf/wire_format.cc",
    157     # This file pulls in zlib, but it's not actually used by protoc, so
    158     # instead of compiling zlib for the host, let's just exclude this.
    159     # "src/src/google/protobuf/io/gzip_stream.cc",
    160     "src/google/protobuf/io/printer.cc",
    161     "src/google/protobuf/io/tokenizer.cc",
    162     "src/google/protobuf/io/zero_copy_stream_impl.cc",
    163     "src/google/protobuf/compiler/importer.cc",
    164     "src/google/protobuf/compiler/parser.cc",
    165   ]
    166 
    167   configs -= [ "//build/config/compiler:chromium_code" ]
    168   configs += [ "//build/config/compiler:no_chromium_code" ]
    169   if (is_win) {
    170     configs -= [ "//build/config/win:lean_and_mean" ]
    171   }
    172   public_configs = [ ":protobuf_config" ]
    173 
    174   cflags = protobuf_lite_cflags
    175 }
    176 
    177 # Only compile the compiler for the host architecture.
    178 if (current_toolchain == host_toolchain) {
    179   executable("protoc") {
    180     sources = [
    181       "src/google/protobuf/compiler/code_generator.cc",
    182       "src/google/protobuf/compiler/command_line_interface.cc",
    183       "src/google/protobuf/compiler/plugin.cc",
    184       "src/google/protobuf/compiler/plugin.pb.cc",
    185       "src/google/protobuf/compiler/subprocess.cc",
    186       "src/google/protobuf/compiler/subprocess.h",
    187       "src/google/protobuf/compiler/zip_writer.cc",
    188       "src/google/protobuf/compiler/zip_writer.h",
    189       "src/google/protobuf/compiler/cpp/cpp_enum.cc",
    190       "src/google/protobuf/compiler/cpp/cpp_enum.h",
    191       "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
    192       "src/google/protobuf/compiler/cpp/cpp_enum_field.h",
    193       "src/google/protobuf/compiler/cpp/cpp_extension.cc",
    194       "src/google/protobuf/compiler/cpp/cpp_extension.h",
    195       "src/google/protobuf/compiler/cpp/cpp_field.cc",
    196       "src/google/protobuf/compiler/cpp/cpp_field.h",
    197       "src/google/protobuf/compiler/cpp/cpp_file.cc",
    198       "src/google/protobuf/compiler/cpp/cpp_file.h",
    199       "src/google/protobuf/compiler/cpp/cpp_generator.cc",
    200       "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
    201       "src/google/protobuf/compiler/cpp/cpp_helpers.h",
    202       "src/google/protobuf/compiler/cpp/cpp_message.cc",
    203       "src/google/protobuf/compiler/cpp/cpp_message.h",
    204       "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
    205       "src/google/protobuf/compiler/cpp/cpp_message_field.h",
    206       "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
    207       "src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
    208       "src/google/protobuf/compiler/cpp/cpp_service.cc",
    209       "src/google/protobuf/compiler/cpp/cpp_service.h",
    210       "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
    211       "src/google/protobuf/compiler/cpp/cpp_string_field.h",
    212       "src/google/protobuf/compiler/java/java_enum.cc",
    213       "src/google/protobuf/compiler/java/java_enum.h",
    214       "src/google/protobuf/compiler/java/java_enum_field.cc",
    215       "src/google/protobuf/compiler/java/java_enum_field.h",
    216       "src/google/protobuf/compiler/java/java_extension.cc",
    217       "src/google/protobuf/compiler/java/java_extension.h",
    218       "src/google/protobuf/compiler/java/java_field.cc",
    219       "src/google/protobuf/compiler/java/java_field.h",
    220       "src/google/protobuf/compiler/java/java_file.cc",
    221       "src/google/protobuf/compiler/java/java_file.h",
    222       "src/google/protobuf/compiler/java/java_generator.cc",
    223       "src/google/protobuf/compiler/java/java_helpers.cc",
    224       "src/google/protobuf/compiler/java/java_helpers.h",
    225       "src/google/protobuf/compiler/java/java_message.cc",
    226       "src/google/protobuf/compiler/java/java_message.h",
    227       "src/google/protobuf/compiler/java/java_message_field.cc",
    228       "src/google/protobuf/compiler/java/java_message_field.h",
    229       "src/google/protobuf/compiler/java/java_primitive_field.cc",
    230       "src/google/protobuf/compiler/java/java_primitive_field.h",
    231       "src/google/protobuf/compiler/java/java_service.cc",
    232       "src/google/protobuf/compiler/java/java_service.h",
    233       "src/google/protobuf/compiler/java/java_string_field.cc",
    234       "src/google/protobuf/compiler/java/java_string_field.h",
    235       "src/google/protobuf/compiler/python/python_generator.cc",
    236       "src/google/protobuf/compiler/main.cc",
    237     ]
    238 
    239     configs -= [ "//build/config/compiler:chromium_code" ]
    240     configs += [ "//build/config/compiler:no_chromium_code" ]
    241     if (is_win) {
    242       # This is defined internally, don't warn on duplicate.
    243       configs -= [ "//build/config/win:lean_and_mean" ]
    244     }
    245 
    246     cflags = protobuf_lite_cflags
    247 
    248     deps = [
    249       ":protobuf_full",
    250     ]
    251   }
    252 }
    253