- add sources.
[platform/framework/web/crosswalk.git] / src / third_party / protobuf / src / google / protobuf / SEBS
1 # **EXPERIMENTAL**
2 #
3 # See http://sebs.googlecode.com
4 #
5 # This is an experimental build definition file using the SEBS build system.
6 # I (Kenton Varda, maintainer of Protocol Buffers) happen to be the author of
7 # SEBS, though SEBS is not a Google project.  I'm sticking this file in
8 # protobuf's SVN because that's the easiest place for me to put it, and it
9 # shouldn't harm anyone.  This file is not included in the distribution.
10 #
11 # Currently, to use this file, you must generate config.h and put it at the
12 # top level of the source tree.
13
14 _cpp = sebs.import_("//sebs/cpp.sebs")
15
16 # ====================================================================
17 # Public targets
18
19 protobuf_lite = _cpp.Library(
20   name = "protobuf-lite",
21   srcs = [ "stubs/common.cc",
22            "stubs/once.cc",
23            "stubs/hash.cc",
24            "stubs/hash.h",
25            "stubs/map-util.h",
26            "stubs/stl_util-inl.h",
27            "extension_set.cc",
28            "generated_message_util.cc",
29            "message_lite.cc",
30            "repeated_field.cc",
31            "wire_format_lite.cc",
32            "io/coded_stream.cc",
33            "io/zero_copy_stream.cc",
34            "io/zero_copy_stream_impl_lite.cc" ],
35   deps = [ _cpp.SystemLibrary(name = "pthread") ])
36
37 protobuf = _cpp.Library(
38   name = "protobuf",
39   srcs = [ "stubs/strutil.cc",
40            "stubs/strutil.h",
41            "stubs/substitute.cc",
42            "stubs/substitute.h",
43            "stubs/structurally_valid.cc",
44            "descriptor.cc",
45            "descriptor.pb.cc",
46            "descriptor_database.cc",
47            "dynamic_message.cc",
48            "extension_set_heavy.cc",
49            "generated_message_reflection.cc",
50            "message.cc",
51            "reflection_ops.cc",
52            "service.cc",
53            "text_format.cc",
54            "unknown_field_set.cc",
55            "wire_format.cc",
56            "io/gzip_stream.cc",
57            "io/printer.cc",
58            "io/tokenizer.cc",
59            "io/zero_copy_stream_impl.cc",
60            "compiler/importer.cc",
61            "compiler/parser.cc" ],
62   deps = [ protobuf_lite,
63            _cpp.SystemLibrary(name = "z") ])
64
65 libprotoc = _cpp.Library(
66   name = "protoc",
67   srcs = [ "compiler/code_generator.cc",
68            "compiler/command_line_interface.cc",
69            "compiler/cpp/cpp_enum.cc",
70            "compiler/cpp/cpp_enum.h",
71            "compiler/cpp/cpp_enum_field.cc",
72            "compiler/cpp/cpp_enum_field.h",
73            "compiler/cpp/cpp_extension.cc",
74            "compiler/cpp/cpp_extension.h",
75            "compiler/cpp/cpp_field.cc",
76            "compiler/cpp/cpp_field.h",
77            "compiler/cpp/cpp_file.cc",
78            "compiler/cpp/cpp_file.h",
79            "compiler/cpp/cpp_generator.cc",
80            "compiler/cpp/cpp_helpers.cc",
81            "compiler/cpp/cpp_helpers.h",
82            "compiler/cpp/cpp_message.cc",
83            "compiler/cpp/cpp_message.h",
84            "compiler/cpp/cpp_message_field.cc",
85            "compiler/cpp/cpp_message_field.h",
86            "compiler/cpp/cpp_primitive_field.cc",
87            "compiler/cpp/cpp_primitive_field.h",
88            "compiler/cpp/cpp_service.cc",
89            "compiler/cpp/cpp_service.h",
90            "compiler/cpp/cpp_string_field.cc",
91            "compiler/cpp/cpp_string_field.h",
92            "compiler/java/java_enum.cc",
93            "compiler/java/java_enum.h",
94            "compiler/java/java_enum_field.cc",
95            "compiler/java/java_enum_field.h",
96            "compiler/java/java_extension.cc",
97            "compiler/java/java_extension.h",
98            "compiler/java/java_field.cc",
99            "compiler/java/java_field.h",
100            "compiler/java/java_file.cc",
101            "compiler/java/java_file.h",
102            "compiler/java/java_generator.cc",
103            "compiler/java/java_helpers.cc",
104            "compiler/java/java_helpers.h",
105            "compiler/java/java_message.cc",
106            "compiler/java/java_message.h",
107            "compiler/java/java_message_field.cc",
108            "compiler/java/java_message_field.h",
109            "compiler/java/java_primitive_field.cc",
110            "compiler/java/java_primitive_field.h",
111            "compiler/java/java_service.cc",
112            "compiler/java/java_service.h",
113            "compiler/python/python_generator.cc" ],
114   deps = [ protobuf ])
115
116 protoc = _cpp.Binary(
117   name = "protoc",
118   srcs = [ "compiler/main.cc" ],
119   deps = [ libprotoc ])
120
121 # ====================================================================
122 # ProtobufLibrary rule class
123
124 class ProtobufLibrary(sebs.Rule):
125   argument_spec = sebs.ArgumentSpec(srcs = [sebs.Artifact],
126                                     deps = ([sebs.Rule], []),
127                                     lite = (bool, False))
128
129   def _expand(self, args):
130     for dep in args.deps:
131       if not isinstance(dep, ProtobufLibrary):
132         raise sebs.DefinitionError(
133           "Dependency of ProtobufLibrary is not a ProtobufLibrary: %s" % dep)
134
135     protoc.expand_once()
136
137     # We must build protoc for the host configuration to allow cross-compiling.
138     host_protoc = self.context.configured_artifact(protoc.binary, "host")
139
140     protoc_action = self.context.action(self, "protobuf")
141     protoc_args = [host_protoc, "-Isrc", "-Itmp", "-Iinclude","--cpp_out=tmp"]
142
143     cpp_srcs = []
144     for src in args.srcs:
145       protoc_args.append(src)
146
147       # We cannot build .proto files from other packages because the .pb.cc
148       # and .pb.h files would be written to that package, and we aren't allowed
149       # to write to other packages.
150       if self.context.local_filename(src) is None:
151         raise sebs.DefinitionError(
152           "Source file is not in this package: %s" % src)
153
154       cc_artifact = self.context.derived_artifact(src, ".pb.cc", protoc_action)
155       header_artifact = self.context.derived_artifact(
156           src, ".pb.h", protoc_action)
157
158       cpp_srcs.append(cc_artifact)
159       cpp_srcs.append(header_artifact)
160
161     protoc_action.set_command(
162       sebs.SubprocessCommand(protoc_action, protoc_args, implicit = cpp_srcs))
163
164     deps = list(args.deps)
165     if args.lite:
166       deps.append(protobuf_lite)
167     else:
168       deps.append(protobuf)
169
170     self.__cpp_library = _cpp.Library(srcs = cpp_srcs, deps = deps,
171                                       context = self.context)
172     self.__cpp_library.label = self.label
173     self.outputs = []
174
175   def as_cpp_library(self):
176     self.expand_once()
177     return self.__cpp_library
178
179 # ====================================================================
180 # Tests
181
182 _lite_test_protos = ProtobufLibrary(
183   srcs = [ "unittest_lite.proto",
184            "unittest_import_lite.proto" ],
185   lite = True)
186 _test_protos = ProtobufLibrary(
187   srcs = [ "unittest.proto",
188            "unittest_empty.proto",
189            "unittest_import.proto",
190            "unittest_mset.proto",
191            "unittest_optimize_for.proto",
192            "unittest_embed_optimize_for.proto",
193            "unittest_custom_options.proto",
194            "unittest_lite_imports_nonlite.proto",
195            "compiler/cpp/cpp_test_bad_identifiers.proto" ],
196   deps = [ _lite_test_protos ])
197
198 _test_util = _cpp.Library(
199   name = "test_util",
200   srcs = [ "test_util.cc",
201            "test_util.h",
202            "testing/googletest.cc",
203            "testing/googletest.h",
204            "testing/file.cc",
205            "testing/file.h" ],
206   deps = [ protobuf, _test_protos, _cpp.SystemLibrary(name = "gtest")] )
207
208 protobuf_lite_test = _cpp.Test(
209   srcs = [ "lite_unittest.cc",
210            "test_util_lite.cc",
211            "test_util_lite.h" ],
212   deps = [ _lite_test_protos ])
213
214 protobuf_test = _cpp.Test(
215   srcs = [ "stubs/common_unittest.cc",
216            "stubs/once_unittest.cc",
217            "stubs/strutil_unittest.cc",
218            "stubs/structurally_valid_unittest.cc",
219            "descriptor_database_unittest.cc",
220            "descriptor_unittest.cc",
221            "dynamic_message_unittest.cc",
222            "extension_set_unittest.cc",
223            "generated_message_reflection_unittest.cc",
224            "message_unittest.cc",
225            "reflection_ops_unittest.cc",
226            "repeated_field_unittest.cc",
227            "text_format_unittest.cc",
228            "unknown_field_set_unittest.cc",
229            "wire_format_unittest.cc",
230            "io/coded_stream_unittest.cc",
231            "io/printer_unittest.cc",
232            "io/tokenizer_unittest.cc",
233            "io/zero_copy_stream_unittest.cc",
234            "compiler/command_line_interface_unittest.cc",
235            "compiler/importer_unittest.cc",
236            "compiler/parser_unittest.cc",
237            "compiler/cpp/cpp_bootstrap_unittest.cc",
238            "compiler/cpp/cpp_unittest.cc" ],
239   deps = [ protobuf, libprotoc, _test_util,
240            _cpp.SystemLibrary(name = "gtest_main") ])