Skip to content
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

ios build wrapper for serval-dna #77

Open
wants to merge 35 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fc3d443
first blob of the build script
foozmeat Mar 25, 2014
0635a4c
Merge branch 'refs/heads/development' into xcode
foozmeat Apr 2, 2014
28bc251
added some rules to modify serval files in place to support building …
foozmeat Apr 4, 2014
b154e5b
don't need this header and its not included in iOS
foozmeat Apr 5, 2014
60c8436
use CFLAGS for cross-compiling
foozmeat Apr 5, 2014
41be08d
ignore our build folder
foozmeat Apr 5, 2014
5aa3dfa
create fat binary
foozmeat Apr 5, 2014
540401c
adding Xcode wrapper project
foozmeat Apr 5, 2014
5624082
more work on the Xcode project
foozmeat Apr 5, 2014
c931b34
conditionally clean and build
foozmeat Apr 5, 2014
1abbc2c
error handling
foozmeat Apr 5, 2014
ef5760d
build as a static library
foozmeat Apr 5, 2014
725bc31
make build folder
foozmeat Apr 5, 2014
c95961d
renamed
foozmeat Apr 5, 2014
9e404b1
renamed to libserval
foozmeat Apr 5, 2014
a342f15
include headers
foozmeat Apr 5, 2014
8280f75
better cleanup
foozmeat Apr 5, 2014
86b4a79
adding confdefs
foozmeat Apr 5, 2014
a241c7d
added confdefs to project
foozmeat Apr 5, 2014
0a3a528
disable JNI
foozmeat Apr 5, 2014
6e0e74a
switching the source of the headers
foozmeat Apr 5, 2014
6a0ed0b
wrong flag
foozmeat Apr 5, 2014
9dffd2b
tem prefix
foozmeat Apr 11, 2014
c6f5574
Merge branch 'refs/heads/development' into xcode
foozmeat Apr 11, 2014
1a7b95d
clean up based on upstream changes
foozmeat Apr 11, 2014
4e34ee5
typo
foozmeat Apr 11, 2014
3a58d27
remove JNI mention
foozmeat Apr 13, 2014
d0aa5b8
use a different prefix for device vs simulator
foozmeat Apr 13, 2014
907ed55
configuration file
foozmeat Apr 13, 2014
bf6ece8
better static lib support
foozmeat Apr 13, 2014
c4a9c2a
renamed function to avoid a conflict on iOS
foozmeat Apr 14, 2014
266c159
switched headers
foozmeat Apr 14, 2014
e057e56
got the last of the defines fixed up
foozmeat Apr 15, 2014
3f5f6e9
we need these types
foozmeat Apr 15, 2014
3ed5ac6
removed trailing slashes
foozmeat Apr 15, 2014
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ serval.c
*.so
test.*.log
testlog
build
ios/libserval.xcodeproj/project.xcworkspace/xcuserdata/
ios/libserval.xcodeproj/xcuserdata/
8 changes: 6 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ sqlite-amalgamation-3070900/sqlite3.o: sqlite-amalgamation-3070900/sqlite3.c
@$(CC) $(CFLAGS) $(DEFS) -c $< -o sqlite-amalgamation-3070900/sqlite3.o

version.o: *.h *.c version_string.sh VERSION.txt COPYRIGHT.txt Makefile
@echo CC version_servald.c
@echo CC $(CFLAGS) version_servald.c
@V=`./version_string.sh --ignore-untracked` \
&& C="`sed -e :a -e N -e '$$!ba' -e 's/[\\\\"]/\\\\&/g' -e 's/\\n/\\\\n/g' COPYRIGHT.txt`" \
&& $(CC) -c version_servald.c -o $@ -DSERVALD_VERSION="\"$$V\"" -DSERVALD_COPYRIGHT="\"$$C\""
&& $(CC) $(CFLAGS) -c version_servald.c -o $@ -DSERVALD_VERSION="\"$$V\"" -DSERVALD_COPYRIGHT="\"$$C\""

VERSION.txt:

Expand Down Expand Up @@ -117,6 +117,10 @@ libserval.so: $(SERVALD_OBJS) version.o
@echo LINK $@
@$(CC) $(CFLAGS) -Wall -shared -o $@ $(SERVALD_OBJS) version.o $(LDFLAGS)

libserval.a: $(SERVALD_OBJS) version.o
@echo AR $@
@$(AR) -cr $@ $(SERVALD_OBJS) version.o

libmonitorclient.so: $(MONITOR_CLIENT_OBJS) version.o
@echo LINK $@
@$(CC) $(CFLAGS) -Wall -shared -o $@ $(MONITOR_CLIENT_OBJS) version.o $(LDFLAGS)
Expand Down
98 changes: 98 additions & 0 deletions ios/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/sh

