-
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
Open
jiri-otoupal
wants to merge
5
commits into
kivy:develop
Choose a base branch
from
jiri-otoupal:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added lz4 #3071
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(arch), '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. You probably want |
||
|
||
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(arch), '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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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