Skip to content

Commit 4d3d471

Browse files
committed
Merge pull request #1 from wtud/cookbook
Recipes for (lib)swift and apsw
2 parents 84ed3ee + d003602 commit 4d3d471

File tree

4 files changed

+241
-0
lines changed

4 files changed

+241
-0
lines changed

recipes/apsw/recipe.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
3+
4+
# version of your package
5+
VERSION_apsw=${VERSION_apsw:-3.8.4.1-r1}
6+
7+
8+
# dependencies of this recipe
9+
DEPS_apsw=(python)
10+
11+
12+
# url of the package
13+
URL_apsw=https://github.com/rogerbinns/apsw/releases/download/3.8.4.1-r1/apsw-3.8.4.1-r1.zip
14+
15+
16+
# md5 of the package
17+
MD5_apsw=5ad3098489576929b90f4215eb5b2621
18+
19+
20+
# default build path
21+
BUILD_apsw=$BUILD_PATH/apsw/$(get_directory $URL_apsw)
22+
23+
24+
# default recipe path
25+
RECIPE_apsw=$RECIPES_PATH/apsw
26+
27+
28+
# function called for preparing source code if needed
29+
# (you can apply patch etc here.)
30+
function prebuild_apsw() {
31+
32+
33+
# fetch sqlite if necessary
34+
cd ${BUILD_apsw}
35+
if [ ! -d ${BUILD_apsw}/sqlite3 ]; then
36+
echo "fetching sqlite..."
37+
# using /usr/bin/python for this
38+
python setup.py fetch --sqlite --version=3.8.4.1 --missing-checksum-ok
39+
fi
40+
41+
42+
# apsw insists on configuring sqlite, but it's for the host, not the target.
43+
# So, put in the correct values.
44+
45+
46+
cat >sqlite3/sqlite3config.h <<EOF
47+
#define HAVE_SYS_TYPES_H 1
48+
#define HAVE_SYS_STAT_H 1
49+
#define HAVE_STDLIB_H 1
50+
#define HAVE_STRING_H 1
51+
#define HAVE_MEMORY_H 1
52+
#define HAVE_STRINGS_H 1
53+
#define HAVE_INTTYPES_H 1
54+
#define HAVE_STDINT_H 1
55+
#define HAVE_UNISTD_H 1
56+
#define HAVE_DLFCN_H 1
57+
#define HAVE_FDATASYNC 0
58+
#define HAVE_USLEEP 1
59+
#define HAVE_LOCALTIME_R 1
60+
#define HAVE_GMTIME_R 1
61+
#define HAVE_DECL_STRERROR_R 1
62+
#define HAVE_STRERROR_R 1
63+
#define HAVE_POSIX_FALLOCATE 0
64+
EOF
65+
66+
67+
}
68+
69+
70+
function shouldbuild_apsw() {
71+
if [ -d "$SITEPACKAGES_PATH/apsw" ]; then
72+
DO_BUILD=0
73+
fi
74+
}
75+
76+
77+
# function called to build the source code
78+
function build_apsw() {
79+
80+
81+
cd ${BUILD_apsw}
82+
83+
84+
export NDK=$ANDROIDNDK
85+
push_arm
86+
87+
88+
# HOSTPYTHON can't do zipfile or tarfile modules because of
89+
# buildozer bug (missing LD_LIBRARY_PATH is what it looks like),
90+
# but we don't need them at this stage
91+
cp setup.py setup.py.backup
92+
sed -e 's/import zipfile, tarfile/# import zipfile, tarfile/g' <setup.py.backup >setup.py
93+
94+
95+
# build python extension
96+
export LDFLAGS="$LDFLAGS -L$LIBS_PATH"
97+
export LDSHARED="$LIBLINK"
98+
99+
100+
echo "building apsw in `pwd`..."
101+
# now we can build; enable the FTS4 sqlite extension for full-text search
102+
try ${HOSTPYTHON} setup.py build --enable=fts4
103+
echo "installing apsw..."
104+
try ${HOSTPYTHON} setup.py install
105+
echo "done with apsw."
106+
107+
108+
pop_arm
109+
}
110+
111+
112+
# function called after all the compile have been done
113+
function postbuild_apsw() {
114+
echo "apsw built"
115+
}
116+

