@@ -83,6 +83,8 @@ def get_distribution(cls, ctx, name=None, recipes=[],
83
83
84
84
name_match_dist = None
85
85
86
+ req_archs = [arch .arch for arch in ctx .archs ]
87
+
86
88
# 0) Check if a dist with that name already exists
87
89
if name is not None and name :
88
90
possible_dists = [d for d in possible_dists if d .name == name ]
@@ -92,7 +94,14 @@ def get_distribution(cls, ctx, name=None, recipes=[],
92
94
# 1) Check if any existing dists meet the requirements
93
95
_possible_dists = []
94
96
for dist in possible_dists :
95
- if (dist .ndk_api != ctx .ndk_api ) or dist .ndk_api is None :
97
+ if any (
98
+ [
99
+ dist .ndk_api != ctx .ndk_api ,
100
+ dist .android_api != ctx .android_api ,
101
+ set (dist .archs ) != set (req_archs ),
102
+ dist .ndk_api is None ,
103
+ ]
104
+ ):
96
105
continue
97
106
for recipe in recipes :
98
107
if recipe not in dist .recipes :
@@ -108,12 +117,11 @@ def get_distribution(cls, ctx, name=None, recipes=[],
108
117
else :
109
118
info ('No existing dists meet the given requirements!' )
110
119
111
- # If any dist has perfect recipes and ndk API, return it
120
+ # 2) Of the possible dists we will select the one which contains the
121
+ # requested recipes, unless we used the kwarg `force_build`
112
122
for dist in possible_dists :
113
123
if force_build :
114
124
continue
115
- if ctx .ndk_api is not None and dist .ndk_api != ctx .ndk_api :
116
- continue
117
125
if (set (dist .recipes ) == set (recipes ) or
118
126
(set (recipes ).issubset (set (dist .recipes )) and
119
127
not require_perfect_match )):
@@ -123,22 +131,35 @@ def get_distribution(cls, ctx, name=None, recipes=[],
123
131
124
132
assert len (possible_dists ) < 2
125
133
126
- # If there was a name match but we didn't already choose it,
134
+ # 3) If there was a name match but we didn't already choose it,
127
135
# then the existing dist is incompatible with the requested
128
136
# configuration and the build cannot continue
129
137
if name_match_dist is not None and not allow_replace_dist :
130
138
raise BuildInterruptingException (
131
- 'Asked for dist with name {name} with recipes ({req_recipes}) and '
132
- 'NDK API {req_ndk_api}, but a dist '
133
- 'with this name already exists and has either incompatible recipes '
134
- '({dist_recipes}) or NDK API {dist_ndk_api}' .format (
139
+ '\n \t Asked for dist with name {name} and:'
140
+ '\n \t -> recipes: ({req_recipes})'
141
+ '\n \t -> NDK api: ({req_ndk_api})'
142
+ '\n \t -> android api ({req_android_api})'
143
+ '\n \t -> archs ({req_archs})'
144
+ '\n ...but a dist with this name already exists and has either '
145
+ 'incompatible:'
146
+ '\n \t -> recipes: ({dist_recipes})'
147
+ '\n \t -> NDK api: ({dist_ndk_api})'
148
+ '\n \t -> android api ({dist_android_api})'
149
+ '\n \t -> archs ({dist_archs})' .format (
135
150
name = name ,
151
+ req_recipes = ', ' .join (recipes ),
136
152
req_ndk_api = ctx .ndk_api ,
153
+ req_android_api = ctx .android_api ,
154
+ req_archs = ', ' .join (req_archs ),
155
+ dist_recipes = ', ' .join (name_match_dist .recipes ),
137
156
dist_ndk_api = name_match_dist .ndk_api ,
138
- req_recipes = ', ' .join (recipes ),
139
- dist_recipes = ', ' .join (name_match_dist .recipes )))
157
+ dist_android_api = name_match_dist .android_api ,
158
+ dist_archs = ', ' .join (name_match_dist .archs ),
159
+ )
160
+ )
140
161
141
- # If we got this far, we need to build a new dist
162
+ # 4) If we got this far, we need to build a new dist
142
163
dist = Distribution (ctx )
143
164
dist .needs_build = True
144
165
@@ -152,7 +173,9 @@ def get_distribution(cls, ctx, name=None, recipes=[],
152
173
dist .name = name
153
174
dist .dist_dir = join (ctx .dist_dir , dist .name )
154
175
dist .recipes = recipes
176
+ dist .archs = req_archs
155
177
dist .ndk_api = ctx .ndk_api
178
+ dist .android_api = ctx .android_api
156
179
157
180
return dist
158
181
@@ -184,20 +207,18 @@ def get_distributions(cls, ctx, extra_dist_dirs=[]):
184
207
dist .dist_dir = folder
185
208
dist .needs_build = False
186
209
dist .recipes = dist_info ['recipes' ]
187
- if 'archs' in dist_info :
188
- dist .archs = dist_info ['archs' ]
189
- if 'ndk_api' in dist_info :
190
- dist .ndk_api = dist_info ['ndk_api' ]
191
- else :
192
- dist .ndk_api = None
193
- warning (
194
- "Distribution {distname}: ({distdir}) has been "
195
- "built with an unknown api target, ignoring it, "
196
- "you might want to delete it" .format (
197
- distname = dist .name ,
198
- distdir = dist .dist_dir
210
+ for entry in {'archs' , 'ndk_api' , 'android_api' }:
211
+ setattr (dist , entry , dist_info .get (entry , None ))
212
+ if entry not in dist_info :
213
+ warning (
214
+ "Distribution {distname}: ({distdir}) has been "
215
+ "built with an unknown {entry}, ignoring it, "
216
+ "you might want to delete it" .format (
217
+ distname = dist .name ,
218
+ distdir = dist .dist_dir ,
219
+ entry = entry ,
220
+ )
199
221
)
200
- )
201
222
dists .append (dist )
202
223
return dists
203
224
0 commit comments