14
14
from pythonforandroid .recipe import Recipe
15
15
16
16
17
- def copy_files (src_root , dest_root , override = True ):
17
+ def copy_files (src_root , dest_root , override = True , symlink = False ):
18
18
for root , dirnames , filenames in walk (src_root ):
19
19
for filename in filenames :
20
20
subdir = normpath (root .replace (src_root , "" ))
@@ -29,7 +29,10 @@ def copy_files(src_root, dest_root, override=True):
29
29
if override and os .path .exists (dest_file ):
30
30
os .unlink (dest_file )
31
31
if not os .path .exists (dest_file ):
32
- shutil .copy (src_file , dest_file )
32
+ if symlink :
33
+ os .symlink (src_file , dest_file )
34
+ else :
35
+ shutil .copy (src_file , dest_file )
33
36
else :
34
37
os .makedirs (dest_file )
35
38
@@ -109,7 +112,7 @@ def check_recipe_choices(self):
109
112
and optional dependencies are being used,
110
113
and returns a list of these.'''
111
114
recipes = []
112
- built_recipes = self .ctx .recipe_build_order
115
+ built_recipes = self .ctx .recipe_build_order or []
113
116
for recipe in self .recipe_depends :
114
117
if isinstance (recipe , (tuple , list )):
115
118
for alternative in recipe :
@@ -137,21 +140,27 @@ def name(self):
137
140
modname = self .__class__ .__module__
138
141
return modname .split ("." , 2 )[- 1 ]
139
142
143
+ def get_bootstrap_dirs (self ):
144
+ """get all bootstrap directories, following the MRO path"""
145
+
146
+ # get all bootstrap names along the __mro__, cutting off Bootstrap and object
147
+ classes = self .__class__ .__mro__ [:- 2 ]
148
+ bootstrap_names = [cls .name for cls in classes ] + ['common' ]
149
+ bootstrap_dirs = [
150
+ join (self .ctx .root_dir , 'bootstraps' , bootstrap_name )
151
+ for bootstrap_name in reversed (bootstrap_names )
152
+ ]
153
+ return bootstrap_dirs
154
+
140
155
def prepare_build_dir (self ):
141
- '''Ensure that a build dir exists for the recipe. This same single
142
- dir will be used for building all different archs.'''
156
+ """Ensure that a build dir exists for the recipe. This same single
157
+ dir will be used for building all different archs."""
158
+ bootstrap_dirs = self .get_bootstrap_dirs ()
159
+ # now do a cumulative copy of all bootstrap dirs
143
160
self .build_dir = self .get_build_dir ()
144
- self .common_dir = self .get_common_dir ()
145
- copy_files (join (self .bootstrap_dir , 'build' ), self .build_dir )
146
- copy_files (join (self .common_dir , 'build' ), self .build_dir ,
147
- override = False )
148
- if self .ctx .symlink_java_src :
149
- info ('Symlinking java src instead of copying' )
150
- shprint (sh .rm , '-r' , join (self .build_dir , 'src' ))
151
- shprint (sh .mkdir , join (self .build_dir , 'src' ))
152
- for dirn in listdir (join (self .bootstrap_dir , 'build' , 'src' )):
153
- shprint (sh .ln , '-s' , join (self .bootstrap_dir , 'build' , 'src' , dirn ),
154
- join (self .build_dir , 'src' ))
161
+ for bootstrap_dir in bootstrap_dirs :
162
+ copy_files (join (bootstrap_dir , 'build' ), self .build_dir , symlink = self .ctx .symlink_bootstrap_files )
163
+
155
164
with current_directory (self .build_dir ):
156
165
with open ('project.properties' , 'w' ) as fileh :
157
166
fileh .write ('target=android-{}' .format (self .ctx .android_api ))
0 commit comments