@@ -27,6 +27,10 @@ This documentation jumps straight to the practicalities of creating
2727your own recipe. The formal reference documentation of the Recipe
2828class can be found in the `Recipe class <recipe_class _>`_ section and below.
2929
30+ Check the `recipe template section <recipe_template _>`_ for a template
31+ that combines all of these ideas, in which you can replace whichever
32+ components you like.
33+
3034The basic declaration of a recipe is as follows::
3135
3236 class YourRecipe(Recipe):
@@ -343,6 +347,7 @@ similar mechanism to compile with the right environment.
343347This isn't documented yet because it will probably be changed so that
344348CythonRecipe inherits from it (to avoid code duplication).
345349
350+
346351Using an NDKRecipe
347352------------------
348353
@@ -374,6 +379,66 @@ what the jni dir folder name should be. If it is omitted, the recipe
374379name is used. Be careful here, sometimes the folder name is important,
375380especially if this folder is a dependency of something else.
376381
382+ .. _recipe_template :
383+
384+ A Recipe template
385+ -----------------
386+
387+ The following template includes all the recipe sections you might
388+ use. Note that none are compulsory, feel free to delete method
389+ overrides if you do not use them::
390+
391+ from toolchain import Recipe, shprint, current_directory
392+ from os.path import exists, join
393+ import sh
394+ import glob
395+
396+
397+ class YourRecipe(Recipe):
398+ # This could also inherit from PythonRecipe etc. if you want to
399+ # use their pre-written build processes
400+
401+ version = 'some_version_string'
402+ url = 'http://example.com/example-{version}.tar.gz'
403+
404+ depends = ['python2', 'numpy'] # A list of any other recipe names
405+ # that must be built before this
406+ # one
407+
408+ conflicts = [] # A list of any recipe names that cannot be built
409+ # alongside this one
410+
411+ def get_recipe_env(self, arch):
412+ env = super(YourRecipe, self).get_recipe_env()
413+ # Manipulate the env here if you want
414+ return env
415+
416+ def should_build(self):
417+ # Add a check for whether the recipe is already built if you
418+ # want, and return False if it is.
419+ return True
420+
421+ def prebuild_arch(self, arch):
422+ super(YourRecipe, self).prebuild_arch(self)
423+ # Do any extra prebuilding you want, e.g.:
424+ self.apply_patch('path/to/patch.patch')
425+
426+ def build_arch(self, arch):
427+ super(YourRecipe, self).build_arch(self)
428+ # Build the code. Make sure to use the right build dir, e.g.
429+ with current_directory(self.get_build_dir(arch.arch)):
430+ sh.ls('-lathr') # Or run some commands that actually do
431+ # something
432+
433+ def postbuild_arch(self, arch):
434+ super(YourRecipe, self).prebuild_arch(self)
435+ # Do anything you want after the build, e.g. deleting
436+ # unnecessary files such as documentation
437+
438+
439+ recipe = YourRecipe()
440+
441+
377442Examples of recipes
378443-------------------
379444
@@ -386,6 +451,8 @@ internal recipes folder. Unless your own module has some unusual
386451complication, following these templates should be all you need to make
387452your own recipes work.
388453
454+ TODO
455+
389456.. _recipe_class :
390457
391458The ``Recipe `` class
0 commit comments