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
20
21CC_LITE_SRC_FILES := \
22    src/google/protobuf/stubs/common.cc                              \
23    src/google/protobuf/stubs/once.cc                                \
24    src/google/protobuf/stubs/hash.cc                                \
25    src/google/protobuf/stubs/hash.h                                 \
26    src/google/protobuf/stubs/map-util.h                             \
27    src/google/protobuf/stubs/stl_util-inl.h                         \
28    src/google/protobuf/extension_set.cc                             \
29    src/google/protobuf/generated_message_util.cc                    \
30    src/google/protobuf/message_lite.cc                              \
31    src/google/protobuf/repeated_field.cc                            \
32    src/google/protobuf/wire_format_lite.cc                          \
33    src/google/protobuf/io/coded_stream.cc                           \
34    src/google/protobuf/io/coded_stream_inl.h                        \
35    src/google/protobuf/io/zero_copy_stream.cc                       \
36    src/google/protobuf/io/zero_copy_stream_impl_lite.cc
37
38JAVA_LITE_SRC_FILES := \
39    java/src/main/java/com/google/protobuf/UninitializedMessageException.java \
40    java/src/main/java/com/google/protobuf/MessageLite.java \
41    java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
42    java/src/main/java/com/google/protobuf/CodedOutputStream.java \
43    java/src/main/java/com/google/protobuf/ByteString.java \
44    java/src/main/java/com/google/protobuf/CodedInputStream.java \
45    java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
46    java/src/main/java/com/google/protobuf/AbstractMessageLite.java \
47    java/src/main/java/com/google/protobuf/FieldSet.java \
48    java/src/main/java/com/google/protobuf/Internal.java \
49    java/src/main/java/com/google/protobuf/WireFormat.java \
50    java/src/main/java/com/google/protobuf/GeneratedMessageLite.java
51
52COMPILER_SRC_FILES :=  \
53    src/google/protobuf/descriptor.cc \
54    src/google/protobuf/descriptor.pb.cc \
55    src/google/protobuf/descriptor_database.cc \
56    src/google/protobuf/dynamic_message.cc \
57    src/google/protobuf/extension_set.cc \
58    src/google/protobuf/extension_set_heavy.cc \
59    src/google/protobuf/generated_message_reflection.cc \
60    src/google/protobuf/generated_message_util.cc \
61    src/google/protobuf/message.cc \
62    src/google/protobuf/message_lite.cc \
63    src/google/protobuf/reflection_ops.cc \
64    src/google/protobuf/repeated_field.cc \
65    src/google/protobuf/service.cc \
66    src/google/protobuf/text_format.cc \
67    src/google/protobuf/unknown_field_set.cc \
68    src/google/protobuf/wire_format.cc \
69    src/google/protobuf/wire_format_lite.cc \
70    src/google/protobuf/compiler/code_generator.cc \
71    src/google/protobuf/compiler/command_line_interface.cc \
72    src/google/protobuf/compiler/importer.cc \
73    src/google/protobuf/compiler/main.cc \
74    src/google/protobuf/compiler/parser.cc \
75    src/google/protobuf/compiler/plugin.cc \
76    src/google/protobuf/compiler/plugin.pb.cc \
77    src/google/protobuf/compiler/subprocess.cc \
78    src/google/protobuf/compiler/zip_writer.cc \
79    src/google/protobuf/compiler/cpp/cpp_enum.cc \
80    src/google/protobuf/compiler/cpp/cpp_enum_field.cc \
81    src/google/protobuf/compiler/cpp/cpp_extension.cc \
82    src/google/protobuf/compiler/cpp/cpp_field.cc \
83    src/google/protobuf/compiler/cpp/cpp_file.cc \
84    src/google/protobuf/compiler/cpp/cpp_generator.cc \
85    src/google/protobuf/compiler/cpp/cpp_helpers.cc \
86    src/google/protobuf/compiler/cpp/cpp_message.cc \
87    src/google/protobuf/compiler/cpp/cpp_message_field.cc \
88    src/google/protobuf/compiler/cpp/cpp_primitive_field.cc \
89    src/google/protobuf/compiler/cpp/cpp_service.cc \
90    src/google/protobuf/compiler/cpp/cpp_string_field.cc \
91    src/google/protobuf/compiler/java/java_enum.cc \
92    src/google/protobuf/compiler/java/java_enum_field.cc \
93    src/google/protobuf/compiler/java/java_extension.cc \
94    src/google/protobuf/compiler/java/java_field.cc \
95    src/google/protobuf/compiler/java/java_file.cc \
96    src/google/protobuf/compiler/java/java_generator.cc \
97    src/google/protobuf/compiler/java/java_helpers.cc \
98    src/google/protobuf/compiler/java/java_message.cc \
99    src/google/protobuf/compiler/java/java_message_field.cc \
100    src/google/protobuf/compiler/java/java_primitive_field.cc \
101    src/google/protobuf/compiler/java/java_service.cc \
102    src/google/protobuf/compiler/javamicro/javamicro_enum.cc \
103    src/google/protobuf/compiler/javamicro/javamicro_enum_field.cc \
104    src/google/protobuf/compiler/javamicro/javamicro_field.cc \
105    src/google/protobuf/compiler/javamicro/javamicro_file.cc \
106    src/google/protobuf/compiler/javamicro/javamicro_generator.cc \
107    src/google/protobuf/compiler/javamicro/javamicro_helpers.cc \
108    src/google/protobuf/compiler/javamicro/javamicro_message.cc \
109    src/google/protobuf/compiler/javamicro/javamicro_message_field.cc \
110    src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc \
111    src/google/protobuf/compiler/javanano/javanano_enum.cc \
112    src/google/protobuf/compiler/javanano/javanano_enum_field.cc \
113    src/google/protobuf/compiler/javanano/javanano_extension.cc \
114    src/google/protobuf/compiler/javanano/javanano_field.cc \
115    src/google/protobuf/compiler/javanano/javanano_file.cc \
116    src/google/protobuf/compiler/javanano/javanano_generator.cc \
117    src/google/protobuf/compiler/javanano/javanano_helpers.cc \
118    src/google/protobuf/compiler/javanano/javanano_message.cc \
119    src/google/protobuf/compiler/javanano/javanano_message_field.cc \
120    src/google/protobuf/compiler/javanano/javanano_primitive_field.cc \
121    src/google/protobuf/compiler/python/python_generator.cc \
122    src/google/protobuf/io/coded_stream.cc \
123    src/google/protobuf/io/gzip_stream.cc \
124    src/google/protobuf/io/printer.cc \
125    src/google/protobuf/io/tokenizer.cc \
126    src/google/protobuf/io/zero_copy_stream.cc \
127    src/google/protobuf/io/zero_copy_stream_impl.cc \
128    src/google/protobuf/io/zero_copy_stream_impl_lite.cc \
129    src/google/protobuf/stubs/common.cc \
130    src/google/protobuf/stubs/hash.cc \
131    src/google/protobuf/stubs/once.cc \
132    src/google/protobuf/stubs/structurally_valid.cc \
133    src/google/protobuf/stubs/strutil.cc \
134    src/google/protobuf/stubs/substitute.cc
135
136# Java nano library (for device-side users)
137# =======================================================
138include $(CLEAR_VARS)
139
140LOCAL_MODULE := libprotobuf-java-2.3.0-nano
141LOCAL_MODULE_TAGS := optional
142LOCAL_SDK_VERSION := 8
143
144LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
145LOCAL_SRC_FILES += $(call all-java-files-under, java/src/device/main/java/com/google/protobuf/nano)
146
147include $(BUILD_STATIC_JAVA_LIBRARY)
148
149# Java nano library (for host-side users)
150# =======================================================
151include $(CLEAR_VARS)
152
153LOCAL_MODULE := host-libprotobuf-java-2.3.0-nano
154LOCAL_MODULE_TAGS := optional
155
156LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
157
158include $(BUILD_HOST_JAVA_LIBRARY)
159
160# Java micro library (for device-side users)
161# =======================================================
162include $(CLEAR_VARS)
163
164LOCAL_MODULE := libprotobuf-java-2.3.0-micro
165LOCAL_MODULE_TAGS := optional
166LOCAL_SDK_VERSION := 8
167
168LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
169
170include $(BUILD_STATIC_JAVA_LIBRARY)
171
172# Java micro library (for host-side users)
173# =======================================================
174include $(CLEAR_VARS)
175
176LOCAL_MODULE := host-libprotobuf-java-2.3.0-micro
177LOCAL_MODULE_TAGS := optional
178
179LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
180
181include $(BUILD_HOST_JAVA_LIBRARY)
182
183# Java lite library (for device-side users)
184# =======================================================
185include $(CLEAR_VARS)
186
187LOCAL_MODULE := libprotobuf-java-2.3.0-lite
188LOCAL_MODULE_TAGS := optional
189LOCAL_SDK_VERSION := 8
190
191LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
192
193include $(BUILD_STATIC_JAVA_LIBRARY)
194
195# Java lite library (for host-side users)
196# =======================================================
197include $(CLEAR_VARS)
198
199LOCAL_MODULE := host-libprotobuf-java-2.3.0-lite
200LOCAL_MODULE_TAGS := optional
201
202LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
203
204include $(BUILD_HOST_JAVA_LIBRARY)
205
206# C++ lite library
207# =======================================================
208include $(CLEAR_VARS)
209
210LOCAL_MODULE := libprotobuf-cpp-2.3.0-lite
211LOCAL_MODULE_TAGS := optional
212
213LOCAL_CPP_EXTENSION := .cc
214
215LOCAL_SRC_FILES := $(CC_LITE_SRC_FILES)
216
217LOCAL_C_INCLUDES := \
218    $(LOCAL_PATH)/android \
219    $(LOCAL_PATH)/src
220
221# Define the header files to be copied
222#LOCAL_COPY_HEADERS := \
223#    src/google/protobuf/stubs/once.h \
224#    src/google/protobuf/stubs/common.h \
225#    src/google/protobuf/io/coded_stream.h \
226#    src/google/protobuf/generated_message_util.h \
227#    src/google/protobuf/repeated_field.h \
228#    src/google/protobuf/extension_set.h \
229#    src/google/protobuf/wire_format_lite_inl.h
230#
231#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
232
233LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
234
235# These are the minimum versions and don't need to be update.
236ifeq ($(TARGET_ARCH),arm)
237LOCAL_SDK_VERSION := 8
238else
239# x86/mips support only available from API 9.
240LOCAL_SDK_VERSION := 9
241endif
242LOCAL_NDK_STL_VARIANT := stlport_static
243
244include $(BUILD_STATIC_LIBRARY)
245
246# C++ full library
247# =======================================================
248protobuf_cc_full_src_files := \
249    $(CC_LITE_SRC_FILES)                                             \
250    src/google/protobuf/stubs/strutil.cc                             \
251    src/google/protobuf/stubs/strutil.h                              \
252    src/google/protobuf/stubs/substitute.cc                          \
253    src/google/protobuf/stubs/substitute.h                           \
254    src/google/protobuf/stubs/structurally_valid.cc                  \
255    src/google/protobuf/descriptor.cc                                \
256    src/google/protobuf/descriptor.pb.cc                             \
257    src/google/protobuf/descriptor_database.cc                       \
258    src/google/protobuf/dynamic_message.cc                           \
259    src/google/protobuf/extension_set_heavy.cc                       \
260    src/google/protobuf/generated_message_reflection.cc              \
261    src/google/protobuf/message.cc                                   \
262    src/google/protobuf/reflection_ops.cc                            \
263    src/google/protobuf/service.cc                                   \
264    src/google/protobuf/text_format.cc                               \
265    src/google/protobuf/unknown_field_set.cc                         \
266    src/google/protobuf/wire_format.cc                               \
267    src/google/protobuf/io/gzip_stream.cc                            \
268    src/google/protobuf/io/printer.cc                                \
269    src/google/protobuf/io/tokenizer.cc                              \
270    src/google/protobuf/io/zero_copy_stream_impl.cc                  \
271    src/google/protobuf/compiler/importer.cc                         \
272    src/google/protobuf/compiler/parser.cc
273
274# C++ full library - stlport version
275# =======================================================
276include $(CLEAR_VARS)
277
278LOCAL_MODULE := libprotobuf-cpp-2.3.0-full
279LOCAL_MODULE_TAGS := optional
280LOCAL_CPP_EXTENSION := .cc
281LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
282LOCAL_C_INCLUDES := \
283    $(LOCAL_PATH)/android \
284    external/zlib \
285    $(LOCAL_PATH)/src
286
287# Define the header files to be copied
288#LOCAL_COPY_HEADERS := \
289#    src/google/protobuf/stubs/once.h \
290#    src/google/protobuf/stubs/common.h \
291#    src/google/protobuf/io/coded_stream.h \
292#    src/google/protobuf/generated_message_util.h \
293#    src/google/protobuf/repeated_field.h \
294#    src/google/protobuf/extension_set.h \
295#    src/google/protobuf/wire_format_lite_inl.h
296#
297#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
298
299LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
300
301# These are the minimum versions and don't need to be update.
302ifeq ($(TARGET_ARCH),arm)
303LOCAL_SDK_VERSION := 8
304else
305# x86/mips support only available from API 9.
306LOCAL_SDK_VERSION := 9
307endif
308LOCAL_NDK_STL_VARIANT := stlport_static
309
310include $(BUILD_STATIC_LIBRARY)
311
312# C++ full library - Gnustl+rtti version
313# =======================================================
314include $(CLEAR_VARS)
315
316LOCAL_MODULE := libprotobuf-cpp-2.3.0-full-gnustl-rtti
317LOCAL_MODULE_TAGS := optional
318LOCAL_CPP_EXTENSION := .cc
319LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
320LOCAL_C_INCLUDES := \
321    $(LOCAL_PATH)/android \
322    external/zlib \
323    $(LOCAL_PATH)/src
324
325LOCAL_CFLAGS := -frtti $(IGNORED_WARNINGS)
326LOCAL_SDK_VERSION := 14
327LOCAL_NDK_STL_VARIANT := gnustl_static
328
329include $(BUILD_STATIC_LIBRARY)
330
331# Clean temp vars
332protobuf_cc_full_src_files :=
333
334
335# Android Protocol buffer compiler, aprotoc (host executable)
336# used by the build systems as $(PROTOC) defined in
337# build/core/config.mk
338# =======================================================
339include $(CLEAR_VARS)
340
341LOCAL_MODULE := aprotoc
342LOCAL_MODULE_CLASS := EXECUTABLES
343LOCAL_MODULE_TAGS := optional
344
345LOCAL_CPP_EXTENSION := .cc
346LOCAL_SRC_FILES := $(COMPILER_SRC_FILES)
347
348LOCAL_C_INCLUDES := \
349    $(LOCAL_PATH)/android \
350    external/zlib \
351    $(LOCAL_PATH)/src
352
353LOCAL_STATIC_LIBRARIES += libz
354LOCAL_LDLIBS := -lpthread
355
356LOCAL_CFLAGS := $(IGNORED_WARNINGS)
357
358include $(BUILD_HOST_EXECUTABLE)
359
360# To test java proto params build rules.
361# =======================================================
362include $(CLEAR_VARS)
363
364LOCAL_MODULE := aprotoc-test-nano-params
365LOCAL_MODULE_TAGS := tests
366LOCAL_SDK_VERSION := current
367
368LOCAL_PROTOC_OPTIMIZE_TYPE := nano
369
370LOCAL_SRC_FILES := \
371        src/google/protobuf/unittest_import_nano.proto \
372        src/google/protobuf/unittest_simple_nano.proto \
373        src/google/protobuf/unittest_stringutf8_nano.proto \
374        src/google/protobuf/unittest_recursive_nano.proto
375
376
377LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
378
379LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
380        java_package = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|com.google.protobuf.nano, \
381        java_outer_classname = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|UnittestImportNano
382
383include $(BUILD_STATIC_JAVA_LIBRARY)
384
385# To test Android-specific nanoproto features.
386# =======================================================
387include $(CLEAR_VARS)
388
389# Parcelable messages
390LOCAL_MODULE := android-nano-test-parcelable
391LOCAL_MODULE_TAGS := tests
392LOCAL_SDK_VERSION := current
393
394LOCAL_PROTOC_OPTIMIZE_TYPE := nano
395
396LOCAL_SRC_FILES := src/google/protobuf/unittest_simple_nano.proto
397
398LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
399
400LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
401        parcelable_messages = true
402
403include $(BUILD_STATIC_JAVA_LIBRARY)
404
405include $(CLEAR_VARS)
406
407# Parcelable and extendable messages
408LOCAL_MODULE := android-nano-test-parcelable-extendable
409LOCAL_MODULE_TAGS := tests
410LOCAL_SDK_VERSION := current
411
412LOCAL_PROTOC_OPTIMIZE_TYPE := nano
413
414LOCAL_SRC_FILES := src/google/protobuf/unittest_extension_nano.proto
415
416LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
417
418LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
419        parcelable_messages = true, \
420        store_unknown_fields = true
421
422include $(BUILD_STATIC_JAVA_LIBRARY)
423
424include $(CLEAR_VARS)
425
426# Test APK
427LOCAL_PACKAGE_NAME := NanoAndroidTest
428
429LOCAL_SDK_VERSION := 8
430
431LOCAL_MODULE_TAGS := tests
432
433LOCAL_SRC_FILES := $(call all-java-files-under, java/src/device/test/java/com/google/protobuf/nano)
434
435LOCAL_MANIFEST_FILE := java/src/device/test/AndroidManifest.xml
436
437LOCAL_STATIC_JAVA_LIBRARIES := libprotobuf-java-2.3.0-nano \
438        android-nano-test-parcelable \
439        android-nano-test-parcelable-extendable
440
441LOCAL_DEX_PREOPT := false
442
443include $(BUILD_PACKAGE)
444