1# Copyright (C) 2009 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15#
16
17LOCAL_PATH := $(call my-dir)
18
19IGNORED_WARNINGS := -Wno-sign-compare -Wno-unused-parameter -Wno-sign-promo -Wno-error=return-type
20
21CC_LITE_SRC_FILES := \
22    src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc         \
23    src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc        \
24    src/google/protobuf/stubs/common.cc                              \
25    src/google/protobuf/stubs/once.cc                                \
26    src/google/protobuf/stubs/hash.h                                 \
27    src/google/protobuf/stubs/map_util.h                             \
28    src/google/protobuf/stubs/shared_ptr.h                           \
29    src/google/protobuf/stubs/stringprintf.cc                        \
30    src/google/protobuf/stubs/stringprintf.h                         \
31    src/google/protobuf/extension_set.cc                             \
32    src/google/protobuf/generated_message_util.cc                    \
33    src/google/protobuf/message_lite.cc                              \
34    src/google/protobuf/repeated_field.cc                            \
35    src/google/protobuf/wire_format_lite.cc                          \
36    src/google/protobuf/io/coded_stream.cc                           \
37    src/google/protobuf/io/coded_stream_inl.h                        \
38    src/google/protobuf/io/zero_copy_stream.cc                       \
39    src/google/protobuf/io/zero_copy_stream_impl_lite.cc
40
41JAVA_LITE_SRC_FILES := \
42    java/src/main/java/com/google/protobuf/UninitializedMessageException.java \
43    java/src/main/java/com/google/protobuf/MessageLite.java \
44    java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
45    java/src/main/java/com/google/protobuf/CodedOutputStream.java \
46    java/src/main/java/com/google/protobuf/ByteString.java \
47    java/src/main/java/com/google/protobuf/CodedInputStream.java \
48    java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
49    java/src/main/java/com/google/protobuf/AbstractMessageLite.java \
50    java/src/main/java/com/google/protobuf/AbstractParser.java \
51    java/src/main/java/com/google/protobuf/FieldSet.java \
52    java/src/main/java/com/google/protobuf/Internal.java \
53    java/src/main/java/com/google/protobuf/WireFormat.java \
54    java/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
55    java/src/main/java/com/google/protobuf/BoundedByteString.java \
56    java/src/main/java/com/google/protobuf/LazyField.java \
57    java/src/main/java/com/google/protobuf/LazyFieldLite.java \
58    java/src/main/java/com/google/protobuf/LazyStringList.java \
59    java/src/main/java/com/google/protobuf/LazyStringArrayList.java \
60    java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \
61    java/src/main/java/com/google/protobuf/LiteralByteString.java \
62    java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java \
63    java/src/main/java/com/google/protobuf/Parser.java \
64    java/src/main/java/com/google/protobuf/ProtocolStringList.java \
65    java/src/main/java/com/google/protobuf/RopeByteString.java \
66    java/src/main/java/com/google/protobuf/SmallSortedMap.java \
67    java/src/main/java/com/google/protobuf/Utf8.java
68
69# This contains more source files than needed for the full version, but the
70# additional files should not create any conflict.
71JAVA_FULL_SRC_FILES := \
72    $(call all-java-files-under, java/src/main/java) \
73    src/google/protobuf/descriptor.proto
74
75COMPILER_SRC_FILES :=  \
76    src/google/protobuf/descriptor.cc \
77    src/google/protobuf/descriptor.pb.cc \
78    src/google/protobuf/descriptor_database.cc \
79    src/google/protobuf/dynamic_message.cc \
80    src/google/protobuf/extension_set.cc \
81    src/google/protobuf/extension_set_heavy.cc \
82    src/google/protobuf/generated_message_reflection.cc \
83    src/google/protobuf/generated_message_util.cc \
84    src/google/protobuf/message.cc \
85    src/google/protobuf/message_lite.cc \
86    src/google/protobuf/reflection_ops.cc \
87    src/google/protobuf/repeated_field.cc \
88    src/google/protobuf/service.cc \
89    src/google/protobuf/text_format.cc \
90    src/google/protobuf/unknown_field_set.cc \
91    src/google/protobuf/wire_format.cc \
92    src/google/protobuf/wire_format_lite.cc \
93    src/google/protobuf/compiler/code_generator.cc \
94    src/google/protobuf/compiler/command_line_interface.cc \
95    src/google/protobuf/compiler/importer.cc \
96    src/google/protobuf/compiler/main.cc \
97    src/google/protobuf/compiler/parser.cc \
98    src/google/protobuf/compiler/plugin.cc \
99    src/google/protobuf/compiler/plugin.pb.cc \
100    src/google/protobuf/compiler/subprocess.cc \
101    src/google/protobuf/compiler/zip_writer.cc \
102    src/google/protobuf/compiler/cpp/cpp_enum.cc \
103    src/google/protobuf/compiler/cpp/cpp_enum_field.cc \
104    src/google/protobuf/compiler/cpp/cpp_extension.cc \
105    src/google/protobuf/compiler/cpp/cpp_field.cc \
106    src/google/protobuf/compiler/cpp/cpp_file.cc \
107    src/google/protobuf/compiler/cpp/cpp_generator.cc \
108    src/google/protobuf/compiler/cpp/cpp_helpers.cc \
109    src/google/protobuf/compiler/cpp/cpp_message.cc \
110    src/google/protobuf/compiler/cpp/cpp_message_field.cc \
111    src/google/protobuf/compiler/cpp/cpp_primitive_field.cc \
112    src/google/protobuf/compiler/cpp/cpp_service.cc \
113    src/google/protobuf/compiler/cpp/cpp_string_field.cc \
114    src/google/protobuf/compiler/java/java_context.cc \
115    src/google/protobuf/compiler/java/java_enum.cc \
116    src/google/protobuf/compiler/java/java_enum_field.cc \
117    src/google/protobuf/compiler/java/java_extension.cc \
118    src/google/protobuf/compiler/java/java_field.cc \
119    src/google/protobuf/compiler/java/java_file.cc \
120    src/google/protobuf/compiler/java/java_generator.cc \
121    src/google/protobuf/compiler/java/java_generator_factory.cc \
122    src/google/protobuf/compiler/java/java_helpers.cc \
123    src/google/protobuf/compiler/java/java_lazy_message_field.cc \
124    src/google/protobuf/compiler/java/java_message.cc \
125    src/google/protobuf/compiler/java/java_message_field.cc \
126    src/google/protobuf/compiler/java/java_name_resolver.cc \
127    src/google/protobuf/compiler/java/java_primitive_field.cc \
128    src/google/protobuf/compiler/java/java_shared_code_generator.cc \
129    src/google/protobuf/compiler/java/java_service.cc \
130    src/google/protobuf/compiler/java/java_string_field.cc \
131    src/google/protobuf/compiler/java/java_doc_comment.cc \
132    src/google/protobuf/compiler/javamicro/javamicro_enum.cc \
133    src/google/protobuf/compiler/javamicro/javamicro_enum_field.cc \
134    src/google/protobuf/compiler/javamicro/javamicro_field.cc \
135    src/google/protobuf/compiler/javamicro/javamicro_file.cc \
136    src/google/protobuf/compiler/javamicro/javamicro_generator.cc \
137    src/google/protobuf/compiler/javamicro/javamicro_helpers.cc \
138    src/google/protobuf/compiler/javamicro/javamicro_message.cc \
139    src/google/protobuf/compiler/javamicro/javamicro_message_field.cc \
140    src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc \
141    src/google/protobuf/compiler/javanano/javanano_enum.cc \
142    src/google/protobuf/compiler/javanano/javanano_enum_field.cc \
143    src/google/protobuf/compiler/javanano/javanano_extension.cc \
144    src/google/protobuf/compiler/javanano/javanano_field.cc \
145    src/google/protobuf/compiler/javanano/javanano_file.cc \
146    src/google/protobuf/compiler/javanano/javanano_generator.cc \
147    src/google/protobuf/compiler/javanano/javanano_helpers.cc \
148    src/google/protobuf/compiler/javanano/javanano_message.cc \
149    src/google/protobuf/compiler/javanano/javanano_message_field.cc \
150    src/google/protobuf/compiler/javanano/javanano_primitive_field.cc \
151    src/google/protobuf/compiler/python/python_generator.cc \
152    src/google/protobuf/io/coded_stream.cc \
153    src/google/protobuf/io/gzip_stream.cc \
154    src/google/protobuf/io/printer.cc \
155    src/google/protobuf/io/strtod.cc \
156    src/google/protobuf/io/tokenizer.cc \
157    src/google/protobuf/io/zero_copy_stream.cc \
158    src/google/protobuf/io/zero_copy_stream_impl.cc \
159    src/google/protobuf/io/zero_copy_stream_impl_lite.cc \
160    src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
161    src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
162    src/google/protobuf/stubs/common.cc \
163    src/google/protobuf/stubs/once.cc \
164    src/google/protobuf/stubs/structurally_valid.cc \
165    src/google/protobuf/stubs/strutil.cc \
166    src/google/protobuf/stubs/substitute.cc \
167    src/google/protobuf/stubs/stringprintf.cc
168
169# Java nano library (for device-side users)
170# =======================================================
171include $(CLEAR_VARS)
172
173LOCAL_MODULE := libprotobuf-java-nano
174LOCAL_MODULE_TAGS := optional
175LOCAL_SDK_VERSION := 8
176
177LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
178LOCAL_SRC_FILES += $(call all-java-files-under, java/src/device/main/java/com/google/protobuf/nano)
179
180include $(BUILD_STATIC_JAVA_LIBRARY)
181
182# Java nano library (for host-side users)
183# =======================================================
184include $(CLEAR_VARS)
185
186LOCAL_MODULE := host-libprotobuf-java-nano
187LOCAL_MODULE_TAGS := optional
188
189LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
190
191include $(BUILD_HOST_JAVA_LIBRARY)
192
193# Java micro library (for device-side users)
194# =======================================================
195include $(CLEAR_VARS)
196
197LOCAL_MODULE := libprotobuf-java-micro
198LOCAL_MODULE_TAGS := optional
199LOCAL_SDK_VERSION := 8
200
201LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
202
203include $(BUILD_STATIC_JAVA_LIBRARY)
204
205# Java micro library (for host-side users)
206# =======================================================
207include $(CLEAR_VARS)
208
209LOCAL_MODULE := host-libprotobuf-java-micro
210LOCAL_MODULE_TAGS := optional
211
212LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
213
214include $(BUILD_HOST_JAVA_LIBRARY)
215
216# Java lite library (for device-side users)
217# =======================================================
218include $(CLEAR_VARS)
219
220LOCAL_MODULE := libprotobuf-java-lite
221LOCAL_MODULE_TAGS := optional
222LOCAL_SDK_VERSION := 9
223
224LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
225
226include $(BUILD_STATIC_JAVA_LIBRARY)
227
228# Java lite library (for host-side users)
229# =======================================================
230include $(CLEAR_VARS)
231
232LOCAL_MODULE := host-libprotobuf-java-lite
233LOCAL_MODULE_TAGS := optional
234
235LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
236
237include $(BUILD_HOST_JAVA_LIBRARY)
238
239# Java full library (for host-side users)
240# =======================================================
241include $(CLEAR_VARS)
242
243LOCAL_MODULE := host-libprotobuf-java-full
244LOCAL_MODULE_TAGS := optional
245
246LOCAL_SRC_FILES := $(JAVA_FULL_SRC_FILES)
247
248include $(BUILD_HOST_JAVA_LIBRARY)
249
250# C++ lite library
251# =======================================================
252include $(CLEAR_VARS)
253
254LOCAL_MODULE := libprotobuf-cpp-lite
255LOCAL_MODULE_TAGS := optional
256
257LOCAL_CPP_EXTENSION := .cc
258
259LOCAL_SRC_FILES := $(CC_LITE_SRC_FILES)
260
261LOCAL_C_INCLUDES := \
262    $(LOCAL_PATH)/android \
263    $(LOCAL_PATH)/src
264
265# Define the header files to be copied
266#LOCAL_COPY_HEADERS := \
267#    src/google/protobuf/stubs/once.h \
268#    src/google/protobuf/stubs/common.h \
269#    src/google/protobuf/io/coded_stream.h \
270#    src/google/protobuf/generated_message_util.h \
271#    src/google/protobuf/repeated_field.h \
272#    src/google/protobuf/extension_set.h \
273#    src/google/protobuf/wire_format_lite_inl.h
274#
275#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
276
277LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
278
279# These are the minimum versions and don't need to be update.
280ifeq ($(TARGET_ARCH),arm)
281LOCAL_SDK_VERSION := 8
282else
283# x86/mips support only available from API 9.
284LOCAL_SDK_VERSION := 9
285endif
286LOCAL_NDK_STL_VARIANT := stlport_static
287
288include $(BUILD_STATIC_LIBRARY)
289
290# C++ lite library (libc++ flavored for the platform)
291# =======================================================
292include $(CLEAR_VARS)
293
294LOCAL_MODULE := libprotobuf-cpp-lite
295LOCAL_MODULE_TAGS := optional
296
297LOCAL_CPP_EXTENSION := .cc
298
299LOCAL_SRC_FILES := $(CC_LITE_SRC_FILES)
300
301LOCAL_C_INCLUDES := \
302    $(LOCAL_PATH)/android \
303    $(LOCAL_PATH)/src
304
305LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
306
307include $(BUILD_SHARED_LIBRARY)
308
309# C++ full library
310# =======================================================
311protobuf_cc_full_src_files := \
312    $(CC_LITE_SRC_FILES)                                             \
313    src/google/protobuf/stubs/strutil.cc                             \
314    src/google/protobuf/stubs/strutil.h                              \
315    src/google/protobuf/stubs/substitute.cc                          \
316    src/google/protobuf/stubs/substitute.h                           \
317    src/google/protobuf/stubs/structurally_valid.cc                  \
318    src/google/protobuf/descriptor.cc                                \
319    src/google/protobuf/descriptor.pb.cc                             \
320    src/google/protobuf/descriptor_database.cc                       \
321    src/google/protobuf/dynamic_message.cc                           \
322    src/google/protobuf/extension_set_heavy.cc                       \
323    src/google/protobuf/generated_message_reflection.cc              \
324    src/google/protobuf/message.cc                                   \
325    src/google/protobuf/reflection_ops.cc                            \
326    src/google/protobuf/service.cc                                   \
327    src/google/protobuf/text_format.cc                               \
328    src/google/protobuf/unknown_field_set.cc                         \
329    src/google/protobuf/wire_format.cc                               \
330    src/google/protobuf/io/gzip_stream.cc                            \
331    src/google/protobuf/io/printer.cc                                \
332    src/google/protobuf/io/strtod.cc                                 \
333    src/google/protobuf/io/tokenizer.cc                              \
334    src/google/protobuf/io/zero_copy_stream_impl.cc                  \
335    src/google/protobuf/compiler/importer.cc                         \
336    src/google/protobuf/compiler/parser.cc
337
338# C++ full library - stlport version
339# =======================================================
340include $(CLEAR_VARS)
341
342LOCAL_MODULE := libprotobuf-cpp-full
343LOCAL_MODULE_TAGS := optional
344LOCAL_CPP_EXTENSION := .cc
345LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
346LOCAL_C_INCLUDES := \
347    $(LOCAL_PATH)/android \
348    external/zlib \
349    $(LOCAL_PATH)/src
350
351# Define the header files to be copied
352#LOCAL_COPY_HEADERS := \
353#    src/google/protobuf/stubs/once.h \
354#    src/google/protobuf/stubs/common.h \
355#    src/google/protobuf/io/coded_stream.h \
356#    src/google/protobuf/generated_message_util.h \
357#    src/google/protobuf/repeated_field.h \
358#    src/google/protobuf/extension_set.h \
359#    src/google/protobuf/wire_format_lite_inl.h
360#
361#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
362
363LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
364
365# These are the minimum versions and don't need to be update.
366ifeq ($(TARGET_ARCH),arm)
367LOCAL_SDK_VERSION := 8
368else
369# x86/mips support only available from API 9.
370LOCAL_SDK_VERSION := 9
371endif
372LOCAL_NDK_STL_VARIANT := stlport_static
373
374include $(BUILD_STATIC_LIBRARY)
375
376# C++ full library - Gnustl+rtti version
377# =======================================================
378include $(CLEAR_VARS)
379
380LOCAL_MODULE := libprotobuf-cpp-full-gnustl-rtti
381LOCAL_MODULE_TAGS := optional
382LOCAL_CPP_EXTENSION := .cc
383LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
384LOCAL_C_INCLUDES := \
385    $(LOCAL_PATH)/android \
386    external/zlib \
387    $(LOCAL_PATH)/src
388
389LOCAL_CFLAGS := -frtti $(IGNORED_WARNINGS)
390LOCAL_SDK_VERSION := 14
391LOCAL_NDK_STL_VARIANT := gnustl_static
392
393include $(BUILD_STATIC_LIBRARY)
394
395# C++ full library - libc++ version for the platform
396# =======================================================
397include $(CLEAR_VARS)
398
399LOCAL_MODULE := libprotobuf-cpp-full
400LOCAL_MODULE_TAGS := optional
401LOCAL_CPP_EXTENSION := .cc
402LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
403LOCAL_C_INCLUDES := \
404    $(LOCAL_PATH)/android \
405    external/zlib \
406    $(LOCAL_PATH)/src
407
408LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
409LOCAL_SHARED_LIBRARIES := libz
410
411include $(BUILD_SHARED_LIBRARY)
412
413# Clean temp vars
414protobuf_cc_full_src_files :=
415
416
417# Android Protocol buffer compiler, aprotoc (host executable)
418# used by the build systems as $(PROTOC) defined in
419# build/core/config.mk
420# =======================================================
421include $(CLEAR_VARS)
422
423LOCAL_MODULE := aprotoc
424LOCAL_MODULE_CLASS := EXECUTABLES
425LOCAL_MODULE_TAGS := optional
426
427# Use the system's libstdc++ (libc++ on mac) because we copy aprotoc to
428# unbundled projects where libc++.so may not be available.
429LOCAL_CXX_STL := libstdc++
430
431LOCAL_CPP_EXTENSION := .cc
432LOCAL_SRC_FILES := $(COMPILER_SRC_FILES)
433
434LOCAL_C_INCLUDES := \
435    $(LOCAL_PATH)/android \
436    external/zlib \
437    $(LOCAL_PATH)/src
438
439LOCAL_STATIC_LIBRARIES += libz
440
441ifneq ($(HOST_OS),windows)
442LOCAL_LDLIBS := -lpthread
443endif
444
445LOCAL_CFLAGS := $(IGNORED_WARNINGS)
446
447include $(BUILD_HOST_EXECUTABLE)
448
449# To test java proto params build rules.
450# =======================================================
451include $(CLEAR_VARS)
452
453LOCAL_MODULE := aprotoc-test-nano-params
454LOCAL_MODULE_TAGS := tests
455LOCAL_SDK_VERSION := current
456
457LOCAL_PROTOC_OPTIMIZE_TYPE := nano
458
459LOCAL_SRC_FILES := \
460        src/google/protobuf/unittest_import_nano.proto \
461        src/google/protobuf/unittest_simple_nano.proto \
462        src/google/protobuf/unittest_stringutf8_nano.proto \
463        src/google/protobuf/unittest_recursive_nano.proto
464
465
466LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
467
468LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
469        java_package = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|com.google.protobuf.nano, \
470        java_outer_classname = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|UnittestImportNano
471
472include $(BUILD_STATIC_JAVA_LIBRARY)
473
474# To test Android-specific nanoproto features.
475# =======================================================
476include $(CLEAR_VARS)
477
478# Parcelable messages
479LOCAL_MODULE := android-nano-test-parcelable
480LOCAL_MODULE_TAGS := tests
481LOCAL_SDK_VERSION := current
482# Only needed at compile-time.
483LOCAL_JAVA_LIBRARIES := android-support-annotations
484
485LOCAL_PROTOC_OPTIMIZE_TYPE := nano
486
487LOCAL_SRC_FILES := src/google/protobuf/unittest_simple_nano.proto
488
489LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
490
491LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
492        parcelable_messages = true, \
493        generate_intdefs = true
494
495include $(BUILD_STATIC_JAVA_LIBRARY)
496
497include $(CLEAR_VARS)
498
499# Parcelable and extendable messages
500LOCAL_MODULE := android-nano-test-parcelable-extendable
501LOCAL_MODULE_TAGS := tests
502LOCAL_SDK_VERSION := current
503# Only needed at compile-time.
504LOCAL_JAVA_LIBRARIES := android-support-annotations
505
506LOCAL_PROTOC_OPTIMIZE_TYPE := nano
507
508LOCAL_SRC_FILES := src/google/protobuf/unittest_extension_nano.proto
509
510LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
511
512LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
513        parcelable_messages = true, \
514        generate_intdefs = true, \
515        store_unknown_fields = true
516
517include $(BUILD_STATIC_JAVA_LIBRARY)
518
519include $(CLEAR_VARS)
520
521# Test APK
522LOCAL_PACKAGE_NAME := NanoAndroidTest
523
524LOCAL_SDK_VERSION := 8
525
526LOCAL_MODULE_TAGS := tests
527
528LOCAL_SRC_FILES := $(call all-java-files-under, java/src/device/test/java/com/google/protobuf/nano)
529
530LOCAL_MANIFEST_FILE := java/src/device/test/AndroidManifest.xml
531
532LOCAL_STATIC_JAVA_LIBRARIES := libprotobuf-java-nano \
533        android-nano-test-parcelable \
534        android-nano-test-parcelable-extendable
535
536LOCAL_DEX_PREOPT := false
537
538include $(BUILD_PACKAGE)
539
540