|
| 1 | +import sh |
| 2 | + |
| 3 | +from multiprocessing import cpu_count |
| 4 | +from os.path import exists, join |
| 5 | + |
| 6 | +from pythonforandroid.archs import Arch |
| 7 | +from pythonforandroid.logger import shprint |
| 8 | +from pythonforandroid.recipe import Recipe |
| 9 | +from pythonforandroid.util import current_directory, ensure_dir |
| 10 | + |
| 11 | + |
| 12 | +class LibLzmaRecipe(Recipe): |
| 13 | + |
| 14 | + version = '5.2.4' |
| 15 | + url = 'https://tukaani.org/xz/xz-{version}.tar.gz' |
| 16 | + built_libraries = {'liblzma.so': 'install/lib'} |
| 17 | + |
| 18 | + def build_arch(self, arch: Arch) -> None: |
| 19 | + env = self.get_recipe_env(arch) |
| 20 | + install_dir = join(self.get_build_dir(arch.arch), 'install') |
| 21 | + with current_directory(self.get_build_dir(arch.arch)): |
| 22 | + if not exists('configure'): |
| 23 | + shprint(sh.Command('./autogen.sh'), _env=env) |
| 24 | + shprint(sh.Command('autoreconf'), '-vif', _env=env) |
| 25 | + shprint(sh.Command('./configure'), |
| 26 | + '--host=' + arch.command_prefix, |
| 27 | + '--prefix=' + install_dir, |
| 28 | + '--disable-builddir', |
| 29 | + '--disable-static', |
| 30 | + '--enable-shared', |
| 31 | + |
| 32 | + '--disable-xz', |
| 33 | + '--disable-xzdec', |
| 34 | + '--disable-lzmadec', |
| 35 | + '--disable-lzmainfo', |
| 36 | + '--disable-scripts', |
| 37 | + '--disable-doc', |
| 38 | + |
| 39 | + _env=env) |
| 40 | + shprint( |
| 41 | + sh.make, '-j', str(cpu_count()), |
| 42 | + _env=env |
| 43 | + ) |
| 44 | + |
| 45 | + ensure_dir('install') |
| 46 | + shprint(sh.make, 'install', _env=env) |
| 47 | + |
| 48 | + def get_library_includes(self, arch: Arch) -> str: |
| 49 | + """ |
| 50 | + Returns a string with the appropriate `-I<lib directory>` to link |
| 51 | + with the lzma lib. This string is usually added to the environment |
| 52 | + variable `CPPFLAGS`. |
| 53 | + """ |
| 54 | + return " -I" + join( |
| 55 | + self.get_build_dir(arch.arch), 'install', 'include', |
| 56 | + ) |
| 57 | + |
| 58 | + def get_library_ldflags(self, arch: Arch) -> str: |
| 59 | + """ |
| 60 | + Returns a string with the appropriate `-L<lib directory>` to link |
| 61 | + with the lzma lib. This string is usually added to the environment |
| 62 | + variable `LDFLAGS`. |
| 63 | + """ |
| 64 | + return " -L" + join( |
| 65 | + self.get_build_dir(arch.arch), self.built_libraries['liblzma.so'], |
| 66 | + ) |
| 67 | + |
| 68 | + @staticmethod |
| 69 | + def get_library_libs_flag() -> str: |
| 70 | + """ |
| 71 | + Returns a string with the appropriate `-l<lib>` flags to link with |
| 72 | + the lzma lib. This string is usually added to the environment |
| 73 | + variable `LIBS`. |
| 74 | + """ |
| 75 | + return " -llzma" |
| 76 | + |
| 77 | + |
| 78 | +recipe = LibLzmaRecipe() |
0 commit comments