Skip to content

Apsw recipe #665

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

Merged
merged 7 commits into from
Jun 18, 2016
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
37 changes: 37 additions & 0 deletions pythonforandroid/recipes/apsw/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from pythonforandroid.toolchain import PythonRecipe, shprint, shutil, current_directory
from os.path import join, exists
import sh

class ApswRecipe(PythonRecipe):
version = '3.11.1-r1'
url = 'https://github.com/rogerbinns/apsw/archive/{version}.tar.gz'
depends = ['sqlite3', 'hostpython2', 'python2', 'setuptools']
call_hostpython_via_targetpython = False
site_packages_name = 'apsw'

def build_arch(self, arch):
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
# Build python bindings
hostpython = sh.Command(self.hostpython_location)
shprint(hostpython,
'setup.py',
'build_ext',
'--enable=fts3'
, _env=env)
# Install python bindings
super(ApswRecipe, self).build_arch(arch)

def get_recipe_env(self, arch):
env = super(ApswRecipe, self).get_recipe_env(arch)
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \
' -I' + self.get_recipe('sqlite3', self.ctx).get_build_dir(arch.arch)
# Set linker to use the correct gcc
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
' -lpython2.7' + \
' -lsqlite3'
return env

recipe = ApswRecipe()
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()