|
| 1 | +import sh |
| 2 | + |
| 3 | +from multiprocessing import cpu_count |
| 4 | + |
| 5 | +from pythonforandroid.archs import Arch |
| 6 | +from pythonforandroid.logger import shprint |
| 7 | +from pythonforandroid.recipe import Recipe |
| 8 | +from pythonforandroid.util import current_directory |
| 9 | + |
| 10 | + |
| 11 | +class LibBz2Recipe(Recipe): |
| 12 | + |
| 13 | + version = "1.0.8" |
| 14 | + url = "https://sourceware.org/pub/bzip2/bzip2-{version}.tar.gz" |
| 15 | + built_libraries = {"libbz2.so": ""} |
| 16 | + patches = ["lib_android.patch"] |
| 17 | + |
| 18 | + def build_arch(self, arch: Arch) -> None: |
| 19 | + env = self.get_recipe_env(arch) |
| 20 | + with current_directory(self.get_build_dir(arch.arch)): |
| 21 | + shprint( |
| 22 | + sh.make, |
| 23 | + "-j", |
| 24 | + str(cpu_count()), |
| 25 | + f'CC={env["CC"]}', |
| 26 | + f'AR={env["AR"]}', |
| 27 | + f'RANLIB={env["RANLIB"]}', |
| 28 | + "-f", |
| 29 | + "Makefile-libbz2_so", |
| 30 | + _env=env, |
| 31 | + ) |
| 32 | + |
| 33 | + def get_library_includes(self, arch: Arch) -> str: |
| 34 | + """ |
| 35 | + Returns a string with the appropriate `-I<lib directory>` to link |
| 36 | + with the bz2 lib. This string is usually added to the environment |
| 37 | + variable `CPPFLAGS`. |
| 38 | + """ |
| 39 | + return " -I" + self.get_build_dir(arch.arch) |
| 40 | + |
| 41 | + def get_library_ldflags(self, arch: Arch) -> str: |
| 42 | + """ |
| 43 | + Returns a string with the appropriate `-L<lib directory>` to link |
| 44 | + with the bz2 lib. This string is usually added to the environment |
| 45 | + variable `LDFLAGS`. |
| 46 | + """ |
| 47 | + return " -L" + self.get_build_dir(arch.arch) |
| 48 | + |
| 49 | + @staticmethod |
| 50 | + def get_library_libs_flag() -> str: |
| 51 | + """ |
| 52 | + Returns a string with the appropriate `-l<lib>` flags to link with |
| 53 | + the bz2 lib. This string is usually added to the environment |
| 54 | + variable `LIBS`. |
| 55 | + """ |
| 56 | + return " -lbz2" |
| 57 | + |
| 58 | + |
| 59 | +recipe = LibBz2Recipe() |
0 commit comments