2018-05-23 18:23:21 +02:00
|
|
|
"""
|
|
|
|
Author: Lawrence Du
|
|
|
|
E-mail: larrydu88@gmail.com
|
|
|
|
"""
|
|
|
|
|
|
|
|
from toolchain import CythonRecipe, shprint
|
|
|
|
import sh
|
2019-01-11 18:22:49 +01:00
|
|
|
from os.path import join
|
2020-04-25 18:28:16 +02:00
|
|
|
from os import chdir
|
2019-02-07 10:00:23 +01:00
|
|
|
import logging
|
2018-05-23 18:23:21 +02:00
|
|
|
|
2019-02-07 10:00:23 +01:00
|
|
|
logger = logging.getLogger(__name__)
|
2018-05-23 18:23:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
class KiventCoreRecipe(CythonRecipe):
|
|
|
|
version = 'master'
|
|
|
|
url = 'https://github.com/kivy/kivent/archive/{version}.zip'
|
|
|
|
name = 'kivent_core'
|
2020-04-25 18:28:16 +02:00
|
|
|
depends = ['libffi', 'kivy'] # note: unsure if libffi is necessary here
|
|
|
|
pre_build_ext = False
|
2018-05-23 18:23:21 +02:00
|
|
|
subbuilddir = False
|
|
|
|
cythonize = True
|
2020-04-25 18:28:16 +02:00
|
|
|
pbx_frameworks = ["OpenGLES"] # note: This line may be unnecessary
|
2019-01-11 18:22:49 +01:00
|
|
|
|
2018-05-23 18:23:21 +02:00
|
|
|
def get_recipe_env(self, arch):
|
2020-04-25 18:28:16 +02:00
|
|
|
env = super(KiventCoreRecipe, self).get_recipe_env(arch)
|
2018-05-23 18:23:21 +02:00
|
|
|
env['CYTHONPATH'] = self.get_recipe(
|
|
|
|
'kivy', self.ctx).get_build_dir(arch.arch)
|
|
|
|
return env
|
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
def get_build_dir(self, arch, sub=False):
|
2018-05-23 18:23:21 +02:00
|
|
|
"""
|
2019-01-11 18:22:49 +01:00
|
|
|
Call this to get the correct build_dir, where setup.py is located which is
|
2018-05-23 18:23:21 +02:00
|
|
|
actually under modules/core/setup.py
|
|
|
|
"""
|
|
|
|
builddir = super(KiventCoreRecipe, self).get_build_dir(str(arch))
|
|
|
|
if sub or self.subbuilddir:
|
2020-04-25 18:28:16 +02:00
|
|
|
core_build_dir = join(builddir, 'modules', 'core')
|
2019-02-07 10:00:23 +01:00
|
|
|
logger.info("Core build directory is located at {}".format(core_build_dir))
|
2018-05-23 18:23:21 +02:00
|
|
|
return core_build_dir
|
|
|
|
else:
|
2019-02-07 10:00:23 +01:00
|
|
|
logger.info("Building in {}".format(builddir))
|
2018-05-23 18:23:21 +02:00
|
|
|
return builddir
|
|
|
|
|
|
|
|
def build_arch(self, arch):
|
|
|
|
"""
|
2019-01-11 18:22:49 +01:00
|
|
|
Override build.arch to avoid calling setup.py here (Call it in
|
2018-05-23 18:23:21 +02:00
|
|
|
install() instead).
|
|
|
|
"""
|
|
|
|
self.subbuildir = True
|
|
|
|
self.cythonize_build()
|
|
|
|
self.biglink()
|
2020-04-25 18:28:16 +02:00
|
|
|
self.subbuilddir = False
|
2019-01-11 18:22:49 +01:00
|
|
|
|
2018-05-23 18:23:21 +02:00
|
|
|
def install(self):
|
|
|
|
"""
|
2019-01-11 18:22:49 +01:00
|
|
|
This method simply builds the command line call for calling
|
2018-05-23 18:23:21 +02:00
|
|
|
kivent_core/modules/core/setup.py
|
2019-01-11 18:22:49 +01:00
|
|
|
|
2018-05-23 18:23:21 +02:00
|
|
|
This constructs the equivalent of the command
|
|
|
|
"$python2.7 setup.py build_ext install"
|
|
|
|
only with the environment variables altered for each different architecture
|
|
|
|
The appropriate version of kivy also needs to be added to the path, and this
|
|
|
|
differs for each architecture (i386, x86_64, armv7, etc)
|
|
|
|
|
|
|
|
Note: This method is called by build_all() in toolchain.py
|
|
|
|
|
|
|
|
"""
|
|
|
|
arch = list(self.filtered_archs)[0]
|
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
build_dir = self.get_build_dir(arch.arch, sub=True)
|
|
|
|
logger.info("Building kivent_core {} in {}".format(arch.arch, build_dir))
|
2018-05-23 18:23:21 +02:00
|
|
|
chdir(build_dir)
|
|
|
|
hostpython = sh.Command(self.ctx.hostpython)
|
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
# Get the appropriate environment for this recipe (including CYTHONPATH)
|
|
|
|
# build_env = arch.get_env()
|
2018-05-23 18:23:21 +02:00
|
|
|
build_env = self.get_recipe_env(arch)
|
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
dest_dir = join(self.ctx.dist_dir, "root", "python")
|
2018-05-23 18:23:21 +02:00
|
|
|
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
|
2019-01-11 18:22:49 +01:00
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
# Add Architecture specific kivy path for 'import kivy' to PYTHONPATH
|
2018-05-23 18:23:21 +02:00
|
|
|
arch_kivy_path = self.get_recipe('kivy', self.ctx).get_build_dir(arch.arch)
|
2020-04-25 18:28:16 +02:00
|
|
|
build_env['PYTHONPATH'] = join(build_env['PYTHONPATH'], ':', arch_kivy_path)
|
2018-05-23 18:23:21 +02:00
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
# Make sure you call kivent_core/modules/core/setup.py
|
|
|
|
subdir_path = self.get_build_dir(str(arch), sub=True)
|
|
|
|
setup_path = join(subdir_path, "setup.py")
|
2018-05-23 18:23:21 +02:00
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
# Print out directories for sanity check
|
2019-02-07 10:00:23 +01:00
|
|
|
logger.info("ENVS", build_env)
|
2020-04-25 18:28:16 +02:00
|
|
|
logger.info("ROOT", self.ctx.root_dir)
|
|
|
|
logger.info("BUILD", self.ctx.build_dir)
|
2019-02-07 10:00:23 +01:00
|
|
|
logger.info("INCLUDE", self.ctx.include_dir)
|
|
|
|
logger.info("DISTDIR", self.ctx.dist_dir)
|
2020-04-25 18:28:16 +02:00
|
|
|
logger.info("ARCH KIVY LOC", self.get_recipe('kivy', self.ctx).get_build_dir(arch.arch))
|
2019-01-11 18:22:49 +01:00
|
|
|
|
2018-05-23 18:23:21 +02:00
|
|
|
shprint(hostpython, setup_path, "build_ext", "install", _env=build_env)
|
2019-01-11 18:22:49 +01:00
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
|
2018-05-23 18:23:21 +02:00
|
|
|
recipe = KiventCoreRecipe()
|