recipes/libswift/recipe.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
#TODO get a release version if possible
4+
VERSION_libswift=
5+
DEPS_libswift=()
6+
#TODO get a version specific URL and update the md5sum
7+
#URL_libswift=https://github.com/whirm/tgs-android/archive/master.zip
8+
#MD5_libswift=23ce86e2bd4d213fdcf1d8c5c37a979a
9+
URL_libswift=https://nodeload.github.com/triblerteam/libswift/zip/4123e6579309cd65a5ba3800e0b674f348c62bfb
10+
FILENAME_libswift=4123e6579309cd65a5ba3800e0b674f348c62bfb
11+
EXTRACT_libswift=$BUILD_PATH/libswift/libswift-$FILENAME_libswift
12+
BUILD_libswift=$BUILD_PATH/libswift/libswift
13+
RECIPE_libswift=$RECIPES_PATH/libswift
14+
15+
function prebuild_libswift() {
16+
true
17+
}
18+
19+
function build_libswift() {
20+
if [ ! -d "$BUILD_libswift" ]; then
21+
cd $BUILD_PATH/libswift
22+
mkdir -p libswift
23+
unzip $PACKAGES_PATH/$FILENAME_libswift
24+
rm -Rf libswift/jni
25+
mv $EXTRACT_libswift libswift/jni
26+
fi
27+
cd $BUILD_libswift
28+
mkdir -p libs
29+
30+
if [ -f "$BUILD_PATH/libs/libevent.so" ]; then
31+
#return
32+
true
33+
fi
34+
35+
push_arm
36+
37+
#FIXME get it so you don't have to download the jni module manually
38+
export LDFLAGS=$LIBLINK
39+
try ndk-build -C $BUILD_libswift/jni
40+
unset LDFLAGS
41+
42+
#TODO find out why it's libevent.so and not libswift.so
43+
try cp -a $BUILD_libswift/libs/$ARCH/*.so $LIBS_PATH
44+
45+
pop_arm
46+
}
47+
48+
function postbuild_libswift() {
49+
true
50+
}
51+

recipes/swift/extra/Android.mk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
5+
LOCAL_MODULE := libevent2
6+
7+
LOCAL_SRC_FILES := libevent2/lib/libevent.a
8+
LOCAL_EXPORT_C_INCLUDES := libevent2/include
9+
LOCAL_C_INCLUDES := libevent2/include
10+
11+
include $(PREBUILT_STATIC_LIBRARY)
12+
13+
LOCAL_MODULE := swift
14+
LOCAL_SRC_FILES := swift.cpp sha1.cpp compat.cpp sendrecv.cpp send_control.cpp hashtree.cpp bin.cpp binmap.cpp binheap.cpp channel.cpp transfer.cpp httpgw.cpp statsgw.cpp cmdgw.cpp avgspeed.cpp availability.cpp
15+
16+
LOCAL_CFLAGS += -D__NEW__
17+
18+
LOCAL_STATIC_LIBRARIES := libevent2
19+
20+
#include $(BUILD_SHARED_LIBRARY)
21+
include $(BUILD_EXECUTABLE)

recipes/swift/recipe.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
#TODO get a release version if possible
4+
VERSION_swift=
5+
DEPS_swift=()
6+
URL_swift=https://nodeload.github.com/triblerteam/libswift/zip/4123e6579309cd65a5ba3800e0b674f348c62bfb
7+
MD5_swift=99cf78ea0b4aeb23a2439dd886f00f8f
8+
FILENAME_swift=4123e6579309cd65a5ba3800e0b674f348c62bfb
9+
EXTRACT_swift=$BUILD_PATH/swift/libswift-$FILENAME_swift
10+
BUILD_swift=$BUILD_PATH/swift/swift
11+
RECIPE_swift=$RECIPES_PATH/swift
12+
13+
function prebuild_swift() {
14+
true
15+
}
16+
17+
function build_swift() {
18+
if [ ! -d "$BUILD_swift" ]; then
19+
cd $BUILD_PATH/swift
20+
mkdir -p swift
21+
unzip $PACKAGES_PATH/$FILENAME_swift
22+
rm -Rf swift/jni
23+
mv $EXTRACT_swift swift/jni
24+
25+
# Use differend Android.mk to create a binary instead of a library
26+
cp $RECIPE_swift/extra/Android.mk swift/jni/Android.mk
27+
fi
28+
29+
cd $BUILD_swift
30+
mkdir -p libs
31+
32+
if [ -f "$BUILD_PATH/libs/swift" ]; then
33+
#return
34+
true
35+
fi
36+
37+
push_arm
38+
39+
#FIXME get it so you don't have to download the jni module manually
40+
export LDFLAGS=$LIBLINK
41+
try ndk-build -C $BUILD_swift/jni
42+
unset LDFLAGS
43+
44+
#TODO find out why it's libevent.so and not libswift.so
45+
try cp -a $BUILD_swift/libs/$ARCH/libevent $LIBS_PATH/swift
46+
47+
pop_arm
48+
}
49+
50+
function postbuild_swift() {
51+
true
52+
}
53+

0 commit comments

Comments
 (0)