Skip to content

Commit 0417e5a

Browse files
committed
Allow patching from any folder + fix pygame components issues
This is needed to properly apply the patches for the pygame bootstrap components recipe, because we must apply the patches from build_container_dir and the current patching method only allow us to do that from the build directory (which not exists in pygame components because we delete it). Also fix a typo error for pygame components.
1 parent f36d340 commit 0417e5a

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

pythonforandroid/recipe.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,18 @@ def report_hook(index, blksize, size):
166166
shprint(sh.git, 'submodule', 'update', '--recursive')
167167
return target
168168

169-
def apply_patch(self, filename, arch):
169+
def apply_patch(self, filename, arch, build_dir=None):
170170
"""
171171
Apply a patch from the current recipe directory into the current
172172
build directory.
173+
174+
.. versionchanged:: 0.6.0
175+
Add ability to apply patch from any dir via kwarg `build_dir`'''
173176
"""
174177
info("Applying patch {}".format(filename))
178+
build_dir = build_dir if build_dir else self.get_build_dir(arch)
175179
filename = join(self.get_recipe_dir(), filename)
176-
shprint(sh.patch, "-t", "-d", self.get_build_dir(arch), "-p1",
180+
shprint(sh.patch, "-t", "-d", build_dir, "-p1",
177181
"-i", filename, _tail=10)
178182

179183
def copy_file(self, filename, dest):
@@ -428,8 +432,11 @@ def is_patched(self, arch):
428432
build_dir = self.get_build_dir(arch.arch)
429433
return exists(join(build_dir, '.patched'))
430434

431-
def apply_patches(self, arch):
432-
'''Apply any patches for the Recipe.'''
435+
def apply_patches(self, arch, build_dir=None):
436+
'''Apply any patches for the Recipe.
437+
438+
.. versionchanged:: 0.6.0
439+
Add ability to apply patches from any dir via kwarg `build_dir`'''
433440
if self.patches:
434441
info_main('Applying patches for {}[{}]'
435442
.format(self.name, arch.arch))
@@ -438,6 +445,7 @@ def apply_patches(self, arch):
438445
info_main('{} already patched, skipping'.format(self.name))
439446
return
440447

448+
build_dir = build_dir if build_dir else self.get_build_dir(arch.arch)
441449
for patch in self.patches:
442450
if isinstance(patch, (tuple, list)):
443451
patch, patch_check = patch
@@ -446,9 +454,9 @@ def apply_patches(self, arch):
446454

447455
self.apply_patch(
448456
patch.format(version=self.version, arch=arch.arch),
449-
arch.arch)
457+
arch.arch, build_dir=build_dir)
450458

451-
shprint(sh.touch, join(self.get_build_dir(arch.arch), '.patched'))
459+
shprint(sh.touch, join(build_dir, '.patched'))
452460

453461
def should_build(self, arch):
454462
'''Should perform any necessary test and return True only if it needs

pythonforandroid/recipes/pygame_bootstrap_components/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ class PygameJNIComponentsRecipe(BootstrapNDKRecipe):
99
version = 'master'
1010
url = 'https://github.com/kivy/p4a-pygame-bootstrap-components/archive/{version}.zip'
1111
dir_name = 'bootstrap_components'
12+
patches = ['jpeg-ndk15-plus.patch']
1213

1314
def prebuild_arch(self, arch):
14-
super(PygameJNIComponentsRecipe, self).postbuild_arch(arch)
15+
super(PygameJNIComponentsRecipe, self).prebuild_arch(arch)
1516

1617
info('Unpacking pygame bootstrap JNI dir components')
1718
with current_directory(self.get_build_container_dir(arch)):
@@ -25,11 +26,9 @@ def prebuild_arch(self, arch):
2526
info('Unpacking was successful, deleting original container dir')
2627
shprint(sh.rm, '-rf', self.get_build_dir(arch))
2728

28-
info('Applying jpeg assembler patch')
29-
ndk_15_plus_patch = join(self.get_recipe_dir(), 'jpeg-ndk15-plus.patch')
30-
shprint(sh.patch, '-t', '-d',
31-
join(self.get_build_container_dir(arch), 'jpeg'), '-p1',
32-
'-i', ndk_15_plus_patch, _tail=10)
29+
def apply_patches(self, arch, build_dir=None):
30+
super(PygameJNIComponentsRecipe, self).apply_patches(
31+
arch, build_dir=self.get_build_container_dir(arch.arch))
3332

3433

3534
recipe = PygameJNIComponentsRecipe()

pythonforandroid/recipes/pygame_bootstrap_components/jpeg-ndk15-plus.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ The distributed jpeg has troubles to be build with newer ndks, starting from
22
the introduction of the `unified headers` (ndk > 15). This patch allow us to
33
build the distributed `external jpeg` in sdl package, got the solution in here:
44
https://github.com/oNaiPs/droidVncServer/issues/53
5-
--- jpeg/Android.mk.orig 2015-06-21 15:14:54.000000000 +0200
6-
+++ jpeg/Android.mk 2019-01-14 10:57:06.384806168 +0100
5+
--- jni/jpeg/Android.mk.orig 2015-06-21 15:14:54.000000000 +0200
6+
+++ jni/jpeg/Android.mk 2019-01-14 10:57:06.384806168 +0100
77
@@ -20,7 +20,7 @@
88
endif
99

@@ -13,8 +13,8 @@ https://github.com/oNaiPs/droidVncServer/issues/53
1313

1414
ifeq ($(strip $(ANDROID_JPEG_NO_ASSEMBLER)),true)
1515
LOCAL_SRC_FILES += jidctint.c jidctfst.c
16-
--- jpeg/jidctfst.S.orig 2019-01-14 11:00:38.000000000 +0100
17-
+++ jpeg/jidctfst.S 2019-01-14 11:00:56.844803970 +0100
16+
--- jni/jpeg/jidctfst.S.orig 2019-01-14 11:00:38.000000000 +0100
17+
+++ jni/jpeg/jidctfst.S 2019-01-14 11:00:56.844803970 +0100
1818
@@ -63,7 +63,7 @@
1919

2020

0 commit comments

Comments
 (0)