summaryrefslogtreecommitdiffstats
path: root/support/android
diff options
context:
space:
mode:
authorFrançois Gaffie <francois.gaffie@intel.com>2016-02-17 07:59:02 +0100
committerEric Laurent <elaurent@google.com>2016-03-04 17:47:35 -0800
commit0ee85db398be8ea33d67cc42f99a1468cd6c8180 (patch)
tree3b563dd1f477cff6b95a516cf9b121a461149f59 /support/android
parent221a25e58e92ebc450c7eaba5f3ba8153a2308ae (diff)
downloadplatform_external_parameter-framework-0ee85db398be8ea33d67cc42f99a1468cd6c8180.tar.gz
platform_external_parameter-framework-0ee85db398be8ea33d67cc42f99a1468cd6c8180.tar.bz2
platform_external_parameter-framework-0ee85db398be8ea33d67cc42f99a1468cd6c8180.zip
parameter-framework: add shrinked version of boost ASIO
Boost ASIO is a dependancy of Parameter framework v3.2.4. As only used by PFW, as not provided by AOSP and as it is a quite huge library, this patch adds the dependancy within PFW folder as a shrinked version. Bug: 22887211 Change-Id: Ie47b8cda7616214e06d2464fbb441abce367e7d4 Signed-off-by: François Gaffie <francois.gaffie@intel.com>
Diffstat (limited to 'support/android')
-rw-r--r--support/android/asio/asio.hpp48
-rw-r--r--support/android/asio/asio_defines.txt87
-rwxr-xr-xsupport/android/asio/asio_shrinker.sh135
3 files changed, 270 insertions, 0 deletions
diff --git a/support/android/asio/asio.hpp b/support/android/asio/asio.hpp
new file mode 100644
index 0000000..ca7cd2f
--- /dev/null
+++ b/support/android/asio/asio.hpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#pragma once
+
+/** @file
+ * This file contains all ASIO inclusions needed by the Parameter Framework on
+ * Android. This avoids pulling all of ASIO and is part of the "ASIO shrinker
+ * for AOSP". If the Parameter Framework ever uses more of ASIO, then this list
+ * may need to be extended and the shrinker re-run.
+ */
+
+#include "asio/buffer.hpp"
+#include "asio/connect.hpp"
+#include "asio/error.hpp"
+#include "asio/error_code.hpp"
+#include "asio/io_service.hpp"
+#include "asio/ip/tcp.hpp"
+#include "asio/read.hpp"
+#include "asio/socket_base.hpp"
+#include "asio/system_error.hpp"
+#include "asio/write.hpp"
diff --git a/support/android/asio/asio_defines.txt b/support/android/asio/asio_defines.txt
new file mode 100644
index 0000000..e00ca1e
--- /dev/null
+++ b/support/android/asio/asio_defines.txt
@@ -0,0 +1,87 @@
+// non-boost asio, header-only
+#define ASIO_STANDALONE
+#define ASIO_HEADER_ONLY=1
+// we don't need to generate the doxygen
+#undef GENERATING_DOCUMENTATION
+// platform-specific deifnitions
+#undef BOOST_WINDOWS
+#undef BOOST_MSVC
+#undef _MSC_VER
+#undef ASIO_MSVC
+#undef WIN32
+#undef _WIN32
+#undef __WIN32__
+#undef ASIO_WINDOWS_RUNTIME
+#undef ASIO_WINDOWS
+#undef __CYGWIN__
+#undef __SYMBIAN32__
+#undef __BORLANDC__
+// We assume clang ("LOCAL_CLANG := true" in Android Makefiles)
+#define __clang__
+// We assume C++11
+#define ASIO_HAS_STD_SYSTEM_ERROR 1
+#define ASIO_HAS_STD_ARRAY 1
+#define ASIO_HAS_STD_SHARED_PTR 1
+#define ASIO_HAS_STD_ATOMIC 1
+#define ASIO_HAS_STD_ADDRESSOF 1
+#define ASIO_HAS_STD_FUNCTION 1
+#define ASIO_HAS_STD_TYPE_TRAITS 1
+#define ASIO_HAS_CSTDINT 1
+#define ASIO_HAS_STD_THREAD 1
+#define ASIO_HAS_STD_MUTEX_AND_CONDVAR 1
+#define ASIO_HAS_STD_CHRONO 1
+#define ASIO_HAS_GETADDRINFO 1
+#define ASIO_HAS_MOVE 1
+#define ASIO_HAS_VARIADIC_TEMPLATES 1
+#define ASIO_HAS_CONSTEXPR 1
+// Android has clang's libc++
+#define ASIO_HAS_CLANG_LIBCXX 1
+// non-boost asio
+#define ASIO_DISABLE_BOOST_ARRAY 1
+#define ASIO_DISABLE_BOOST_ASSERT 1
+#define ASIO_DISABLE_BOOST_BIND 1
+#define ASIO_DISABLE_BOOST_CHRONO 1
+#define ASIO_DISABLE_BOOST_DATE_TIME 1
+#define ASIO_DISABLE_BOOST_LIMITS 1
+#define ASIO_DISABLE_BOOST_REGEX 1
+#define ASIO_DISABLE_BOOST_STATIC_CONSTANT 1
+#define ASIO_DISABLE_BOOST_THROW_EXCEPTION 1
+#define ASIO_DISABLE_BOOST_WORKAROUND 1
+#undef ASIO_HAS_BOOST_CONFIG
+#undef ASIO_HAS_BOOST_ARRAY
+#undef ASIO_HAS_BOOST_ASSERT
+#undef ASIO_HAS_BOOST_LIMITS
+#undef ASIO_HAS_BOOST_THROW_EXCEPTION
+#undef ASIO_HAS_BOOST_REGEX
+#undef ASIO_HAS_BOOST_BIND
+#undef ASIO_HAS_BOOST_WORKAROUND
+#undef ASIO_HAS_BOOST_CHRONO
+#undef ASIO_HAS_BOOST_DATE_TIME
+// no need for buffer debugging
+#define ASIO_DISABLE_BUFFER_DEBUGGING
+#undef ASIO_ENABLE_BUFFER_DEBUGGING
+// bionic doesn't implement eventfd nor timerfd
+#define ASIO_DISABLE_EPOLL
+#define ASIO_DISABLE_EVENTFD
+#undef ASIO_HAS_EVENTFD
+#undef ASIO_HAS_TIMERFD
+#define ASIO_HAS_THREADS
+// We are not using asio for iostream, nor serial ports, nor posix file
+// descriptiors, nor with unix sockets
+#define ASIO_NO_IOSTREAM
+#define ASIO_DISABLE_SERIAL_PORT
+#undef ASIO_HAS_SERIAL_PORT
+#undef ASIO_HAS_POSIX_STREAM_DESCRIPTOR
+#define ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR
+#undef ASIO_HAS_LOCAL_SOCKETS
+#define ASIO_DISABLE_LOCAL_SOCKETS
+// windows-only features
+#undef ASIO_HAS_IOCP
+#undef ASIO_HAS_WINDOWS_OBJECT_HANDLE
+#undef ASIO_HAS_WINDOWS_STREAM_HANDLE
+#undef ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE
+#undef ASIO_HAS_WINDOWS_OBJECT_HANDLE
+#undef ASIO_HAS_WINDOWS_OVERLAPPED_PTR
+#define ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
+#define ASIO_DISABLE_KQUEUE 1
+#undef ASIO_HAS_KQUEUE
diff --git a/support/android/asio/asio_shrinker.sh b/support/android/asio/asio_shrinker.sh
new file mode 100755
index 0000000..cce570f
--- /dev/null
+++ b/support/android/asio/asio_shrinker.sh
@@ -0,0 +1,135 @@
+#! /bin/bash
+# Copyright (c) 2016, Intel Corporation
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation and/or
+# other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors
+# may be used to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+cd "$ANDROID_BUILD_TOP"
+. build/envsetup.sh
+cd -
+
+set -eo pipefail
+
+# INSTRUCTIONS
+#
+# Prior to running this script you should git-rm the previous content of the
+# directory pointed to by the "asio" symbolic link, extract the version you
+# want to integrate and finally, make the "asio" symbolic link point to the
+# extracted directory. Additionaly, the build environment must be ready; i.e.
+# you must have sourced "build/envestup.sh" and lunched any target.
+#
+# Then, run this script by passing it a list of lunch targets. ASIO will be
+# minified based on which files were used when building the Parameter Framework
+# on those lunch targets. As results may very among targets, it is advised to
+# pass lunch targets of various architectures (ideally, all lunch targets).
+
+# USAGE
+# See the usage() function below
+
+usage () {
+ echo "run from the Parameter Framework's git root"
+ echo "\tsupport/android/asio/asio_shrinker.sh <lunch target> [more lunch targets]"
+ exit 1
+}
+
+fail () {
+ code=$?
+ echo "Asio shrinker error: $1"
+ exit $code
+}
+
+list_compiled_files () {
+ directory=$1
+ output=$2
+
+ # list all files used during compilation. Ignore "grep" errors: some .P
+ # files may well not contain any "asio" line.
+ find "$directory/obj" -name "*.P" | \
+ xargs grep --no-filename 'external/parameter-framework/asio' >> "$output" || true
+}
+
+if [ $# -eq 0 ]; then
+ echo "Not enough arguments."
+ usage
+fi
+
+# This script must be run from the Parameter Framework's git root.
+cd asio
+
+asio_includes=$(mktemp)
+find include -type f -name '*.[ih]pp' > "$asio_includes"
+
+# unifdef can't parse multi-line macros. Help him out by removing the wrapping
+xargs sed -i -e :a -e '/\\$/N' -e 's@\\ *\n@ @' -e ta < "$asio_includes"
+
+# apply macro definitions
+# "-x 2" means: only exit with a code != 0 if an error happened
+# "-m" means: work on multiple files
+# -f" means: read define and undef directives from the following file
+xargs unifdef -x 2 -m -f ../support/android/asio/asio_defines.txt < "$asio_includes"
+rm "$asio_includes"
+
+
+# Take a list of lunch targets as argument and run "mma" on all of them.
+# Why? because it seems that different target architectures require different
+# sets of files
+pushd ..
+tmpfile=$(mktemp)
+for target in "$@"; do
+ lunch $target || fail "Failed to lunch $target"
+
+ # compile and list the source files that actually have been used
+ mma -j$(nproc) || fail "Failed to build $target"
+ list_compiled_files "$ANDROID_PRODUCT_OUT" $tmpfile
+done
+popd
+list_compiled_files "$ANDROID_HOST_OUT" $tmpfile
+
+# In .P files, a line may contain several entries and may be terminated by " \"
+# or " :" or nothing. Let's make sure we have one entry per line.
+sed -r -e 's@^ *([^:\\]*)( [:\\])?$@\1@' \
+ -e 's@^external/parameter-framework/asio/@@g' \
+ -e 's@ @\n@' $tmpfile | \
+ sort -u | \
+ xargs git add || fail "Failed to git-add some necessary ASIO headers"
+rm $tmpfile
+
+# Add copyright mentions and readmes
+git add COPYING LICENSE_1_0.txt README
+# Remove asio.hpp because we override it
+git rm -f include/asio.hpp || true # it may already have been removed
+
+cat > README.parameter-framework << __EOF__
+This version of ASIO has been minified for lower disk footprint for Android
+integraton by support/android/asio/asio_shrinker.sh.
+
+Although unlikely (thanks to having been tested on all AOSP lunch targets), if
+the Parameter Framework fails to compile on your lunch target because of a
+missing ASIO header, you may download a vanilla ASIO version from
+'http://sourceforge.net/projects/asio/files/asio/1.10.6%20%28Stable%29/' and
+run that script anew.
+__EOF__
+git add README.parameter-framework