3 # See http://sebs.googlecode.com
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.
11 # Currently, to use this file, you must generate config.h and put it at the
12 # top level of the source tree.
14 _cpp = sebs.import_("//sebs/cpp.sebs")
16 # ====================================================================
19 protobuf_lite = _cpp.Library(
20 name = "protobuf-lite",
21 srcs = [ "stubs/common.cc",
26 "stubs/stl_util-inl.h",
28 "generated_message_util.cc",
31 "wire_format_lite.cc",
33 "io/zero_copy_stream.cc",
34 "io/zero_copy_stream_impl_lite.cc" ],
35 deps = [ _cpp.SystemLibrary(name = "pthread") ])
37 protobuf = _cpp.Library(
39 srcs = [ "stubs/strutil.cc",
41 "stubs/substitute.cc",
43 "stubs/structurally_valid.cc",
46 "descriptor_database.cc",
48 "extension_set_heavy.cc",
49 "generated_message_reflection.cc",
54 "unknown_field_set.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") ])
65 libprotoc = _cpp.Library(
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" ],
116 protoc = _cpp.Binary(
118 srcs = [ "compiler/main.cc" ],
119 deps = [ libprotoc ])
121 # ====================================================================
122 # ProtobufLibrary rule class
124 class ProtobufLibrary(sebs.Rule):
125 argument_spec = sebs.ArgumentSpec(srcs = [sebs.Artifact],
126 deps = ([sebs.Rule], []),
127 lite = (bool, False))
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)
137 # We must build protoc for the host configuration to allow cross-compiling.
138 host_protoc = self.context.configured_artifact(protoc.binary, "host")
140 protoc_action = self.context.action(self, "protobuf")
141 protoc_args = [host_protoc, "-Isrc", "-Itmp", "-Iinclude","--cpp_out=tmp"]
144 for src in args.srcs:
145 protoc_args.append(src)
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)
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)
158 cpp_srcs.append(cc_artifact)
159 cpp_srcs.append(header_artifact)
161 protoc_action.set_command(
162 sebs.SubprocessCommand(protoc_action, protoc_args, implicit = cpp_srcs))
164 deps = list(args.deps)
166 deps.append(protobuf_lite)
168 deps.append(protobuf)
170 self.__cpp_library = _cpp.Library(srcs = cpp_srcs, deps = deps,
171 context = self.context)
172 self.__cpp_library.label = self.label
175 def as_cpp_library(self):
177 return self.__cpp_library
179 # ====================================================================
182 _lite_test_protos = ProtobufLibrary(
183 srcs = [ "unittest_lite.proto",
184 "unittest_import_lite.proto" ],
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 ])
198 _test_util = _cpp.Library(
200 srcs = [ "test_util.cc",
202 "testing/googletest.cc",
203 "testing/googletest.h",
206 deps = [ protobuf, _test_protos, _cpp.SystemLibrary(name = "gtest")] )
208 protobuf_lite_test = _cpp.Test(
209 srcs = [ "lite_unittest.cc",
211 "test_util_lite.h" ],
212 deps = [ _lite_test_protos ])
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") ])