Skip to content

Commit 07b61c5

Browse files
committed
toolchain: improved functions to apply recipe patches
1 parent e800908 commit 07b61c5

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

pythonforandroid/toolchain.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,15 +1564,30 @@ def extract_source(self, source, cwd):
15641564
# print("Unrecognized extension for {}".format(filename))
15651565
# raise Exception()
15661566

1567-
def apply_patch(self, filename):
1567+
def apply_patch(self, filename, arch='armeabi'):
15681568
"""
15691569
Apply a patch from the current recipe directory into the current
15701570
build directory.
15711571
"""
15721572
info("Applying patch {}".format(filename))
15731573
filename = join(self.recipe_dir, filename)
1574-
# AND: get_build_dir shouldn't need to hardcode armeabi
1575-
sh.patch("-t", "-d", self.get_build_dir('armeabi'), "-p1", "-i", filename)
1574+
shprint(sh.patch, "-t", "-d", self.get_build_dir(arch), "-p1",
1575+
"-i", filename, _tail=10)
1576+
1577+
def apply_all_patches(self, wildcard=join('patches','*.patch'), arch='armeabi'):
1578+
patches = glob.glob(join(self.recipe_dir, wildcard))
1579+
if not patches:
1580+
warning('requested patches {} not found for {}'.format(wildcard, self.name))
1581+
for filename in sorted(patches):
1582+
name = splitext(basename(filename))[0]
1583+
patched_flag = join(self.get_build_container_dir(arch), name + '.patched')
1584+
if exists(patched_flag):
1585+
info('patch {} already applied to {}, skipping'.format(name, self.name))
1586+
else:
1587+
self.apply_patch(filename, arch=arch)
1588+
sh.touch(patched_flag)
1589+
return len(patches)
1590+
15761591

15771592
def copy_file(self, filename, dest):
15781593
info("Copy {} to {}".format(filename, dest))

0 commit comments

Comments
 (0)