-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy path__init__.py
72 lines (61 loc) · 2.43 KB
/
__init__.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import sh
from os.path import join, basename
from glob import glob
from multiprocessing import cpu_count
from pythonforandroid.recipe import PyProjectRecipe
from pythonforandroid.util import current_directory, ensure_dir
from pythonforandroid.logger import shprint
class Panda3dRecipe(PyProjectRecipe):
version = "1.10.14"
url = "https://github.com/panda3d/panda3d/archive/refs/tags/v{version}.tar.gz"
patches = ["makepanda.patch"]
def get_recipe_env(self, arch):
env = super().get_recipe_env(arch)
env["ANDROID_NDK_ROOT"] = self.ctx.ndk_dir
env["ANDROID_SDK_ROOT"] = self.ctx.sdk_dir
env["ANDROID_TARGET_API"] = str(self.ctx.android_api)
env["CXXFLAGS"] += " -stdlib=libstdc++ -Wno-unsupported-floating-point-opt"
env["CFLAGS"] += " -Wno-unsupported-floating-point-opt"
# Python includes
python_includes = self.ctx.python_recipe.include_root(arch.arch)
env["CXXFLAGS"] += " -I{}".format(python_includes)
env["CFLAGS"] += " -I{}".format(python_includes)
return env
def build_arch(self, arch):
self.install_hostpython_prerequisites()
build_dir = self.get_build_dir(arch)
env = self.get_recipe_env(arch)
outputdir = join(build_dir, "dist")
ensure_dir(outputdir)
# Used by makepanda
_arch = {
"armeabi-v7a": "armv7a",
"arm64-v8a": "aarch64",
"x86": "x86",
"x86_64": "x86_64",
}[arch.arch]
# Setup python lib folder
panda3d_lib_dir = join(build_dir, "thirdparty/android-libs-{}".format(_arch), "python", "lib")
ensure_dir(panda3d_lib_dir)
for lib in glob(join(self.ctx.python_recipe.link_root(arch.arch), "*.so")):
shprint(
sh.ln, "-sf", lib, join(panda3d_lib_dir, basename(lib))
)
with current_directory(build_dir):
shprint(
sh.Command(self.hostpython_location),
"makepanda/makepanda.py",
"--everything",
"--outputdir",
outputdir,
"--arch",
_arch,
"--target",
"android-{}".format(self.ctx.ndk_api),
"--threads",
str(cpu_count()),
"--wheel",
_env=env
)
self.install_wheel(arch, join(build_dir, "dist", "*.whl"))
recipe = Panda3dRecipe()