Skip to content
Merged
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
16 changes: 12 additions & 4 deletions pythonforandroid/recipes/python2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Python2Recipe(TargetPythonRecipe):

depends = ['hostpython2']
conflicts = ['python3crystax', 'python3']
opt_depends = ['openssl']
opt_depends = ['openssl','sqlite3']

patches = ['patches/Python-{version}-xcompile.patch',
'patches/Python-{version}-ctypes-disable-wchar.patch',
Expand Down Expand Up @@ -68,9 +68,6 @@ def build_arch(self, arch):
# return

def do_python_build(self, arch):
if 'sqlite' in self.ctx.recipe_build_order:
print('sqlite support not yet enabled in python recipe')
exit(1)

hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx)
shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch))
Expand Down Expand Up @@ -101,6 +98,17 @@ def do_python_build(self, arch):
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal)
shprint(sh.sed, '-i', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal)

if 'sqlite3' in self.ctx.recipe_build_order:
# Include sqlite3 in python2 build
r = Recipe.get_recipe('sqlite3', self.ctx)
i = ' -I' + r.get_build_dir(arch.arch)
l = ' -L' + r.get_lib_dir(arch) + ' -lsqlite3'
# Insert or append to env
f = 'CPPFLAGS'
env[f] = env[f] + i if f in env else i
f = 'LDFLAGS'
env[f] = env[f] + l if f in env else l

configure = sh.Command('./configure')
# AND: OFLAG isn't actually set, should it be?
shprint(configure,
Expand Down
11 changes: 11 additions & 0 deletions pythonforandroid/recipes/sqlite3/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LOCAL_PATH := $(call my-dir)/..

include $(CLEAR_VARS)

LOCAL_SRC_FILES := sqlite3.c

LOCAL_MODULE := sqlite3

LOCAL_CFLAGS := -DSQLITE_ENABLE_FTS3

include $(BUILD_SHARED_LIBRARY)
32 changes: 32 additions & 0 deletions pythonforandroid/recipes/sqlite3/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from pythonforandroid.toolchain import NDKRecipe, shprint, shutil, current_directory
from os.path import join, exists
import sh

class Sqlite3Recipe(NDKRecipe):
version = '3.12.2'
# Don't forget to change the URL when changing the version
url = 'https://www.sqlite.org/2016/sqlite-amalgamation-3120200.zip'
generated_libraries = ['sqlite3']

def should_build(self, arch):
return not self.has_libs(arch, 'libsqlite3.so')

def prebuild_arch(self, arch):
super(Sqlite3Recipe, self).prebuild_arch(arch)
# Copy the Android make file
sh.mkdir('-p', join(self.get_build_dir(arch.arch), 'jni'))
shutil.copyfile(join(self.get_recipe_dir(), 'Android.mk'),
join(self.get_build_dir(arch.arch), 'jni/Android.mk'))

def build_arch(self, arch, *extra_args):
super(Sqlite3Recipe, self).build_arch(arch)
# Copy the shared library
shutil.copyfile(join(self.get_build_dir(arch.arch), 'libs', arch.arch, 'libsqlite3.so'),
join(self.ctx.get_libs_dir(arch.arch), 'libsqlite3.so'))

def get_recipe_env(self, arch):
env = super(Sqlite3Recipe, self).get_recipe_env(arch)
env['NDK_PROJECT_PATH'] = self.get_build_dir(arch.arch)
return env

recipe = Sqlite3Recipe()