aboutsummaryrefslogtreecommitdiff
path: root/Android.mk
diff options
context:
space:
mode:
authorJeff Davidson <jpd@google.com>2014-04-22 23:25:53 -0700
committerJeff Davidson <jpd@google.com>2014-04-25 14:34:55 -0700
commitec4b1ce0b67a2386c270551146ce7932003525a7 (patch)
tree0f751a2c700f4192e58f3489ca04ad2b1881c0d1 /Android.mk
parentf1019531a6d587b247d08acb71dc5fe1f0577aa4 (diff)
downloadprotobuf-ec4b1ce0b67a2386c270551146ce7932003525a7.tar.gz
protobuf-ec4b1ce0b67a2386c270551146ce7932003525a7.tar.bz2
protobuf-ec4b1ce0b67a2386c270551146ce7932003525a7.zip
Support generation of Parcelable nano messages.
This CL adds the "parcelable_messages" option. When enabled, all generated message classes will conform to the Android Parcelable contract. This is achieved by introducing a new parent class for generated classes which implements the required functionality. Since the store_unknown_fields option also makes use of a superclass, ExtendableMessageNano, we have two versions of the new Parcelable superclass: one extending MessageNano, and one extending ExtendableMessageNano. These classes are otherwise identical. As these classes depend on Android framework jars, they are not included in the host .jar build of the nanoproto library. Finally, add a test suite for running tests of Android-specific functionality, as this cannot be done on a desktop JVM. Change-Id: Icc2a257f03317e947f7078dbb9857c3286857497
Diffstat (limited to 'Android.mk')
-rw-r--r--Android.mk61
1 files changed, 61 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
index ec28bec8..faf6e393 100644
--- a/Android.mk
+++ b/Android.mk
@@ -142,6 +142,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SDK_VERSION := 8
LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
+LOCAL_SRC_FILES += $(call all-java-files-under, java/src/device/main/java/com/google/protobuf/nano)
include $(BUILD_STATIC_JAVA_LIBRARY)
@@ -379,3 +380,63 @@ LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
java_outer_classname = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|UnittestImportNano
include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# To test Android-specific nanoproto features.
+# =======================================================
+include $(CLEAR_VARS)
+
+# Parcelable messages
+LOCAL_MODULE := android-nano-test-parcelable
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := nano
+
+LOCAL_SRC_FILES := src/google/protobuf/unittest_simple_nano.proto
+
+LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
+
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
+ parcelable_messages = true
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
+
+# Parcelable and extendable messages
+LOCAL_MODULE := android-nano-test-parcelable-extendable
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := nano
+
+LOCAL_SRC_FILES := src/google/protobuf/unittest_extension_nano.proto
+
+LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
+
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
+ parcelable_messages = true, \
+ store_unknown_fields = true
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
+
+# Test APK
+LOCAL_PACKAGE_NAME := NanoAndroidTest
+
+LOCAL_SDK_VERSION := 8
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, java/src/device/test/java/com/google/protobuf/nano)
+
+LOCAL_MANIFEST_FILE := java/src/device/test/AndroidManifest.xml
+
+LOCAL_STATIC_JAVA_LIBRARIES := libprotobuf-java-2.3.0-nano \
+ android-nano-test-parcelable \
+ android-nano-test-parcelable-extendable
+
+WITH_DEXPREOPT := false
+
+include $(BUILD_PACKAGE)