Skip to content

Commit b50fc18

Browse files
committed
Allowed dists to be overwritten by default
1 parent acaa004 commit b50fc18

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pythonforandroid/toolchain.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def wrapper_func(self, args):
142142
user_ndk_api=self.ndk_api)
143143
dist = self._dist
144144
if dist.needs_build:
145+
if dist.folder_exists(): # possible if the dist is being replaced
146+
dist.delete()
145147
info_notify('No dist exists that meets your requirements, '
146148
'so one will be built.')
147149
build_dist_from_args(ctx, dist, args)
@@ -158,7 +160,8 @@ def dist_from_args(ctx, args):
158160
name=args.dist_name,
159161
ndk_api=args.ndk_api,
160162
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)
162165

163166

164167
def build_dist_from_args(ctx, dist, args):
@@ -316,6 +319,12 @@ def __init__(self):
316319
description=('Whether the dist recipes must perfectly match '
317320
'those requested'))
318321

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+
319328
generic_parser.add_argument(
320329
'--local-recipes', '--local_recipes',
321330
dest='local_recipes', default='./p4a-recipes',
@@ -921,10 +930,11 @@ def distributions(self, _args):
921930

922931
def delete_dist(self, _args):
923932
dist = self._dist
924-
if dist.needs_build:
933+
if not dist.folder_exists():
925934
info('No dist exists that matches your specifications, '
926935
'exiting without deleting.')
927-
shutil.rmtree(dist.dist_dir)
936+
return
937+
dist.delete()
928938

929939
def sdk_tools(self, args):
930940
"""Runs the android binary from the detected SDK directory, passing

0 commit comments

Comments
 (0)