Skip to content

Commit d657f9e

Browse files
committed
[dist] Check p4a version when reusing dist
And in case that we detect a mismatch version we will force to delete all the previous build folders to start from scratch Note: In case that we want to export a created dist we will omit the removal, unless we need to rebuild the dist.
1 parent 0f09fbe commit d657f9e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

pythonforandroid/distribution.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Distribution(object):
2020

2121
name = None # A name identifying the dist. May not be None.
2222
needs_build = False # Whether the dist needs compiling
23+
needs_clean_build = False # Whether the build needs a full clean
2324
url = None
2425
dist_dir = None # Where the dist dir ultimately is. Should not be None.
2526
ndk_api = None
@@ -129,6 +130,11 @@ def get_distribution(cls, ctx, name=None, recipes=[],
129130
not require_perfect_match)):
130131
info_notify('{} has compatible recipes, using this one'
131132
.format(dist.name))
133+
if dist.p4a_version != __version__:
134+
# We build this dist with a different version of p4a, so
135+
# we mark it as a dist that requires a clean build environ
136+
# (to avoid old cached builds issues)
137+
dist.needs_clean_build = True
132138
return dist
133139

134140
assert len(possible_dists) < 2
@@ -209,7 +215,9 @@ def get_distributions(cls, ctx, extra_dist_dirs=[]):
209215
dist.dist_dir = folder
210216
dist.needs_build = False
211217
dist.recipes = dist_info['recipes']
212-
for entry in {'archs', 'ndk_api', 'android_api'}:
218+
for entry in {
219+
'archs', 'ndk_api', 'android_api', 'p4a_version'
220+
}:
213221
setattr(dist, entry, dist_info.get(entry, None))
214222
if entry not in dist_info:
215223
warning(

pythonforandroid/toolchain.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ def wrapper_func(self, args):
144144
user_android_api=self.android_api,
145145
user_ndk_api=self.ndk_api)
146146
dist = self._dist
147+
export_dist = func.__name__ == 'export_dist'
148+
if all([dist.needs_build, dist.needs_clean_build, not export_dist]):
149+
warning(
150+
'\n{separator}\n'
151+
'* Detected new p4a version: {new_version}\n'
152+
'* Selected dist was made using version: {dist_version}\n'
153+
'* So We will remove all cached builds, to ensure a '
154+
'successful build!!\n\n'
155+
'* Note: the downloaded packages will not be removed.\n'
156+
'{separator}'.format(
157+
separator='*' * 72,
158+
new_version=__version__,
159+
dist_version=dist.p4a_version
160+
)
161+
)
162+
self.clean_builds(args)
147163
if dist.needs_build:
148164
if dist.folder_exists(): # possible if the dist is being replaced
149165
dist.delete()

0 commit comments

Comments
 (0)