-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Added lz4 #3071
base: develop
Are you sure you want to change the base?
Added lz4 #3071
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from os.path import join | ||
|
||
import sh | ||
|
||
from pythonforandroid.logger import shprint | ||
from pythonforandroid.recipe import Recipe | ||
from pythonforandroid.toolchain import current_directory | ||
|
||
|
||
class LibLZ4Recipe(Recipe): | ||
name = 'liblz4' | ||
version = '1.9.4' # Use the desired version | ||
url = 'https://github.com/lz4/lz4/archive/refs/tags/v{version}.tar.gz' | ||
depends = [] | ||
|
||
def build_arch(self, arch): | ||
env = self.get_recipe_env(arch) | ||
build_dir = self.get_build_dir(arch.arch) | ||
lib_dir = self.ctx.get_libs_dir(arch.arch) | ||
include_dir = join(self.ctx.get_python_install_dir(), 'include', 'lz4') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI is failing with:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, did you have a chance to test the recipe on-device, is it working? |
||
|
||
# Ensure include directory exists | ||
if not os.path.exists(include_dir): | ||
os.makedirs(include_dir) | ||
|
||
with current_directory(join(build_dir, 'lib')): | ||
# Clean previous builds | ||
shprint(sh.make, 'clean', _env=env) | ||
# Build the static library | ||
shprint(sh.make, 'CC={}'.format(env['CC']), 'liblz4.a', _env=env) | ||
# Copy the static library to the libs directory | ||
sh.cp('liblz4.a', lib_dir) | ||
# Copy headers to the include directory | ||
sh.cp('lz4.h', include_dir) | ||
sh.cp('lz4frame.h', include_dir) | ||
sh.cp('lz4hc.h', include_dir) | ||
sh.cp('xxhash.h', include_dir) | ||
|
||
def get_recipe_env(self, arch): | ||
env = super().get_recipe_env(arch) | ||
# Ensure the correct compiler is used | ||
python_recipe = self.get_recipe('python3', self.ctx) | ||
env['CC'] = python_recipe.get_recipe_env(arch)['CC'] | ||
return env | ||
|
||
|
||
recipe = LibLZ4Recipe() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from os.path import join | ||
|
||
from pythonforandroid.recipe import CompiledComponentsPythonRecipe | ||
|
||
|
||
class Lz4Recipe(CompiledComponentsPythonRecipe): | ||
name = 'lz4' | ||
version = '4.3.2' # Use the desired version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drop this comment too |
||
url = 'https://pypi.python.org/packages/source/l/lz4/lz4-{version}.tar.gz' | ||
depends = ['setuptools', 'liblz4'] | ||
call_hostpython_via_targetpython = False | ||
|
||
def get_recipe_env(self, arch): | ||
env = super().get_recipe_env(arch) | ||
ctx = self.ctx | ||
|
||
# Include the headers from liblz4 | ||
lz4_include_dir = join(ctx.get_python_install_dir(), 'include', 'lz4') | ||
env['CFLAGS'] += f' -I{lz4_include_dir}' | ||
|
||
# Link against the liblz4 library | ||
lz4_lib_dir = ctx.get_libs_dir(arch.arch) | ||
env['LDFLAGS'] += f' -L{lz4_lib_dir} -llz4' | ||
|
||
return env | ||
|
||
|
||
recipe = Lz4Recipe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably drop this comment