1
+ from os import makedirs , remove
2
+ from os .path import exists , join
1
3
import sh
2
- from os . path import join
4
+
3
5
from pythonforandroid .recipe import Recipe
4
6
from pythonforandroid .logger import shprint
5
7
@@ -20,17 +22,34 @@ class LibRt(Recipe):
20
22
def libc_path (self ):
21
23
return join (self .ctx .ndk_platform , 'usr' , 'lib' , 'libc' )
22
24
23
- @property
24
- def librt_path (self ):
25
- return join (self .ctx .ndk_platform , 'usr' , 'lib' , 'librt' )
26
-
27
25
def build_arch (self , arch ):
28
- shprint (sh .ln , '-sf' , self .libc_path + '.so' , self .librt_path + '.so' )
29
- shprint (sh .ln , '-sf' , self .libc_path + '.a' , self .librt_path + '.a' )
30
-
31
- def postbuild_arch (self , arch ):
32
- shprint (sh .rm , self .librt_path + '.so' )
33
- shprint (sh .rm , self .librt_path + '.a' )
26
+ # Create a temporary folder to add to link path with a fake librt.so:
27
+ fake_librt_temp_folder = join (
28
+ self .get_build_dir (arch .arch ),
29
+ "p4a-librt-recipe-tempdir"
30
+ )
31
+ if not exists (fake_librt_temp_folder ):
32
+ makedirs (fake_librt_temp_folder )
33
+
34
+ # Set symlinks, and make sure to update them on every build run:
35
+ if exists (join (fake_librt_temp_folder , "librt.so" )):
36
+ remove (join (fake_librt_temp_folder , "librt.so" ))
37
+ shprint (sh .ln , '-sf' ,
38
+ self .libc_path + '.so' ,
39
+ join (fake_librt_temp_folder , "librt.so" ),
40
+ )
41
+ if exists (join (fake_librt_temp_folder , "librt.a" )):
42
+ remove (join (fake_librt_temp_folder , "librt.a" ))
43
+ shprint (sh .ln , '-sf' ,
44
+ self .libc_path + '.a' ,
45
+ join (fake_librt_temp_folder , "librt.a" ),
46
+ )
47
+
48
+ # Add folder as -L link option for all recipes if not done yet:
49
+ if fake_librt_temp_folder not in arch .extra_global_link_paths :
50
+ arch .extra_global_link_paths .append (
51
+ fake_librt_temp_folder
52
+ )
34
53
35
54
36
55
recipe = LibRt ()
0 commit comments