]> localhost Git - libzipper.git/commitdiff
Added android support.
authorMichael McMaster <michael@codesrc.com>
Tue, 4 Oct 2011 05:02:25 +0000 (15:02 +1000)
committerMichael McMaster <michael@codesrc.com>
Tue, 4 Oct 2011 05:02:25 +0000 (15:02 +1000)
15 files changed:
FileReader.cc
FileWriter.cc
INSTALL
INSTALL.Android [new file with mode: 0644]
Makefile.am
NEWS
VERSION
android/zipper/Android.mk [new file with mode: 0644]
autodeb.sh
configure.ac
debian/changelog
port/strerror_gnu.cc [new file with mode: 0644]
port/strerror_posix.cc [moved from strerror.cc with 78% similarity]
zip.cc
zipper.cc

index b43c393dfc17af2bfd5bb87f0c894a98f01198e6..054c24e8a24813c2281018b2fcb9e9f230fac8fd 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <errno.h>
 
 using namespace zipper;
 
index 94cb48bb5a0d1c1bb8604c10aabe1ca0559583d2..53e7de74464fc3342774d5b0b6d17a31e2f09880 100644 (file)
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <utime.h>
+#include <errno.h>
 
 using namespace zipper;
 
diff --git a/INSTALL b/INSTALL
index 1f62fb997c9bd7b7c3a1966a9eb7a1c20304b6b9..91ff44f56771588f3c2b6bc396049cd827c5aa25 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,8 @@
 libzipper
 Michael McMaster <michael@codesrc.com>
 
+* Refer to INSTALL.Android for Google Android NDK compilation information.
+
 Pre-Requisites
        g++  (4.5.3)
        make (GNU make 3.81)
diff --git a/INSTALL.Android b/INSTALL.Android
new file mode 100644 (file)
index 0000000..e72f196
--- /dev/null
@@ -0,0 +1,40 @@
+libzipper
+Michael McMaster <michael@codesrc.com>
+
+Pre-Requisites
+       Android NDK (tested with android-ndk-r6)
+       Existing Android project
+
+NDK Limitations
+       * Your Application.mk file must enable C++ exceptions with:
+               APP_CPPFLAGS := -fexceptions -frtti
+       Although the NDK supports exceptions as of r5, they are disabled by
+       default for backwards compatibility.
+
+       * Your Application.mk file must specify a C++ STL implementation with
+       exception support. As of r6, only gnustl_static provides exception support.
+               APP_STL := gnustl_static
+
+Note that this port doesn't include any JNI interface code.  It is expected that
+libzipper will be called from other native code libraries, and not directly
+from Java.
+
+Including libzipper in your NDK project:
+1) Modify your Application.mk file to include the module, and
+       set APP_CPPFLAGS and APP_STL as stated under "NDK Limitations" above.
+
+       APP_CPPFLAGS += -fexceptions -frtti
+       APP_STL := gnustl_static
+       APP_MODULES += zipper
+
+2) Modify your applications Android.mk file to import the libzipper module:
+
+       LOCAL_STATIC_LIBRARIES += libzipper
+       $(call import-module,zipper)
+
+3) Set the NDK_MODULE_PATH variable to include the libzipper source directory
+       when calling ndk-build.
+       eg. If libzipper was extracted to /tmp/libzipper-1.0.3:
+
+               cd /path/to/your/ndk/application
+               ndk-build NDK_MODULE_PATH="/tmp/libzipper-1.0.3/android"
index e8cc63f5d38f59d4dc510e4595fbec79a2a47580..3c36fae276a48deda9a6eb4d91acb25ac3b96e50 100644 (file)
 
 include doxygen.am
 
-dist_noinst_SCRIPTS = autogen.sh
+dist_noinst_SCRIPTS = \
+       autogen.sh
+
+DIST_COMMON = \
+       config.guess \
+       config.sub \
+       depcomp \
+       install-sh \
+       ltmain.sh \
+       missing
+
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libzipper1.pc
 
 EXTRA_DIST = \
        COPYING \
        INSTALL \
+       INSTALL.Android \
        NEWS \
        README \
