Android.mk revision 7b93f287c2bce7520f2a80d7c059415d31221f2a
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
69COMPILER_SRC_FILES :=  \
70    src/google/protobuf/descriptor.cc \
71    src/google/protobuf/descriptor.pb.cc \
72    src/google/protobuf/descriptor_database.cc \
73    src/google/protobuf/dynamic_message.cc \
74    src/google/protobuf/extension_set.cc \
75    src/google/protobuf/extension_set_heavy.cc \
76    src/google/protobuf/generated_message_reflection.cc \
77    src/google/protobuf/generated_message_util.cc \
78    src/google/protobuf/message.cc \
79    src/google/protobuf/message_lite.cc \
80    src/google/protobuf/reflection_ops.cc \
81    src/google/protobuf/repeated_field.cc \
82    src/google/protobuf/service.cc \
83    src/google/protobuf/text_format.cc \
84    src/google/protobuf/unknown_field_set.cc \
85    src/google/protobuf/wire_format.cc \
86    src/google/protobuf/wire_format_lite.cc \
87    src/google/protobuf/compiler/code_generator.cc \
88    src/google/protobuf/compiler/command_line_interface.cc \
89    src/google/protobuf/compiler/importer.cc \
90    src/google/protobuf/compiler/main.cc \
91    src/google/protobuf/compiler/parser.cc \
92    src/google/protobuf/compiler/plugin.cc \
93    src/google/protobuf/compiler/plugin.pb.cc \
94    src/google/protobuf/compiler/subprocess.cc \
95    src/google/protobuf/compiler/zip_writer.cc \
96    src/google/protobuf/compiler/cpp/cpp_enum.cc \
97    src/google/protobuf/compiler/cpp/cpp_enum_field.cc \
98    src/google/protobuf/compiler/cpp/cpp_extension.cc \
99    src/google/protobuf/compiler/cpp/cpp_field.cc \
100    src/google/protobuf/compiler/cpp/cpp_file.cc \
101    src/google/protobuf/compiler/cpp/cpp_generator.cc \
102    src/google/protobuf/compiler/cpp/cpp_helpers.cc \
103    src/google/protobuf/compiler/cpp/cpp_message.cc \
104    src/google/protobuf/compiler/cpp/cpp_message_field.cc \
105    src/google/protobuf/compiler/cpp/cpp_primitive_field.cc \
106    src/google/protobuf/compiler/cpp/cpp_service.cc \
107    src/google/protobuf/compiler/cpp/cpp_string_field.cc \
108    src/google/protobuf/compiler/java/java_context.cc \
109    src/google/protobuf/compiler/java/java_enum.cc \
110    src/google/protobuf/compiler/java/java_enum_field.cc \
111    src/google/protobuf/compiler/java/java_extension.cc \
112    src/google/protobuf/compiler/java/java_field.cc \
113    src/google/protobuf/compiler/java/java_file.cc \
114    src/google/protobuf/compiler/java/java_generator.cc \
115    src/google/protobuf/compiler/java/java_generator_factory.cc \
116    src/google/protobuf/compiler/java/java_helpers.cc \
117    src/google/protobuf/compiler/java/java_lazy_message_field.cc \
118    src/google/protobuf/compiler/java/java_message.cc \
119    src/google/protobuf/compiler/java/java_message_field.cc \
120    src/google/protobuf/compiler/java/java_name_resolver.cc \
121    src/google/protobuf/compiler/java/java_primitive_field.cc \
122    src/google/protobuf/compiler/java/java_shared_code_generator.cc \
123    src/google/protobuf/compiler/java/java_service.cc \
124    src/google/protobuf/compiler/java/java_string_field.cc \
125    src/google/protobuf/compiler/java/java_doc_comment.cc \
126    src/google/protobuf/compiler/javamicro/javamicro_enum.cc \
127    src/google/protobuf/compiler/javamicro/javamicro_enum_field.cc \
128    src/google/protobuf/compiler/javamicro/javamicro_field.cc \
129    src/google/protobuf/compiler/javamicro/javamicro_file.cc \
130    src/google/protobuf/compiler/javamicro/javamicro_generator.cc \
131    src/google/protobuf/compiler/javamicro/javamicro_helpers.cc \
132    src/google/protobuf/compiler/javamicro/javamicro_message.cc \
133    src/google/protobuf/compiler/javamicro/javamicro_message_field.cc \
134    src/google/protobuf/compiler/javamicro/javamicro_primitive_field.cc \
135    src/google/protobuf/compiler/javanano/javanano_enum.cc \
136    src/google/protobuf/compiler/javanano/javanano_enum_field.cc \
137    src/google/protobuf/compiler/javanano/javanano_extension.cc \
138    src/google/protobuf/compiler/javanano/javanano_field.cc \
139    src/google/protobuf/compiler/javanano/javanano_file.cc \
140    src/google/protobuf/compiler/javanano/javanano_generator.cc \
141    src/google/protobuf/compiler/javanano/javanano_helpers.cc \
142    src/google/protobuf/compiler/javanano/javanano_message.cc \
143    src/google/protobuf/compiler/javanano/javanano_message_field.cc \
144    src/google/protobuf/compiler/javanano/javanano_primitive_field.cc \
145    src/google/protobuf/compiler/python/python_generator.cc \
146    src/google/protobuf/io/coded_stream.cc \
147    src/google/protobuf/io/gzip_stream.cc \
148    src/google/protobuf/io/printer.cc \
149    src/google/protobuf/io/strtod.cc \
150    src/google/protobuf/io/tokenizer.cc \
151    src/google/protobuf/io/zero_copy_stream.cc \
152    src/google/protobuf/io/zero_copy_stream_impl.cc \
153    src/google/protobuf/io/zero_copy_stream_impl_lite.cc \
154    src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
155    src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
156    src/google/protobuf/stubs/common.cc \
157    src/google/protobuf/stubs/once.cc \
158    src/google/protobuf/stubs/structurally_valid.cc \
159    src/google/protobuf/stubs/strutil.cc \
160    src/google/protobuf/stubs/substitute.cc \
161    src/google/protobuf/stubs/stringprintf.cc
162
163# Java nano library (for device-side users)
164# =======================================================
165include $(CLEAR_VARS)
166
167LOCAL_MODULE := libprotobuf-java-nano
168LOCAL_MODULE_TAGS := optional
169LOCAL_SDK_VERSION := 8
170
171LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
172LOCAL_SRC_FILES += $(call all-java-files-under, java/src/device/main/java/com/google/protobuf/nano)
173
174include $(BUILD_STATIC_JAVA_LIBRARY)
175
176# Java nano library (for host-side users)
177# =======================================================
178include $(CLEAR_VARS)
179
180LOCAL_MODULE := host-libprotobuf-java-nano
181LOCAL_MODULE_TAGS := optional
182
183LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
184
185include $(BUILD_HOST_JAVA_LIBRARY)
186
187# Java micro library (for device-side users)
188# =======================================================
189include $(CLEAR_VARS)
190
191LOCAL_MODULE := libprotobuf-java-micro
192LOCAL_MODULE_TAGS := optional
193LOCAL_SDK_VERSION := 8
194
195LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
196
197include $(BUILD_STATIC_JAVA_LIBRARY)
198
199# Java micro library (for host-side users)
200# =======================================================
201include $(CLEAR_VARS)
202
203LOCAL_MODULE := host-libprotobuf-java-micro
204LOCAL_MODULE_TAGS := optional
205
206LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
207
208include $(BUILD_HOST_JAVA_LIBRARY)
209
210# Java lite library (for device-side users)
211# =======================================================
212include $(CLEAR_VARS)
213
214LOCAL_MODULE := libprotobuf-java-lite
215LOCAL_MODULE_TAGS := optional
216LOCAL_SDK_VERSION := 9
217
218LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
219
220include $(BUILD_STATIC_JAVA_LIBRARY)
221
222# Java lite library (for host-side users)
223# =======================================================
224include $(CLEAR_VARS)
225
226LOCAL_MODULE := host-libprotobuf-java-lite
227LOCAL_MODULE_TAGS := optional
228
229LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
230
231include $(BUILD_HOST_JAVA_LIBRARY)
232
233# C++ lite library
234# =======================================================
235include $(CLEAR_VARS)
236
237LOCAL_MODULE := libprotobuf-cpp-lite
238LOCAL_MODULE_TAGS := optional
239
240LOCAL_CPP_EXTENSION := .cc
241
242LOCAL_SRC_FILES := $(CC_LITE_SRC_FILES)
243
244LOCAL_C_INCLUDES := \
245    $(LOCAL_PATH)/android \
246    $(LOCAL_PATH)/src
247
248# Define the header files to be copied
249#LOCAL_COPY_HEADERS := \
250#    src/google/protobuf/stubs/once.h \
251#    src/google/protobuf/stubs/common.h \
252#    src/google/protobuf/io/coded_stream.h \
253#    src/google/protobuf/generated_message_util.h \
254#    src/google/protobuf/repeated_field.h \
255#    src/google/protobuf/extension_set.h \
256#    src/google/protobuf/wire_format_lite_inl.h
257#
258#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
259
260LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
261
262# These are the minimum versions and don't need to be update.
263ifeq ($(TARGET_ARCH),arm)
264LOCAL_SDK_VERSION := 8
265else
266# x86/mips support only available from API 9.
267LOCAL_SDK_VERSION := 9
268endif
269LOCAL_NDK_STL_VARIANT := stlport_static
270
271include $(BUILD_STATIC_LIBRARY)
272
273# C++ lite library (libc++ flavored for the platform)
274# =======================================================
275include $(CLEAR_VARS)
276
277LOCAL_MODULE := libprotobuf-cpp-lite
278LOCAL_MODULE_TAGS := optional
279
280LOCAL_CPP_EXTENSION := .cc
281
282LOCAL_SRC_FILES := $(CC_LITE_SRC_FILES)
283
284LOCAL_C_INCLUDES := \
285    $(LOCAL_PATH)/android \
286    $(LOCAL_PATH)/src
287
288LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
289
290include $(BUILD_SHARED_LIBRARY)
291
292# C++ full library
293# =======================================================
294protobuf_cc_full_src_files := \
295    $(CC_LITE_SRC_FILES)                                             \
296    src/google/protobuf/stubs/strutil.cc                             \
297    src/google/protobuf/stubs/strutil.h                              \
298    src/google/protobuf/stubs/substitute.cc                          \
299    src/google/protobuf/stubs/substitute.h                           \
300    src/google/protobuf/stubs/structurally_valid.cc                  \
301    src/google/protobuf/descriptor.cc                                \
302    src/google/protobuf/descriptor.pb.cc                             \
303    src/google/protobuf/descriptor_database.cc                       \
304    src/google/protobuf/dynamic_message.cc                           \
305    src/google/protobuf/extension_set_heavy.cc                       \
306    src/google/protobuf/generated_message_reflection.cc              \
307    src/google/protobuf/message.cc                                   \
308    src/google/protobuf/reflection_ops.cc                            \
309    src/google/protobuf/service.cc                                   \
310    src/google/protobuf/text_format.cc                               \
311    src/google/protobuf/unknown_field_set.cc                         \
312    src/google/protobuf/wire_format.cc                               \
313    src/google/protobuf/io/gzip_stream.cc                            \
314    src/google/protobuf/io/printer.cc                                \
315    src/google/protobuf/io/strtod.cc                                 \
316    src/google/protobuf/io/tokenizer.cc                              \
317    src/google/protobuf/io/zero_copy_stream_impl.cc                  \
318    src/google/protobuf/compiler/importer.cc                         \
319    src/google/protobuf/compiler/parser.cc
320
321# C++ full library - stlport version
322# =======================================================
323include $(CLEAR_VARS)
324
325LOCAL_MODULE := libprotobuf-cpp-full
326LOCAL_MODULE_TAGS := optional
327LOCAL_CPP_EXTENSION := .cc
328LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
329LOCAL_C_INCLUDES := \
330    $(LOCAL_PATH)/android \
331    external/zlib \
332    $(LOCAL_PATH)/src
333
334# Define the header files to be copied
335#LOCAL_COPY_HEADERS := \
336#    src/google/protobuf/stubs/once.h \
337#    src/google/protobuf/stubs/common.h \
338#    src/google/protobuf/io/coded_stream.h \
339#    src/google/protobuf/generated_message_util.h \
340#    src/google/protobuf/repeated_field.h \
341#    src/google/protobuf/extension_set.h \
342#    src/google/protobuf/wire_format_lite_inl.h
343#
344#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
345
346LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
347
348# These are the minimum versions and don't need to be update.
349ifeq ($(TARGET_ARCH),arm)
350LOCAL_SDK_VERSION := 8
351else
352# x86/mips support only available from API 9.
353LOCAL_SDK_VERSION := 9
354endif
355LOCAL_NDK_STL_VARIANT := stlport_static
356
357include $(BUILD_STATIC_LIBRARY)
358
359# C++ full library - Gnustl+rtti version
360# =======================================================
361include $(CLEAR_VARS)
362
363LOCAL_MODULE := libprotobuf-cpp-full-gnustl-rtti
364LOCAL_MODULE_TAGS := optional
365LOCAL_CPP_EXTENSION := .cc
366LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
367LOCAL_C_INCLUDES := \
368    $(LOCAL_PATH)/android \
369    external/zlib \
370    $(LOCAL_PATH)/src
371
372LOCAL_CFLAGS := -frtti $(IGNORED_WARNINGS)
373LOCAL_SDK_VERSION := 14
374LOCAL_NDK_STL_VARIANT := gnustl_static
375
376include $(BUILD_STATIC_LIBRARY)
377
378# C++ full library - libc++ version for the platform
379# =======================================================
380include $(CLEAR_VARS)
381
382LOCAL_MODULE := libprotobuf-cpp-full
383LOCAL_MODULE_TAGS := optional
384LOCAL_CPP_EXTENSION := .cc
385LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
386LOCAL_C_INCLUDES := \
387    $(LOCAL_PATH)/android \
388    external/zlib \
389    $(LOCAL_PATH)/src
390
391LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
392LOCAL_SHARED_LIBRARIES := libz
393
394include $(BUILD_SHARED_LIBRARY)
395
396# Clean temp vars
397protobuf_cc_full_src_files :=
398
399
400# Android Protocol buffer compiler, aprotoc (host executable)
401# used by the build systems as $(PROTOC) defined in
402# build/core/config.mk
403# =======================================================
404include $(CLEAR_VARS)
405
406LOCAL_MODULE := aprotoc
407LOCAL_MODULE_CLASS := EXECUTABLES
408LOCAL_MODULE_TAGS := optional
409
410# Build aprotoc as a standalone binary because we copy it to
411# unbundled projects where libc++.so may not be available.
412LOCAL_CXX_STL := libc++_static
413
414LOCAL_CPP_EXTENSION := .cc
415LOCAL_SRC_FILES := $(COMPILER_SRC_FILES)
416
417LOCAL_C_INCLUDES := \
418    $(LOCAL_PATH)/android \
419    external/zlib \
420    $(LOCAL_PATH)/src
421
422LOCAL_STATIC_LIBRARIES += libz
423
424ifneq ($(HOST_OS),windows)
425LOCAL_LDLIBS := -lpthread
426endif
427
428LOCAL_CFLAGS := $(IGNORED_WARNINGS)
429
430include $(BUILD_HOST_EXECUTABLE)
431
432# To test java proto params build rules.
433# =======================================================
434include $(CLEAR_VARS)
435
436LOCAL_MODULE := aprotoc-test-nano-params
437LOCAL_MODULE_TAGS := tests
438LOCAL_SDK_VERSION := current
439
440LOCAL_PROTOC_OPTIMIZE_TYPE := nano
441
442LOCAL_SRC_FILES := \
443        src/google/protobuf/unittest_import_nano.proto \
444        src/google/protobuf/unittest_simple_nano.proto \
445        src/google/protobuf/unittest_stringutf8_nano.proto \
446        src/google/protobuf/unittest_recursive_nano.proto
447
448
449LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
450
451LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
452        java_package = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|com.google.protobuf.nano, \
453        java_outer_classname = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|UnittestImportNano
454
455include $(BUILD_STATIC_JAVA_LIBRARY)
456
457# To test Android-specific nanoproto features.
458# =======================================================
459include $(CLEAR_VARS)
460
461# Parcelable messages
462LOCAL_MODULE := android-nano-test-parcelable
463LOCAL_MODULE_TAGS := tests
464LOCAL_SDK_VERSION := current
465
466LOCAL_PROTOC_OPTIMIZE_TYPE := nano
467
468LOCAL_SRC_FILES := src/google/protobuf/unittest_simple_nano.proto
469
470LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
471
472LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
473        parcelable_messages = true
474
475include $(BUILD_STATIC_JAVA_LIBRARY)
476
477include $(CLEAR_VARS)
478
479# Parcelable and extendable messages
480LOCAL_MODULE := android-nano-test-parcelable-extendable
481LOCAL_MODULE_TAGS := tests
482LOCAL_SDK_VERSION := current
483
484LOCAL_PROTOC_OPTIMIZE_TYPE := nano
485
486LOCAL_SRC_FILES := src/google/protobuf/unittest_extension_nano.proto
487
488LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
489
490LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
491        parcelable_messages = true, \
492        store_unknown_fields = true
493
494include $(BUILD_STATIC_JAVA_LIBRARY)
495
496include $(CLEAR_VARS)
497
498# Test APK
499LOCAL_PACKAGE_NAME := NanoAndroidTest
500
501LOCAL_SDK_VERSION := 8
502
503LOCAL_MODULE_TAGS := tests
504
505LOCAL_SRC_FILES := $(call all-java-files-under, java/src/device/test/java/com/google/protobuf/nano)
506
507LOCAL_MANIFEST_FILE := java/src/device/test/AndroidManifest.xml
508
509LOCAL_STATIC_JAVA_LIBRARIES := libprotobuf-java-nano \
510        android-nano-test-parcelable \
511        android-nano-test-parcelable-extendable
512
513LOCAL_DEX_PREOPT := false
514
515include $(BUILD_PACKAGE)
516
517