forked from kivy/python-for-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecipe_ctx.py
More file actions
54 lines (45 loc) · 1.85 KB
/
Copy pathrecipe_ctx.py
File metadata and controls
54 lines (45 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
from pythonforandroid.bootstrap import Bootstrap
from pythonforandroid.distribution import Distribution
from pythonforandroid.recipe import Recipe
from pythonforandroid.build import Context
from pythonforandroid.archs import ArchAarch_64
class RecipeCtx:
"""
An base class for unit testing a recipe. This will create a context so we
can test any recipe using this context. Implement `setUp` and `tearDown`
methods used by unit testing.
"""
ctx = None
arch = None
recipe = None
recipe_name = ""
"The name of the recipe to test."
recipes = []
"""A List of recipes to pass to `Distribution.get_distribution`. Should
contain the target recipe to test as well as a python recipe."""
recipe_build_order = []
"""A recipe_build_order which should take into account the recipe we want
to test as well as the possible dependent recipes"""
TEST_ARCH = 'arm64-v8a'
def setUp(self):
self.ctx = Context()
self.ctx.ndk_api = 21
self.ctx.android_api = 27
self.ctx._sdk_dir = "/opt/android/android-sdk"
self.ctx._ndk_dir = "/opt/android/android-ndk"
self.ctx.setup_dirs(os.getcwd())
self.ctx.bootstrap = Bootstrap().get_bootstrap("sdl2", self.ctx)
self.ctx.bootstrap.distribution = Distribution.get_distribution(
self.ctx, name="sdl2", recipes=self.recipes, arch_name=self.TEST_ARCH,
)
self.ctx.recipe_build_order = self.recipe_build_order
self.ctx.python_recipe = Recipe.get_recipe("python3", self.ctx)
self.arch = ArchAarch_64(self.ctx)
self.ctx.ndk_platform = (
f"{self.ctx._ndk_dir}/platforms/"
f"android-{self.ctx.ndk_api}/{self.arch.platform_dir}"
)
self.recipe = Recipe.get_recipe(self.recipe_name, self.ctx)
def tearDown(self):
self.ctx = None