Skip to content

Commit b2358f1

Browse files
committed
[recipe-lib] Make libsodium a library recipe and ...
also:   - make the imports from the right module   - fix hardcoded arch   - enable cpu count when compiling
1 parent eeb1b6d commit b2358f1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

pythonforandroid/recipes/libsodium/__init__.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2-
from os.path import exists, join
1+
from pythonforandroid.recipe import Recipe
2+
from pythonforandroid.util import current_directory
3+
from pythonforandroid.logger import shprint
4+
from multiprocessing import cpu_count
35
import sh
46

57

@@ -8,19 +10,21 @@ class LibsodiumRecipe(Recipe):
810
url = 'https://github.com/jedisct1/libsodium/releases/download/{version}/libsodium-{version}.tar.gz'
911
depends = []
1012
patches = ['size_max_fix.patch']
11-
12-
def should_build(self, arch):
13-
super(LibsodiumRecipe, self).should_build(arch)
14-
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libsodium.so'))
13+
built_libraries = {'libsodium.so': 'src/libsodium/.libs'}
1514

1615
def build_arch(self, arch):
17-
super(LibsodiumRecipe, self).build_arch(arch)
1816
env = self.get_recipe_env(arch)
1917
with current_directory(self.get_build_dir(arch.arch)):
2018
bash = sh.Command('bash')
21-
shprint(bash, 'configure', '--disable-soname-versions', '--host=arm-linux-androideabi', '--enable-shared', _env=env)
22-
shprint(sh.make, _env=env)
23-
shutil.copyfile('src/libsodium/.libs/libsodium.so', join(self.ctx.get_libs_dir(arch.arch), 'libsodium.so'))
19+
shprint(
20+
bash,
21+
'configure',
22+
'--disable-soname-versions',
23+
'--host={}'.format(arch.command_prefix),
24+
'--enable-shared',
25+
_env=env,
26+
)
27+
shprint(sh.make, '-j', str(cpu_count()), _env=env)
2428

2529
def get_recipe_env(self, arch):
2630
env = super(LibsodiumRecipe, self).get_recipe_env(arch)

0 commit comments

Comments
 (0)