-       VERSION
+       VERSION \
+       android/zipper/Android.mk
 
 
 lib_LTLIBRARIES = libzipper.la
@@ -44,13 +56,20 @@ libzipper_la_SOURCES = \
        gzip.hh \
        Reader.cc \
        split.hh \
-       strerror.cc \
        strerror.hh \
        util.hh \
        Writer.cc \
        zip.hh \
        zip.cc
 
+if HAVE_GNU_STRERROR
+libzipper_la_SOURCES += \
+       port/strerror_gnu.cc
+else
+libzipper_la_SOURCES += \
+       port/strerror_posix.cc
+endif
+
 # Public API headers go here, for installation to /usr/include
 include_HEADERS = zipper.hh
 
diff --git a/NEWS b/NEWS
index 85a043f2d4c0b37349d7fa69fee80d27ebebcfdd..108d8373a822c671f0e7620fc3633651d396ba71 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+2011-10-04  Version 1.0.3
+       - Added Android NDK support
+
 2011-09-07  Version 1.0.2
        - Fixed a bug in deflate, which caused it to exit prematurely and
        report valid files as corrupt.
diff --git a/VERSION b/VERSION
index 6d7de6e6abef13b18021a3591debc53ac00616d4..21e8796a09d4f26935ffc4879147879a153f0193 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.2
+1.0.3
diff --git a/android/zipper/Android.mk b/android/zipper/Android.mk
new file mode 100644 (file)
index 0000000..48ebedc
--- /dev/null
@@ -0,0 +1,42 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := -W -Wall -Werror -D_POSIX_C_SOURCE=200112
+
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../
+
+# bionic /sys/types.h fails with -std=c++0x, as it doesn't include
+# stdint.h, but tries to use uint64_t.
+LOCAL_CPPFLAGS := -std=gnu++0x
+LOCAL_EXPORT_CPPFLAGS := -std=gnu++0x
+
+# libzipper throws exceptions
+LOCAL_CPPFLAGS += -fexceptions -frtti
+LOCAL_EXPORT_CPPFLAGS += -fexceptions -frtti
+
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_LDLIBS := -lz
+LOCAL_EXPORT_LDLIBS := -lz
+
+LOCAL_MODULE    := zipper
+LOCAL_MODULE_FILENAME    := libzipper
+
+LOCAL_SRC_FILES :=\
+       ../../CompressedFile.cc \
+       ../../deflate.cc \
+       ../../gzip.cc \
+       ../../zip.cc \
+       ../../Compressor.cc \
+       ../../Exception.cc \
+       ../../Reader.cc \
+       ../../zipper.cc \
+       ../../Container.cc \
+       ../../FileReader.cc \
+       ../../Decompressor.cc \
+       ../../FileWriter.cc \
+       ../../Writer.cc \
+       ../../port/strerror_posix.cc \
+
+include $(BUILD_STATIC_LIBRARY)
index b5ee069873ef770c1314984d8fbf967cec45e6cb..b15c1a926e419a9e113050e51bf384715e97e7cd 100755 (executable)
@@ -33,10 +33,10 @@ cp -a ${SRC}/debian libzipper-${VERSION}
 cd libzipper-${VERSION}
 dpkg-buildpackage -rfakeroot
 
-if ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.2-1.dsc; then
+if ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.3-1.dsc; then
        echo "Build failed"
        exit 1;
-elif ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.2-1_amd64.changes; then
+elif ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.3-1_amd64.changes; then
        echo "Build failed"
        exit 1;
 else
index 51dec69eac83a5447fc68542ce01324f802f4af1..1ed643abb8e7769ba1ea9d407dd7947078574eaf 100644 (file)
@@ -27,7 +27,11 @@ AM_MAINTAINER_MODE
 AC_SUBST([libzipper_version], m4_esyscmd_s([cat VERSION]))
 
 AC_PROG_CXX
-AC_PROG_LIBTOOL
+AC_LANG([C++])
+AM_PROG_LIBTOOL
+
+AC_FUNC_STRERROR_R
+AM_CONDITIONAL(HAVE_GNU_STRERROR,[test x$ac_cv_func_strerror_r_char_p = xyes])
 
 DX_DOXYGEN_FEATURE([ON])
 DX_HTML_FEATURE([ON])
