2015-02-09 11:58:44 +01:00
|
|
|
from toolchain import Recipe, shprint
|
2015-02-09 23:34:02 +01:00
|
|
|
from os.path import join, exists
|
2015-02-09 11:58:44 +01:00
|
|
|
import sh
|
|
|
|
import os
|
|
|
|
import fnmatch
|
2015-02-09 23:34:02 +01:00
|
|
|
import shutil
|
2015-02-09 11:58:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
class KivyRecipe(Recipe):
|
2015-02-13 18:42:40 +01:00
|
|
|
version = "ios-poly-arch"
|
2015-02-09 11:58:44 +01:00
|
|
|
url = "https://github.com/kivy/kivy/archive/{version}.zip"
|
2015-02-09 23:34:02 +01:00
|
|
|
library = "libkivy.a"
|
2015-02-13 18:39:34 +01:00
|
|
|
depends = ["python", "sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios"]
|
2015-02-23 11:34:36 +01:00
|
|
|
pbx_frameworks = ["OpenGLES", "Accelerate"]
|
2015-02-09 11:58:44 +01:00
|
|
|
|
2015-02-09 23:34:02 +01:00
|
|
|
def get_kivy_env(self, arch):
|
2015-02-09 11:58:44 +01:00
|
|
|
build_env = arch.get_env()
|
|
|
|
build_env["KIVYIOSROOT"] = self.ctx.root_dir
|
|
|
|
build_env["IOSSDKROOT"] = arch.sysroot
|
2015-02-09 23:34:02 +01:00
|
|
|
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
|
|
|
|
build_env["ARM_LD"] = build_env["LD"]
|
|
|
|
build_env["ARCH"] = arch.arch
|
2015-02-13 18:39:34 +01:00
|
|
|
build_env["KIVY_SDL2_PATH"] = ":".join([
|
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2"),
|
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2_image"),
|
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2_ttf"),
|
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2_mixer")])
|
2015-02-09 23:34:02 +01:00
|
|
|
return build_env
|
|
|
|
|
|
|
|
def build_arch(self, arch):
|
|
|
|
self._patch_setup()
|
|
|
|
build_env = self.get_kivy_env(arch)
|
2015-02-09 11:58:44 +01:00
|
|
|
hostpython = sh.Command(self.ctx.hostpython)
|
|
|
|
# first try to generate .h
|
|
|
|
try:
|
|
|
|
shprint(hostpython, "setup.py", "build_ext", "-g",
|
|
|
|
_env=build_env)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
self.cythonize_build()
|
|
|
|
shprint(hostpython, "setup.py", "build_ext", "-g",
|
|
|
|
_env=build_env)
|
2015-02-09 23:34:02 +01:00
|
|
|
self.biglink()
|
|
|
|
|
|
|
|
def _patch_setup(self):
|
|
|
|
# patch setup to remove some functionnalities
|
|
|
|
pyconfig = join(self.build_dir, "setup.py")
|
|
|
|
def _remove_line(lines, pattern):
|
|
|
|
for line in lines[:]:
|
|
|
|
if pattern in line:
|
|
|
|
lines.remove(line)
|
|
|
|
with open(pyconfig) as fd:
|
|
|
|
lines = fd.readlines()
|
|
|
|
_remove_line(lines, "flags['libraries'] = ['GLESv2']")
|
2015-02-12 00:53:22 +01:00
|
|
|
#_remove_line(lines, "c_options['use_sdl'] = True")
|
2015-02-09 23:34:02 +01:00
|
|
|
with open(pyconfig, "wb") as fd:
|
|
|
|
fd.writelines(lines)
|
|
|
|
|
|
|
|
def install(self):
|
|
|
|
arch = list(self.filtered_archs)[0]
|
|
|
|
build_dir = self.get_build_dir(arch.arch)
|
|
|
|
os.chdir(build_dir)
|
|
|
|
hostpython = sh.Command(self.ctx.hostpython)
|
|
|
|
build_env = self.get_kivy_env(arch)
|
|
|
|
shprint(hostpython, "setup.py", "install", "-O2",
|
2015-02-11 12:53:19 +01:00
|
|
|
"--prefix", join(build_dir, "iosbuild"),
|
2015-02-09 23:34:02 +01:00
|
|
|
_env=build_env)
|
|
|
|
dest_dir = join(self.ctx.dist_dir, "root", "python", "lib", "python2.7",
|
|
|
|
"site-packages", "kivy")
|
|
|
|
if exists(dest_dir):
|
|
|
|
shutil.rmtree(dest_dir)
|
|
|
|
shutil.copytree(
|
2015-02-11 12:53:19 +01:00
|
|
|
join(build_dir, "iosbuild", "lib",
|
2015-02-09 23:34:02 +01:00
|
|
|
"python2.7", "site-packages", "kivy"),
|
|
|
|
dest_dir)
|
2015-02-09 11:58:44 +01:00
|
|
|
|
|
|
|
recipe = KivyRecipe()
|
|
|
|
|
|
|
|
|