lbry-fdroid/p4a/pythonforandroid/recipes/leveldb/__init__.py
Akinwale Ariwodola 8b2694efb7
New build (#508)
* fix build for openssl 1.1.1b required for sdk
(cherry picked from commit aa49e3b2755b97b6331cdbbb89efc954de8d5977)

* use js code from master

* fix openssl recipe and tweak build
(cherry picked from commit 6e94c27021c7bd7b1e880c2fc314850e36a5a38e)

* remove unused build recipes
(cherry picked from commit f5c0577bdb175bfc0990602936bbc9e2052e1f25)
2019-03-30 21:58:45 +01:00

48 lines
2.3 KiB
Python

from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
from os.path import join
import sh
class LevelDBRecipe(Recipe):
version = '1.18'
url = 'https://github.com/google/leveldb/archive/v{version}.tar.gz'
opt_depends = ['snappy']
patches = ['disable-so-version.patch', 'find-snappy.patch']
def should_build(self, arch):
return not self.has_libs(arch, 'libleveldb.so', 'libgnustl_shared.so')
def build_arch(self, arch):
super(LevelDBRecipe, self).build_arch(arch)
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
if 'snappy' in recipe.ctx.recipe_build_order:
# Copy source from snappy recipe
sh.cp('-rf', self.get_recipe('snappy', self.ctx).get_build_dir(arch.arch), 'snappy')
# Build
shprint(sh.make, _env=env)
# Copy the shared library
shutil.copyfile('libleveldb.so', join(self.ctx.get_libs_dir(arch.arch), 'libleveldb.so'))
# Copy stl
shutil.copyfile(self.ctx.ndk_dir + '/sources/cxx-stl/gnu-libstdc++/' + self.ctx.toolchain_version + '/libs/' + arch.arch + '/libgnustl_shared.so',
join(self.ctx.get_libs_dir(arch.arch), 'libgnustl_shared.so'))
def get_recipe_env(self, arch):
env = super(LevelDBRecipe, self).get_recipe_env(arch)
env['TARGET_OS'] = 'OS_ANDROID_CROSSCOMPILE'
if 'snappy' in recipe.ctx.recipe_build_order:
env['CFLAGS'] += ' -DSNAPPY' + \
' -I./snappy'
env['CFLAGS'] += ' -I' + self.ctx.ndk_dir + '/platforms/android-' + str(self.ctx.android_api) + '/arch-' + arch.arch.replace('eabi', '') + '/usr/include' + \
' -I' + self.ctx.ndk_dir + '/sources/cxx-stl/gnu-libstdc++/' + self.ctx.toolchain_version + '/include' + \
' -I' + self.ctx.ndk_dir + '/sources/cxx-stl/gnu-libstdc++/' + self.ctx.toolchain_version + '/libs/' + arch.arch + '/include'
env['CXXFLAGS'] = env['CFLAGS']
env['CXXFLAGS'] += ' -frtti'
env['CXXFLAGS'] += ' -fexceptions'
env['LDFLAGS'] += ' -L' + self.ctx.ndk_dir + '/sources/cxx-stl/gnu-libstdc++/' + self.ctx.toolchain_version + '/libs/' + arch.arch + \
' -lgnustl_shared'
return env
recipe = LevelDBRecipe()