index 1d78d64a01ad0e6fad7ec47523d4ec2ccdb21a87..d2d8face631701ddfed07fe6fa8abda06fd77d9e 100644 (file)
@@ -1,3 +1,9 @@
+libzipper (1.0.3-1) unstable; urgency=low
+
+  * Added Android NDK support
+
+ -- Michael McMaster <michael@codesrc.com>  Tue, 04 Oct 2011 13:22:11 +1000
+
 libzipper (1.0.2-1) unstable; urgency=low
 
   * Fixed a bug in the deflate methods, which would report corrupt data for
diff --git a/port/strerror_gnu.cc b/port/strerror_gnu.cc
new file mode 100644 (file)
index 0000000..d41eddb
--- /dev/null
@@ -0,0 +1,38 @@
+//     Copyright (C) 2011 Michael McMaster <michael@codesrc.com>
+//
+//     This file is part of libzipper.
+//
+//     libzipper is free software: you can redistribute it and/or modify
+//     it under the terms of the GNU General Public License as published by
+//     the Free Software Foundation, either version 3 of the License, or
+//     (at your option) any later version.
+//
+//     libzipper is distributed in the hope that it will be useful,
+//     but WITHOUT ANY WARRANTY; without even the implied warranty of
+//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//     GNU General Public License for more details.
+//
+//     You should have received a copy of the GNU General Public License
+//     along with libzipper.  If not, see <http://www.gnu.org/licenses/>.
+
+#define _GNU_SOURCE
+
+#include "../strerror.hh"
+
+#include <string.h>
+
+using namespace zipper;
+
+std::string
+zipper::strerror(int errnum)
+{
+       char buf[1024];
+       const char* message(NULL);
+
+       // The GNU-specific strerror_r may use the provided buffer, OR a static
+       // buffer.
+       message = strerror_r(errnum, buf, sizeof(buf));
+
+       return std::string(message);
+}
+
similarity index 78%
rename from strerror.cc
rename to port/strerror_posix.cc
index 4b6a022437e148797fe617d6befd7ebd02156920..83f4f8fc5f1a3293c4775a47ff35be303ff34b31 100644 (file)
@@ -15,7 +15,7 @@
 //     You should have received a copy of the GNU General Public License
 //     along with libzipper.  If not, see <http://www.gnu.org/licenses/>.
 
-#include "strerror.hh"
+#include "../strerror.hh"
 
 #include <string.h>
 
@@ -25,23 +25,17 @@ std::string
 zipper::strerror(int errnum)
 {
        char buf[1024];
-       char* message(NULL);
+       const char* message(NULL);
 
-#ifdef _GNU_SOURCE
-       // The GNU-specific strerror_r may use the provided buffer, OR a static
-       // buffer.
-       message = strerror_r(errnum, buf, sizeof(buf));
-
-#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
        int error(strerror_r(errnum, buf, sizeof(buf)));
        if (error != 0)
        {
                message = "Unknown error";
        }
-
 #else
        // Thread-unsafe fallback
-       message = strerror(errnum);
+       message = ::strerror(errnum);
 #endif
 
        return std::string(message);
diff --git a/zip.cc b/zip.cc
index caca8ef0369020a951e715db827123f4f295e8d1..1655072e23189b29ce6a2f76357eb64ed03e7f34 100644 (file)
--- a/zip.cc
+++ b/zip.cc
@@ -294,6 +294,7 @@ namespace
                                centralDirectoryEntries
                                )
                        );
+               (void) isZip; // Avoid unused warning.
                assert(isZip);
 
                std::vector<uint8_t> buffer(centralDirectoryBytes);
index 64f101461744c39cd59c5ef1ce184c7f86e0628b..52c6c1ce76c553ba9ad0849ce102d6a7c5449c49 100644 (file)
--- a/zipper.cc
+++ b/zipper.cc
@@ -17,6 +17,7 @@
 
 #include "zipper.hh"
 #include "split.hh"
+#include <errno.h>
 #include "strerror.hh"
 
 #include <cassert>