1+ from pythonforandroid .toolchain import Recipe , shprint , shutil , current_directory
2+ from os .path import exists , join
3+ import os
4+ import sys
5+ from multiprocessing import cpu_count
6+ import sh
7+
8+
9+ class BitmsghashRecipe (Recipe ):
10+ # This could also inherit from PythonRecipe etc. if you want to
11+ # use their pre-written build processes
12+
13+ url = 'https://github.com/surbhicis/bitmsghash/archive/master.zip'
14+ # {version} will be replaced with self.version when downloading
15+
16+ depends = ['openssl' ]
17+
18+ conflicts = []
19+
20+ def get_recipe_env (self , arch = None ):
21+ env = super (BitmsghashRecipe , self ).get_recipe_env (arch )
22+ r = Recipe .get_recipe ('openssl' , self .ctx )
23+ b = r .get_build_dir (arch .arch )
24+ env ['CCFLAGS' ] = env ['CFLAGS' ] = \
25+ env ['CFLAGS' ] + ' -I{openssl_build_path}/include ' \
26+ '-I{openssl_build_path}/include/openssl' .format (
27+ openssl_build_path = b )
28+ env ['LDFLAGS' ] = \
29+ env ['LDFLAGS' ] + ' -L{openssl_build_path} ' \
30+ '-lcrypto{openssl_version} ' \
31+ '-lssl{openssl_version}' .format (
32+ openssl_build_path = b ,
33+ openssl_version = r .version )
34+ return env
35+
36+ def should_build (self , arch = None ):
37+ super (BitmsghashRecipe , self ).should_build (arch )
38+ return not exists (
39+ join (self .ctx .get_libs_dir (arch .arch ), 'libbitmsghash.so' ))
40+
41+ def build_arch (self , arch = None ):
42+ super (BitmsghashRecipe , self ).build_arch (arch )
43+ env = self .get_recipe_env (arch )
44+ with current_directory (join (self .get_build_dir (arch .arch ))):
45+ dst_dir = join (self .get_build_dir (arch .arch ))
46+ shprint (sh .make , '-j' , str (cpu_count ()), _env = env )
47+ self .install_libs (arch , '{}/libbitmsghash.so' .format (dst_dir ),
48+ 'libbitmsghash.so' )
49+
50+ recipe = BitmsghashRecipe ()
0 commit comments