Skip to content

Protobuf #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The CMOSS scripts can be used to build the following C/C++ Open Source Software
* boost - http://www.boost.org/ - C++ utilities
* soci - http://soci.sourceforge.net/ - generic C++ database API
* pion : http://pion.org/ - C++ HTTP API
* protobuf : https://code.google.com/p/protobuf/ - structured data encoder

The android kernel already provides some of these shared libraries so check if they are available before including them in your NDK project. For example both openssl and icu are part of the Android distribution.

Expand Down
6 changes: 6 additions & 0 deletions build-droid/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export SOCI_VERSION="3.1.0"
# Project version to use to build pion (changing this may break the build)
export PION_VERSION="master"

# Project version to use to build protobuf (changing this may break the build)
export PROTOBUF_VERSION="2.5.0"

# Create dist folder
BUILDDIR=$(dirname $0)

Expand Down Expand Up @@ -191,6 +194,9 @@ do
# Build PION
${TOPDIR}/build-droid/build-pion.sh > "${LOGPATH}-pion.log"

# Build Protobuf
${TOPDIR}/build-droid/build-protobuf.sh> "${LOGPATH}-protobuf.log"

# Remove junk
rm -rf "${ROOTDIR}/bin"
rm -rf "${ROOTDIR}/certs"
Expand Down
73 changes: 73 additions & 0 deletions build-droid/build-protobuf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
set -e

# Changes for protobuf Copyright (c) 2012, Lothar May
# Copyright (c) 2010, Pierre-Olivier Latour
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * The name of Pierre-Olivier Latour may not 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 PIERRE-OLIVIER LATOUR 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.

# Download source
if [ ! -e "protobuf-${PROTOBUF_VERSION}.tar.bz2" ]
then
curl $PROXY -L -O "https://protobuf.googlecode.com/files/protobuf-${PROTOBUF_VERSION}.tar.bz2"
fi

# Extract source
rm -rf "protobuf-${PROTOBUF_VERSION}"
tar xvjf "protobuf-${PROTOBUF_VERSION}.tar.bz2"

# Build
pushd "protobuf-${PROTOBUF_VERSION}"
export CC=${DROIDTOOLS}-gcc
export LD=${DROIDTOOLS}-ld
export CPP=${DROIDTOOLS}-cpp
export CXX=${DROIDTOOLS}-g++
export AR=${DROIDTOOLS}-ar
export AS=${DROIDTOOLS}-as
export NM=${DROIDTOOLS}-nm
export STRIP=${DROIDTOOLS}-strip
export CXXCPP=${DROIDTOOLS}-cpp
export RANLIB=${DROIDTOOLS}-ranlib
export LDFLAGS="-Wl,-rpath-link=${SYSROOT}/usr/lib -L${SYSROOT}/usr/lib -L${ROOTDIR}/lib"
export CFLAGS="-fPIC -DANDROID -nostdlib"
#export CFLAGS="-Os -I${ROOTDIR}/include -I${SYSROOT}/usr/include"
export CPPFLAGS="-I${SYSROOT}/usr/include -DNDEBUG"
export CXXFLAGS="-I${SYSROOT}/usr/include -DNDEBUG"
export LIBS="-lc"

./configure --with-protoc=protoc --with-zlib=no --host=arm-eabi --prefix=${ROOTDIR} --with-sysroot=${SYSROOT} -enable-cross-compile

mv "src/Makefile" "src/Makefile~"
sed "s/all-am: Makefile \$(LTLIBRARIES) \$(PROGRAMS) \$(DATA) \$(HEADERS)/all-am: Makefile \$(LTLIBRARIES) \$(HEADERS)/" src/Makefile~ > src/Makefile~1
sed "s/lib_LTLIBRARIES = libprotobuf-lite\.la libprotobuf\.la libprotoc\.la/lib_LTLIBRARIES = libprotobuf-lite\.la/" src/Makefile~1 > src/Makefile~2
sed "s/install-data-am: install-nobase_dist_protoDATA/install-data-am: /" src/Makefile~2 > src/Makefile~3
sed "s/install-exec-am: install-binPROGRAMS install-libLTLIBRARIES/install-exec-am: install-libLTLIBRARIES/" src/Makefile~3 > src/Makefile

make
make install

popd

# Clean up
rm -rf "protobuf-${PROTOBUF_VERSION}"