@@ -142,6 +142,8 @@ def wrapper_func(self, args):
142
142
user_ndk_api = self .ndk_api )
143
143
dist = self ._dist
144
144
if dist .needs_build :
145
+ if dist .folder_exists (): # possible if the dist is being replaced
146
+ dist .delete ()
145
147
info_notify ('No dist exists that meets your requirements, '
146
148
'so one will be built.' )
147
149
build_dist_from_args (ctx , dist , args )
@@ -158,7 +160,8 @@ def dist_from_args(ctx, args):
158
160
name = args .dist_name ,
159
161
ndk_api = args .ndk_api ,
160
162
recipes = split_argument_list (args .requirements ),
161
- require_perfect_match = args .require_perfect_match )
163
+ require_perfect_match = args .require_perfect_match ,
164
+ allow_replace_dist = args .allow_replace_dist )
162
165
163
166
164
167
def build_dist_from_args (ctx , dist , args ):
@@ -316,6 +319,12 @@ def __init__(self):
316
319
description = ('Whether the dist recipes must perfectly match '
317
320
'those requested' ))
318
321
322
+ add_boolean_option (
323
+ generic_parser , ["allow-replace-dist" ],
324
+ default = True ,
325
+ description = 'Whether existing dist names can be automatically replaced'
326
+ )
327
+
319
328
generic_parser .add_argument (
320
329
'--local-recipes' , '--local_recipes' ,
321
330
dest = 'local_recipes' , default = './p4a-recipes' ,
@@ -921,10 +930,11 @@ def distributions(self, _args):
921
930
922
931
def delete_dist (self , _args ):
923
932
dist = self ._dist
924
- if dist .needs_build :
933
+ if not dist .folder_exists () :
925
934
info ('No dist exists that matches your specifications, '
926
935
'exiting without deleting.' )
927
- shutil .rmtree (dist .dist_dir )
936
+ return
937
+ dist .delete ()
928
938
929
939
def sdk_tools (self , args ):
930
940
"""Runs the android binary from the detected SDK directory, passing
0 commit comments