• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15
16config("protobuf_config") {
17  include_dirs = [ "src" ]
18}
19protobuf_dir = "src/google/protobuf"
20protobuf_lite_src = [
21  "$protobuf_dir/any_lite.cc",
22  "$protobuf_dir/arena.cc",
23  "$protobuf_dir/extension_set.cc",
24  "$protobuf_dir/generated_enum_util.cc",
25  "$protobuf_dir/generated_message_table_driven_lite.cc",
26  "$protobuf_dir/generated_message_util.cc",
27  "$protobuf_dir/implicit_weak_message.cc",
28  "$protobuf_dir/io/coded_stream.cc",
29  "$protobuf_dir/io/io_win32.cc",
30  "$protobuf_dir/io/strtod.cc",
31  "$protobuf_dir/io/zero_copy_stream.cc",
32  "$protobuf_dir/io/zero_copy_stream_impl.cc",
33  "$protobuf_dir/io/zero_copy_stream_impl_lite.cc",
34  "$protobuf_dir/message_lite.cc",
35  "$protobuf_dir/parse_context.cc",
36  "$protobuf_dir/repeated_field.cc",
37  "$protobuf_dir/stubs/bytestream.cc",
38  "$protobuf_dir/stubs/common.cc",
39  "$protobuf_dir/stubs/int128.cc",
40  "$protobuf_dir/stubs/status.cc",
41  "$protobuf_dir/stubs/statusor.cc",
42  "$protobuf_dir/stubs/stringpiece.cc",
43  "$protobuf_dir/stubs/stringprintf.cc",
44  "$protobuf_dir/stubs/structurally_valid.cc",
45  "$protobuf_dir/stubs/strutil.cc",
46  "$protobuf_dir/stubs/time.cc",
47  "$protobuf_dir/wire_format_lite.cc",
48]
49
50protobuf_src = [
51  "$protobuf_dir/any.cc",
52  "$protobuf_dir/any.pb.cc",
53  "$protobuf_dir/api.pb.cc",
54  "$protobuf_dir/compiler/importer.cc",
55  "$protobuf_dir/compiler/parser.cc",
56  "$protobuf_dir/descriptor.cc",
57  "$protobuf_dir/descriptor.pb.cc",
58  "$protobuf_dir/descriptor_database.cc",
59  "$protobuf_dir/duration.pb.cc",
60  "$protobuf_dir/dynamic_message.cc",
61  "$protobuf_dir/empty.pb.cc",
62  "$protobuf_dir/extension_set_heavy.cc",
63  "$protobuf_dir/field_mask.pb.cc",
64  "$protobuf_dir/generated_message_reflection.cc",
65  "$protobuf_dir/generated_message_table_driven.cc",
66  "$protobuf_dir/io/gzip_stream.cc",
67  "$protobuf_dir/io/printer.cc",
68  "$protobuf_dir/io/tokenizer.cc",
69  "$protobuf_dir/map_field.cc",
70  "$protobuf_dir/message.cc",
71  "$protobuf_dir/reflection_ops.cc",
72  "$protobuf_dir/service.cc",
73  "$protobuf_dir/source_context.pb.cc",
74  "$protobuf_dir/struct.pb.cc",
75  "$protobuf_dir/stubs/substitute.cc",
76  "$protobuf_dir/text_format.cc",
77  "$protobuf_dir/timestamp.pb.cc",
78  "$protobuf_dir/type.pb.cc",
79  "$protobuf_dir/unknown_field_set.cc",
80  "$protobuf_dir/util/delimited_message_util.cc",
81  "$protobuf_dir/util/field_comparator.cc",
82  "$protobuf_dir/util/field_mask_util.cc",
83  "$protobuf_dir/util/internal/datapiece.cc",
84  "$protobuf_dir/util/internal/default_value_objectwriter.cc",
85  "$protobuf_dir/util/internal/error_listener.cc",
86  "$protobuf_dir/util/internal/field_mask_utility.cc",
87  "$protobuf_dir/util/internal/json_escaping.cc",
88  "$protobuf_dir/util/internal/json_objectwriter.cc",
89  "$protobuf_dir/util/internal/json_stream_parser.cc",
90  "$protobuf_dir/util/internal/object_writer.cc",
91  "$protobuf_dir/util/internal/proto_writer.cc",
92  "$protobuf_dir/util/internal/protostream_objectsource.cc",
93  "$protobuf_dir/util/internal/protostream_objectwriter.cc",
94  "$protobuf_dir/util/internal/type_info.cc",
95  "$protobuf_dir/util/internal/type_info_test_helper.cc",
96  "$protobuf_dir/util/internal/utility.cc",
97  "$protobuf_dir/util/json_util.cc",
98  "$protobuf_dir/util/message_differencer.cc",
99  "$protobuf_dir/util/time_util.cc",
100  "$protobuf_dir/util/type_resolver_util.cc",
101  "$protobuf_dir/wire_format.cc",
102  "$protobuf_dir/wrappers.pb.cc",
103]
104if (use_wasm) {
105  source_set("protobuf_lite_static") {
106    sources = protobuf_lite_src
107    include_dirs = [
108      "$protobuf_dir/**/*.h",
109      "$protobuf_dir/**/*.inc",
110      "src",
111    ]
112
113    cflags_cc = [ "-Wno-sign-compare" ]
114    cflags = [
115      "-Wno-sign-compare",
116      "-D HAVE_PTHREAD",
117      "-std=c++17",
118    ]
119
120    #configs = default_configs
121
122    public_configs = [ ":protobuf_config" ]
123  }
124} else {
125  source_set("protobuf_lite_static") {
126    sources = protobuf_lite_src
127    include_dirs = [
128      "$protobuf_dir/**/*.h",
129      "$protobuf_dir/**/*.inc",
130      "src",
131    ]
132
133    cflags_cc = [ "-Wno-sign-compare" ]
134    cflags = [
135      "-Wno-sign-compare",
136      "-D HAVE_PTHREAD",
137      "-std=c++17",
138    ]
139
140    # configs = default_configs
141
142    public_configs = [ ":protobuf_config" ]
143  }
144}
145if (use_wasm) {
146  source_set("protobuf_static") {
147    sources = protobuf_src
148    include_dirs = [
149      "$protobuf_dir/**/*.h",
150      "$protobuf_dir/**/*.inc",
151      "src",
152    ]
153    cflags_cc = [ "-Wno-sign-compare" ]
154    cflags = [
155      "-Wno-sign-compare",
156      "-D HAVE_PTHREAD",
157      "-std=c++17",
158    ]
159
160    deps = [ ":protobuf_lite_static" ]
161
162    #configs = default_configs
163
164    public_configs = [ ":protobuf_config" ]
165  }
166} else {
167  source_set("protobuf_static") {
168    sources = protobuf_src
169    include_dirs = [
170      "$protobuf_dir/**/*.h",
171      "$protobuf_dir/**/*.inc",
172      "src",
173    ]
174
175    #cflags_cc = [
176    #  "-Wno-sign-compare",
177    #  "-ftrapv",
178    #  "-fstack-protector-strong",
179    #  "-fstack-protector-all",
180    #  "-D_FORTIFY_SOURCE=2 -O2",
181
182    #]
183    cflags = [
184      "-Wno-sign-compare",
185      "-D HAVE_PTHREAD",
186      "-ftrapv",
187      "-fstack-protector-strong",
188      "-fstack-protector-all",
189      "-D_FORTIFY_SOURCE=2 -O2",
190      "-std=c++17",
191
192      #    "-Wl,--disable-new-dtags,--rpath,/libpath1:/libpath2"
193    ]
194
195    ldflags = [ "-fstack-protector" ]
196    if (!is_macx) {
197      ldflags += [
198        "-fuse-ld=gold",
199        "-Wl,--gc-sections",
200        "-Wl,-O1",
201        "-fpie",
202        "-pie",
203      ]
204    }
205
206    if (!is_win) {
207      cflags += [
208        "-fPIE",
209        "-fPIC",
210      ]
211    }
212
213    deps = [ ":protobuf_lite_static" ]
214
215    public_configs = [ ":protobuf_config" ]
216  }
217  source_set("protoc_lib") {
218    sources = [
219      "$protobuf_dir/compiler/code_generator.cc",
220      "$protobuf_dir/compiler/command_line_interface.cc",
221      "$protobuf_dir/compiler/cpp/cpp_enum.cc",
222      "$protobuf_dir/compiler/cpp/cpp_enum_field.cc",
223      "$protobuf_dir/compiler/cpp/cpp_extension.cc",
224      "$protobuf_dir/compiler/cpp/cpp_field.cc",
225      "$protobuf_dir/compiler/cpp/cpp_file.cc",
226      "$protobuf_dir/compiler/cpp/cpp_generator.cc",
227      "$protobuf_dir/compiler/cpp/cpp_helpers.cc",
228      "$protobuf_dir/compiler/cpp/cpp_map_field.cc",
229      "$protobuf_dir/compiler/cpp/cpp_message.cc",
230      "$protobuf_dir/compiler/cpp/cpp_message_field.cc",
231      "$protobuf_dir/compiler/cpp/cpp_padding_optimizer.cc",
232      "$protobuf_dir/compiler/cpp/cpp_primitive_field.cc",
233      "$protobuf_dir/compiler/cpp/cpp_service.cc",
234      "$protobuf_dir/compiler/cpp/cpp_string_field.cc",
235      "$protobuf_dir/compiler/csharp/csharp_doc_comment.cc",
236      "$protobuf_dir/compiler/csharp/csharp_enum.cc",
237      "$protobuf_dir/compiler/csharp/csharp_enum_field.cc",
238      "$protobuf_dir/compiler/csharp/csharp_field_base.cc",
239      "$protobuf_dir/compiler/csharp/csharp_generator.cc",
240      "$protobuf_dir/compiler/csharp/csharp_helpers.cc",
241      "$protobuf_dir/compiler/csharp/csharp_map_field.cc",
242      "$protobuf_dir/compiler/csharp/csharp_message.cc",
243      "$protobuf_dir/compiler/csharp/csharp_message_field.cc",
244      "$protobuf_dir/compiler/csharp/csharp_primitive_field.cc",
245      "$protobuf_dir/compiler/csharp/csharp_reflection_class.cc",
246      "$protobuf_dir/compiler/csharp/csharp_repeated_enum_field.cc",
247      "$protobuf_dir/compiler/csharp/csharp_repeated_message_field.cc",
248      "$protobuf_dir/compiler/csharp/csharp_repeated_primitive_field.cc",
249      "$protobuf_dir/compiler/csharp/csharp_source_generator_base.cc",
250      "$protobuf_dir/compiler/csharp/csharp_wrapper_field.cc",
251      "$protobuf_dir/compiler/java/java_context.cc",
252      "$protobuf_dir/compiler/java/java_doc_comment.cc",
253      "$protobuf_dir/compiler/java/java_enum.cc",
254      "$protobuf_dir/compiler/java/java_enum_field.cc",
255      "$protobuf_dir/compiler/java/java_enum_field_lite.cc",
256      "$protobuf_dir/compiler/java/java_enum_lite.cc",
257      "$protobuf_dir/compiler/java/java_extension.cc",
258      "$protobuf_dir/compiler/java/java_extension_lite.cc",
259      "$protobuf_dir/compiler/java/java_field.cc",
260      "$protobuf_dir/compiler/java/java_file.cc",
261      "$protobuf_dir/compiler/java/java_generator.cc",
262      "$protobuf_dir/compiler/java/java_generator_factory.cc",
263      "$protobuf_dir/compiler/java/java_helpers.cc",
264      "$protobuf_dir/compiler/java/java_map_field.cc",
265      "$protobuf_dir/compiler/java/java_map_field_lite.cc",
266      "$protobuf_dir/compiler/java/java_message.cc",
267      "$protobuf_dir/compiler/java/java_message_builder.cc",
268      "$protobuf_dir/compiler/java/java_message_builder_lite.cc",
269      "$protobuf_dir/compiler/java/java_message_field.cc",
270      "$protobuf_dir/compiler/java/java_message_field_lite.cc",
271      "$protobuf_dir/compiler/java/java_message_lite.cc",
272      "$protobuf_dir/compiler/java/java_name_resolver.cc",
273      "$protobuf_dir/compiler/java/java_primitive_field.cc",
274      "$protobuf_dir/compiler/java/java_primitive_field_lite.cc",
275      "$protobuf_dir/compiler/java/java_service.cc",
276      "$protobuf_dir/compiler/java/java_shared_code_generator.cc",
277      "$protobuf_dir/compiler/java/java_string_field.cc",
278      "$protobuf_dir/compiler/java/java_string_field_lite.cc",
279      "$protobuf_dir/compiler/js/js_generator.cc",
280      "$protobuf_dir/compiler/js/well_known_types_embed.cc",
281      "$protobuf_dir/compiler/objectivec/objectivec_enum.cc",
282      "$protobuf_dir/compiler/objectivec/objectivec_enum_field.cc",
283      "$protobuf_dir/compiler/objectivec/objectivec_extension.cc",
284      "$protobuf_dir/compiler/objectivec/objectivec_field.cc",
285      "$protobuf_dir/compiler/objectivec/objectivec_file.cc",
286      "$protobuf_dir/compiler/objectivec/objectivec_generator.cc",
287      "$protobuf_dir/compiler/objectivec/objectivec_helpers.cc",
288      "$protobuf_dir/compiler/objectivec/objectivec_map_field.cc",
289      "$protobuf_dir/compiler/objectivec/objectivec_message.cc",
290      "$protobuf_dir/compiler/objectivec/objectivec_message_field.cc",
291      "$protobuf_dir/compiler/objectivec/objectivec_oneof.cc",
292      "$protobuf_dir/compiler/objectivec/objectivec_primitive_field.cc",
293      "$protobuf_dir/compiler/php/php_generator.cc",
294      "$protobuf_dir/compiler/plugin.cc",
295      "$protobuf_dir/compiler/plugin.pb.cc",
296      "$protobuf_dir/compiler/python/python_generator.cc",
297      "$protobuf_dir/compiler/ruby/ruby_generator.cc",
298      "$protobuf_dir/compiler/subprocess.cc",
299      "$protobuf_dir/compiler/zip_writer.cc",
300    ]
301    include_dirs = [
302      "$protobuf_dir/**/*.h",
303      "$protobuf_dir/**/*.inc",
304      "src",
305
306      # "/opt/clang-mingw/i686-w64-mingw32/x86_64-linux-gnu",
307      # "/opt/clang-mingw/i686-w64-mingw32/x86_64-linux-gnu/c++/7",
308      # "/opt/clang-mingw/i686-w64-mingw32/include/c++/7",
309      # "/usr/include",
310      # "/usr/include/c++/7",
311      # "/usr/include/x86_64-linux-gnu/c++/7",
312    ]
313    if (!use_wasm) {
314      configs = default_configs
315    }
316    cflags_cc = [
317      "-Wno-sign-compare",
318      "-Wno-unused-function",
319      "-Wno-unused-private-field",
320
321      # "-std=gnu++17",
322    ]
323    cflags = [
324      "-Wno-sign-compare",
325      "-D HAVE_PTHREAD",
326      "-Wno-unused-function",
327      "-std=c++17",
328
329      #    "-Wl,--disable-new-dtags,--rpath,/libpath1:/libpath2"
330    ]
331
332    deps = [
333      ":protobuf_static",
334      ":protobuf_lite_static",
335    ]
336
337    public_configs = [ ":protobuf_config" ]
338  }
339  executable("protoc") {
340    sources = [ "$protobuf_dir/compiler/main.cc" ]
341    include_dirs = [
342      "$protobuf_dir/**/*.h",
343      "$protobuf_dir/**/*.inc",
344      "src",
345      "/usr/include",
346    ]
347    deps = [ ":protoc_lib" ]
348    cflags_cc = [ "-Wno-sign-compare" ]
349    cflags = [
350      "-Wno-sign-compare",
351      "-D HAVE_PTHREAD",
352    ]
353  }
354}
355