Merge "Integrate integer overflow changes from security branch" into nyc-dev
diff --git a/Android.mk b/Android.mk
index 597425b..5cb684e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -73,10 +73,15 @@
     source/dng_xmp.cpp
 
 LOCAL_MODULE := libdng_sdk
-LOCAL_MODULE_TAGS := optional
 LOCAL_SRC_FILES := $(dng_sdk_files)
 
-LOCAL_CFLAGS := -DUNIX_ENV=1 -DqDNGBigEndian=0 -DqDNGThreadSafe=1 -DqDNGUseLibJPEG=1 -DqDNGUseXMP=0 -DqDNGValidate=0 -DqDNGValidateTarget=1 -DqAndroid=1 -fexceptions -Wsign-compare -Wno-reorder -Wframe-larger-than=20000 -frtti
+LOCAL_CFLAGS := \
+    -DUNIX_ENV=1 -DqDNGBigEndian=0 -DqDNGThreadSafe=1 \
+    -DqDNGUseLibJPEG=1 -DqDNGUseXMP=0 -DqDNGValidate=0 \
+    -DqDNGValidateTarget=1 -DqAndroid=1 \
+    -Wsign-compare -Wno-reorder -Wframe-larger-than=20000
+
+LOCAL_CPPFLAGS := -frtti -fexceptions
 
 # Ignore unused parameters.
 LOCAL_CFLAGS += -Wno-unused-parameter
@@ -92,6 +97,46 @@
 
 include $(BUILD_SHARED_LIBRARY)
 
+# dng sdk validating version static library
+# This version will print out validation warnings/errors to stderr
+# and is built against the NDK for use with CTS
+# ========================================================
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libdng_sdk_validate
+LOCAL_SRC_FILES := $(dng_sdk_files)
+
+LOCAL_CFLAGS := \
+    -DUNIX_ENV=1 -DqDNGBigEndian=0 -DqDNGThreadSafe=1 \
+    -DqDNGUseLibJPEG=1 -DqDNGUseXMP=0 -DqDNGValidate=1 \
+    -DqDNGValidateTarget=1 -DqAndroid=1 \
+    -Wsign-compare -Wno-reorder -Wframe-larger-than=20000
+
+LOCAL_CPPFLAGS := -frtti -fexceptions
+
+# Ignore unused parameters.
+LOCAL_CFLAGS += -Wno-unused-parameter
+# Some integral return types are annotated with "const."
+LOCAL_CFLAGS += -Wno-ignored-qualifiers
+
+LOCAL_CLANG := true
+LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
+
+LOCAL_STATIC_LIBRARIES := libz libjpeg_static
+
+LOCAL_CPP_FEATURES := rtti exceptions
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/source
+
+# NDK build, shared C++ runtime
+# LOCAL_SDK_VERSION := current
+# LOCAL_NDK_STL_VARIANT := c++_shared
+
+# Temporary workaround until camera2 NDK is active. See b/27102995.
+LOCAL_CXX_STL := libc++_static
+
+include $(BUILD_STATIC_LIBRARY)
+
 # dng sdk unittests for target
 # ========================================================