@@ -24,7 +24,7 @@ class Distribution(object):
24
24
ndk_api = None
25
25
26
26
archs = []
27
- '''The arch targets that the dist is built for.'''
27
+ '''The names of the arch targets that the dist is built for.'''
28
28
29
29
recipes = []
30
30
@@ -44,6 +44,7 @@ def __repr__(self):
44
44
@classmethod
45
45
def get_distribution (cls , ctx , name = None , recipes = [],
46
46
ndk_api = None ,
47
+ arch_name = None ,
47
48
force_build = False ,
48
49
extra_dist_dirs = [],
49
50
require_perfect_match = False ,
@@ -60,6 +61,12 @@ def get_distribution(cls, ctx, name=None, recipes=[],
60
61
name : str
61
62
The name of the distribution. If a dist with this name already '
62
63
exists, it will be used.
64
+ ndk_api : int
65
+ The NDK API to compile against, included in the dist because it cannot
66
+ be changed later during APK packaging.
67
+ arch : Arch
68
+ The target architecture to compile against, included in the dist because
69
+ it cannot be changed later during APK packaging.
63
70
recipes : list
64
71
The recipes that the distribution must contain.
65
72
force_download: bool
@@ -81,13 +88,14 @@ def get_distribution(cls, ctx, name=None, recipes=[],
81
88
82
89
possible_dists = existing_dists
83
90
84
- name_match_dist = None
91
+ name_match_dists = []
85
92
86
- # 0) Check if a dist with that name already exists
93
+ # 0) Check if a dist with that name and architecture already exists
94
+ # There may be more than one dist with the same name but different arch targets
87
95
if name is not None and name :
88
- possible_dists = [d for d in possible_dists if d . name == name ]
89
- if possible_dists :
90
- name_match_dist = possible_dists [ 0 ]
96
+ possible_dists = [
97
+ d for d in possible_dists if
98
+ ( d . name == name ) and ( arch_name in d . archs ) ]
91
99
92
100
# 1) Check if any existing dists meet the requirements
93
101
_possible_dists = []
@@ -110,12 +118,14 @@ def get_distribution(cls, ctx, name=None, recipes=[],
110
118
else :
111
119
info ('No existing dists meet the given requirements!' )
112
120
113
- # If any dist has perfect recipes and ndk API, return it
121
+ # If any dist has perfect recipes, arch and NDK API, return it
114
122
for dist in possible_dists :
115
123
if force_build :
116
124
continue
117
125
if ndk_api is not None and dist .ndk_api != ndk_api :
118
126
continue
127
+ if arch_name is not None and arch_name not in dist .archs :
128
+ continue
119
129
if (set (dist .recipes ) == set (recipes ) or
120
130
(set (recipes ).issubset (set (dist .recipes )) and
121
131
not require_perfect_match )):
@@ -128,7 +138,7 @@ def get_distribution(cls, ctx, name=None, recipes=[],
128
138
# If there was a name match but we didn't already choose it,
129
139
# then the existing dist is incompatible with the requested
130
140
# configuration and the build cannot continue
131
- if name_match_dist is not None and not allow_replace_dist :
141
+ if name_match_dists and not allow_replace_dist :
132
142
raise BuildInterruptingException (
133
143
'Asked for dist with name {name} with recipes ({req_recipes}) and '
134
144
'NDK API {req_ndk_api}, but a dist '
@@ -152,9 +162,14 @@ def get_distribution(cls, ctx, name=None, recipes=[],
152
162
name = filen .format (i )
153
163
154
164
dist .name = name
155
- dist .dist_dir = join (ctx .dist_dir , dist .name )
165
+ dist .dist_dir = join (
166
+ ctx .dist_dir ,
167
+ generate_dist_folder_name (name , [arch_name ])
168
+ )
156
169
dist .recipes = recipes
157
170
dist .ndk_api = ctx .ndk_api
171
+ dist .archs = [arch_name ]
172
+
158
173
159
174
return dist
160
175
@@ -182,7 +197,7 @@ def get_distributions(cls, ctx, extra_dist_dirs=[]):
182
197
with open (join (folder , 'dist_info.json' )) as fileh :
183
198
dist_info = json .load (fileh )
184
199
dist = cls (ctx )
185
- dist .name = folder . split ( '/' )[ - 1 ]
200
+ dist .name = dist_info [ 'dist_name' ]
186
201
dist .dist_dir = folder
187
202
dist .needs_build = False
188
203
dist .recipes = dist_info ['recipes' ]
@@ -236,3 +251,22 @@ def pretty_log_dists(dists, log_func=info):
236
251
237
252
for line in infos :
238
253
log_func ('\t ' + line )
254
+
255
+ def generate_dist_folder_name (base_dist_name , arch_names = None ):
256
+ """Generate the distribution folder name to use, based on a
257
+ combination of the input arguments.
258
+
259
+ Parameters
260
+ ----------
261
+ base_dist_name : str
262
+ The core distribution identifier string
263
+ arch_names : list of str
264
+ The architecture compile targets
265
+ """
266
+ if arch_names is None :
267
+ arch_names = ["no_arch_specified" ]
268
+
269
+ return '{}__{}' .format (
270
+ base_dist_name ,
271
+ '_' .join (arch_names )
272
+ )
0 commit comments