@@ -64,8 +64,8 @@ def get_distribution(cls, ctx, name=None, recipes=[],
6464 ndk_api : int
6565 The NDK API to compile against, included in the dist because it cannot
6666 be changed later during APK packaging.
67- arch : Arch
68- The target architecture to compile against, included in the dist because
67+ arch_name : str
68+ The target architecture name to compile against, included in the dist because
6969 it cannot be changed later during APK packaging.
7070 recipes : list
7171 The recipes that the distribution must contain.
@@ -86,17 +86,24 @@ def get_distribution(cls, ctx, name=None, recipes=[],
8686
8787 existing_dists = Distribution .get_distributions (ctx )
8888
89- possible_dists = existing_dists
89+ possible_dists = existing_dists [:]
9090
91- name_match_dists = []
91+ # Will hold dists that would be built in the same folder as an existing dist
92+ folder_match_dist = None
9293
9394 # 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
9595 if name is not None and name :
9696 possible_dists = [
9797 d for d in possible_dists if
9898 (d .name == name ) and (arch_name in d .archs )]
9999
100+ # There should only be one folder with a given dist name *and* arch.
101+ # We could check that here, but for compatibility let's let it slide
102+ # and just record the details of one of them. We only use this data to
103+ # possibly fail the build later, so it doesn't really matter if there
104+ # was more than one clash.
105+ folder_match_dist = possible_dists [0 ]
106+
100107 # 1) Check if any existing dists meet the requirements
101108 _possible_dists = []
102109 for dist in possible_dists :
@@ -133,22 +140,22 @@ def get_distribution(cls, ctx, name=None, recipes=[],
133140 .format (dist .name ))
134141 return dist
135142
136- assert len (possible_dists ) < 2
137-
138143 # If there was a name match but we didn't already choose it,
139144 # then the existing dist is incompatible with the requested
140145 # configuration and the build cannot continue
141- if name_match_dists and not allow_replace_dist :
146+ if folder_match_dist is not None and not allow_replace_dist :
142147 raise BuildInterruptingException (
143148 'Asked for dist with name {name} with recipes ({req_recipes}) and '
144149 'NDK API {req_ndk_api}, but a dist '
145150 'with this name already exists and has either incompatible recipes '
146151 '({dist_recipes}) or NDK API {dist_ndk_api}' .format (
147152 name = name ,
148153 req_ndk_api = ndk_api ,
149- dist_ndk_api = name_match_dist .ndk_api ,
154+ dist_ndk_api = folder_match_dist .ndk_api ,
150155 req_recipes = ', ' .join (recipes ),
151- dist_recipes = ', ' .join (name_match_dist .recipes )))
156+ dist_recipes = ', ' .join (folder_match_dist .recipes )))
157+
158+ assert len (folder_match_dist ) < 2
152159
153160 # If we got this far, we need to build a new dist
154161 dist = Distribution (ctx )
@@ -170,7 +177,6 @@ def get_distribution(cls, ctx, name=None, recipes=[],
170177 dist .ndk_api = ctx .ndk_api
171178 dist .archs = [arch_name ]
172179
173-
174180 return dist
175181
176182 def folder_exists (self ):
0 commit comments