Skip to content

Commit c846efd

Browse files
authored
Merge pull request #1592 from opacam/fix-pygame-components
Allow patching from any folder + fix pygame components issues
2 parents d22246d + 0417e5a commit c846efd

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
@@ -179,14 +179,18 @@ def report_hook(index, blksize, size):
179179
shprint(sh.git, 'submodule', 'update', '--recursive')
180180
return target
181181

182-
def apply_patch(self, filename, arch):
182+
def apply_patch(self, filename, arch, build_dir=None):
183183
"""
184184
Apply a patch from the current recipe directory into the current
185185
build directory.
186+
187+
.. versionchanged:: 0.6.0
188+
Add ability to apply patch from any dir via kwarg `build_dir`'''
186189
"""
187190
info("Applying patch {}".format(filename))
191+
build_dir = build_dir if build_dir else self.get_build_dir(arch)
188192
filename = join(self.get_recipe_dir(), filename)
189-
shprint(sh.patch, "-t", "-d", self.get_build_dir(arch), "-p1",
193+
shprint(sh.patch, "-t", "-d", build_dir, "-p1",
190194
"-i", filename, _tail=10)
191195

192196
def copy_file(self, filename, dest):
@@ -441,8 +445,11 @@ def is_patched(self, arch):
441445
build_dir = self.get_build_dir(arch.arch)
442446
return exists(join(build_dir, '.patched'))
443447

444-
def apply_patches(self, arch):
445-
'''Apply any patches for the Recipe.'''
448+
def apply_patches(self, arch, build_dir=None):
449+
'''Apply any patches for the Recipe.
450+
451+
.. versionchanged:: 0.6.0
452+
Add ability to apply patches from any dir via kwarg `build_dir`'''
446453
if self.patches:
447454
info_main('Applying patches for {}[{}]'
448455
.format(self.name, arch.arch))
@@ -451,6 +458,7 @@ def apply_patches(self, arch):
451458
info_main('{} already patched, skipping'.format(self.name))
452459
return
453460

461+
build_dir = build_dir if build_dir else self.get_build_dir(arch.arch)
454462
for patch in self.patches:
455463
if isinstance(patch, (tuple, list)):
456464
patch, patch_check = patch
@@ -459,9 +467,9 @@ def apply_patches(self, arch):
459467

460468
self.apply_patch(
461469
patch.format(version=self.version, arch=arch.arch),
462-
arch.arch)
470+
arch.arch, build_dir=build_dir)
463471

464-
shprint(sh.touch, join(self.get_build_dir(arch.arch), '.patched'))
472+
shprint(sh.touch, join(build_dir, '.patched'))
465473

466474
def should_build(self, arch):
467475
'''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)