@@ -38,6 +38,8 @@ The basic declaration of a recipe is as follows::
38
38
url = 'http://example.com/example-{version}.tar.gz'
39
39
version = '2.0.3'
40
40
md5sum = '4f3dc9a9d857734a488bcbefd9cd64ed'
41
+
42
+ patches = ['some_fix.patch'] # Paths relative to the recipe dir
41
43
42
44
depends = ['kivy', 'sdl2'] # These are just examples
43
45
conflicts = ['pygame']
@@ -118,26 +120,35 @@ Methods and tools to help with compilation
118
120
Patching modules before installation
119
121
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120
122
121
- You can easily apply patches to your recipes with the ``apply_patch ``
122
- method. For instance, you could do this in your prebuild method::
123
-
124
- import sh
125
- def prebuild_arch(self, arch):
126
- super(YourRecipe, self).prebuild_arch(arch)
127
- build_dir = self.get_build_dir(arch.arch)
128
- if exists(join(build_dir, '.patched')):
129
- print('Your recipe is already patched, skipping')
130
- return
131
- self.apply_patch('some_patch.patch')
132
- shprint(sh.touch, join(build_dir, '.patched'))
133
-
134
- The path to the patch should be in relation to your recipe code.
135
- In this case, ``some_path.patch `` must be in the same directory as the
136
- recipe.
137
-
138
- This code also manually takes care to patch only once. You can use the
139
- same strategy yourself, though a more generic solution may be provided
140
- in the future.
123
+ You can easily apply patches to your recipes by adding them to the
124
+ ``patches `` declaration, e.g.::
125
+
126
+ patches = ['some_fix.patch',
127
+ 'another_fix.patch']
128
+
129
+ The paths should be relative to the recipe file. Patches are
130
+ automatically applied just once (i.e. not reapplied the second time
131
+ python-for-android is run).
132
+
133
+ You can also use the helper functions in ``pythonforandroid.patching ``
134
A800
+ to apply patches depending on certain conditions, e.g.::
135
+
136
+ from pythonforandroid.patching import will_build, is_arch
137
+
138
+ ...
139
+
140
+ class YourRecipe(Recipe):
141
+
142
+ patches = [('x86_patch.patch', is_arch('x86')),
143
+ ('sdl2_compatibility.patch', will_build('sdl2'))]
144
+
145
+ ...
146
+
147
+ You can include your own conditions by passing any function as the
148
+ second entry of the tuple. It will receive the ``arch `` (e.g. x86,
149
+ armeabi) and ``recipe `` (i.e. the Recipe object) as kwargs. The patch
150
+ will be applied only if the function returns True.
151
+
141
152
142
153
Installing libs
143
154
~~~~~~~~~~~~~~~
0 commit comments