@@ -1615,6 +1615,12 @@ class Recipe(object):
1615
1615
'''A list of optional dependencies, that must be built before this
1616
1616
recipe if they are built at all, but whose presence is not essential.'''
1617
1617
1618
+ patches = []
1619
+ '''A list of patches to apply to the source. Values can be either a string
1620
+ referring to the patch file relative to the recipe dir, or a tuple of the
1621
+ string patch file and a callable, which will receive the kwargs `arch` and
1622
+ `version`, which should return True if the patch should be applied.'''
1623
+
1618
1624
archs = ['armeabi' ] # Not currently implemented properly
1619
1625
1620
1626
@property
@@ -1981,6 +1987,27 @@ def prebuild_arch(self, arch):
1981
1987
else :
1982
1988
info ('{} has no {}, skipping' .format (self .name , prebuild ))
1983
1989
1990
+ def apply_patches (self , arch ):
1991
+ '''Apply any patches for the Recipe.'''
1992
+ if self .patches :
1993
+ info_main ('Applying patches for {}[{}]'
1994
+ .format (self .name , arch .arch ))
1995
+
1996
+ build_dir = self .get_build_dir (arch .arch )
1997
+ if exists (join (build_dir , '.patched' )):
1998
+ info_main ('{} already patched, skipping' .format (self .name ))
1999
+ return
2000
+
2001
+ for patch in self .patches :
2002
+ if isinstance (patch , (tuple , list )):
2003
+ patch , patch_check = patch
2004
+ if not patch_check (arch = arch , version = self .version ):
2005
+ continue
2006
+
2007
+ self .apply_patch (patch , arch .arch )
2008
+
2009
+ shprint (sh .touch , join (build_dir , '.patched' ))
2010
+
1984
2011
def should_build (self , arch ):
1985
2012
'''Should perform any necessary test and return True only if it needs
1986
2013
building again.
@@ -2309,6 +2336,7 @@ def build_recipes(build_order, python_modules, ctx):
2309
2336
for recipe in recipes :
2310
2337
info_main ('Prebuilding {} for {}' .format (recipe .name , arch .arch ))
2311
2338
recipe .prebuild_arch (arch )
2339
+ recipe .apply_patches (arch )
2312
2340
2313
2341
# 3) build packages
2314
2342
info_main ('# Building recipes' )
0 commit comments