# Created by James Moore on 3/25/14.
# Copyright (c) 2014 The Serval Project. All rights reserved.

# set -x

# if we're building inside of xcode we need to back up a level
if [[ -n $DEVELOPER_DIR ]]; then
cd ..
pwd
fi

# Add the homebrew tools to the path since automake no longer is apart of Xcode
PATH=/usr/local/bin:$PATH
ARCHS="armv7 armv7s arm64 i386 x86_64"
SDK_VERSION=7.1
PREFIX=$(pwd)/build
DEVELOPER=`xcode-select -print-path`
SYMROOT="build"

command -v autoreconf >/dev/null 2>&1 || { echo "In order to build this library you must have the autoreconf tool installed. It's available via homebrew."; exit 1; }

buildIOS()
{
ARCH=$1
HOST=""
PREFIX="/tmp/servald"

if [[ "${ARCH}" == "i386" ]]; then
PLATFORM="iPhoneSimulator"
HOST="--host=i386-apple-darwin"
elif [[ "${ARCH}" == "x86_64" ]]; then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
HOST="--host=arm-apple-darwin"
PREFIX="/Library/servald"
fi

CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
SDKROOT="${CROSS_TOP}/SDKs/${CROSS_SDK}"

export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot $SDKROOT -I$SDKROOT/usr/include -miphoneos-version-min=${SDK_VERSION}"
export CC="clang"

echo "=> Building libserval for ${PLATFORM} ${SDK_VERSION} ${ARCH}"

./configure $HOST --prefix $PREFIX &> "${SYMROOT}/libserval-${ARCH}.log" || { echo "configure failed"; exit 1; }

make libserval.a >> "${SYMROOT}/libserval-${ARCH}.log" 2>&1 || { echo "make failed"; exit 1; }
cp libserval.a ${SYMROOT}/libserval-${ARCH}.a
make clean >> "${SYMROOT}/libserval-${ARCH}.log" 2>&1 || { echo "make clean failed"; exit 1; }

}

#
# Start the build
#

if [[ $ACTION == "clean" ]]; then
echo "=> Cleaning..."
rm ${SYMROOT}/libserval.a 2> /dev/null
rm -rf ${SYMROOT}/libserval-* 2> /dev/null
rm -rf ${SYMROOT}/include 2> /dev/null
exit
fi

if [[ -f ${SYMROOT}/libserval.a ]]; then
echo "libserval has already been built...skipping"
exit
fi

# Generate configure
autoreconf -f -i

mkdir -p ${SYMROOT}

for arch in ${ARCHS}; do
buildIOS "${arch}"
done

echo "=> Building fat binary"

lipo \
"${SYMROOT}/libserval-armv7.a" \
"${SYMROOT}/libserval-armv7s.a" \
"${SYMROOT}/libserval-arm64.a" \
"${SYMROOT}/libserval-i386.a" \
"${SYMROOT}/libserval-x86_64.a" \
-create -output ${SYMROOT}/libserval.a || { echo "failed building fat library"; exit 1; }

echo "=> Copying Headers"
mkdir -p ${SYMROOT}/include
cp *.h ios/confdefs.h ${SYMROOT}/include

echo "=> Done"
62 changes: 62 additions & 0 deletions ios/confdefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// These were taken from the confdefs section of the config.log. This file might have to be regenerated in the future.

#define PACKAGE_NAME "servald"
#define PACKAGE_TARNAME "servald"
#define PACKAGE_VERSION "0.9"
#define PACKAGE_STRING "servald 0.9"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_PTHREAD_PRIO_INHERIT 1
#define HAVE_PTHREAD 1
#define HAVE_MATH_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LIBC 1
#define HAVE_GETPEEREID 1
#define HAVE_BCOPY 1
#define HAVE_BZERO 1
#define HAVE_BCMP 1
#define SIZEOF_OFF_T 8
#define HAVE_STDIO_H 1
#define HAVE_ERRNO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_UNISTD_H 1
#define HAVE_STRING_H 1
#define HAVE_ARPA_INET_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_UCRED_H 1
#define HAVE_POLL_H 1
#define HAVE_NETDB_H 1
#define HAVE_NET_IF_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_IFADDRS_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_SYS_FILIO_H 1
#define HAVE_SYS_SOCKIO_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SINF 1
#define HAVE_COSF 1
#define HAVE_TANF 1
#define HAVE_ASINF 1
#define HAVE_ACOSF 1
#define HAVE_ATANF 1
#define HAVE_ATAN2F 1
#define HAVE_CEILF 1
#define HAVE_FLOORF 1
#define HAVE_POWF 1
#define HAVE_EXPF 1
#define HAVE_LOGF 1
#define HAVE_LOG10F 1
#define HAVE_STRLCPY 1
Loading