python/kivy: correctly install both of them into the dist/root
This commit is contained in:
parent
6592e69f52
commit
456259f912
4 changed files with 71 additions and 10 deletions
|
@ -1,14 +1,15 @@
|
|||
from toolchain import Recipe, shprint
|
||||
from os.path import join
|
||||
from os.path import join, exists
|
||||
import sh
|
||||
import os
|
||||
import fnmatch
|
||||
import shutil
|
||||
|
||||
|
||||
class KivyRecipe(Recipe):
|
||||
version = "master"
|
||||
url = "https://github.com/kivy/kivy/archive/{version}.zip"
|
||||
#library = "Xcode-iOS/build/Release-{arch.sdk}/libSDL2_image.a"
|
||||
library = "libkivy.a"
|
||||
#include_dir = "SDL_image.h"
|
||||
depends = ["python", "sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf"]
|
||||
|
||||
|
@ -25,10 +26,18 @@ class KivyRecipe(Recipe):
|
|||
for filename in fnmatch.filter(filenames, "*.pyx"):
|
||||
self.cythonize(join(root, filename))
|
||||
|
||||
def build_arch(self, arch):
|
||||
def get_kivy_env(self, arch):
|
||||
build_env = arch.get_env()
|
||||
build_env["KIVYIOSROOT"] = self.ctx.root_dir
|
||||
build_env["IOSSDKROOT"] = arch.sysroot
|
||||
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
|
||||
build_env["ARM_LD"] = build_env["LD"]
|
||||
build_env["ARCH"] = arch.arch
|
||||
return build_env
|
||||
|
||||
def build_arch(self, arch):
|
||||
self._patch_setup()
|
||||
build_env = self.get_kivy_env(arch)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
# first try to generate .h
|
||||
try:
|
||||
|
@ -39,9 +48,47 @@ class KivyRecipe(Recipe):
|
|||
self.cythonize_build()
|
||||
shprint(hostpython, "setup.py", "build_ext", "-g",
|
||||
_env=build_env)
|
||||
import sys
|
||||
sys.exit(0)
|
||||
self.biglink()
|
||||
|
||||
def biglink(self):
|
||||
dirs = []
|
||||
for root, dirnames, filenames in os.walk(self.build_dir):
|
||||
if fnmatch.filter(filenames, "*.so.libs"):
|
||||
dirs.append(root)
|
||||
cmd = sh.Command(join(self.ctx.root_dir, "tools", "biglink"))
|
||||
shprint(cmd, join(self.build_dir, "libkivy.a"), *dirs)
|
||||
|
||||
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']")
|
||||
_remove_line(lines, "c_options['use_sdl'] = True")
|
||||
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",
|
||||
"--root", join(build_dir, "iosbuild"),
|
||||
_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(
|
||||
join(build_dir, "iosbuild", "usr", "local", "lib",
|
||||
"python2.7", "site-packages", "kivy"),
|
||||
dest_dir)
|
||||
|
||||
recipe = KivyRecipe()
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from toolchain import Recipe, shprint
|
||||
from os.path import join
|
||||
import sh
|
||||
import os
|
||||
|
||||
|
||||
class PythonRecipe(Recipe):
|
||||
|
@ -47,6 +48,19 @@ class PythonRecipe(Recipe):
|
|||
"HOSTPYTHON={}".format(self.ctx.hostpython),
|
||||
"HOSTPGEN={}".format(self.ctx.hostpgen))
|
||||
|
||||
def install(self):
|
||||
arch = list(self.filtered_archs)[0]
|
||||
build_env = arch.get_env()
|
||||
build_dir = self.get_build_dir(arch.arch)
|
||||
build_env["PATH"] = os.environ["PATH"]
|
||||
shprint(sh.make,
|
||||
"-C", build_dir,
|
||||
"install",
|
||||
"CROSS_COMPILE_TARGET=yes",
|
||||
"HOSTPYTHON={}".format(self.ctx.hostpython),
|
||||
"prefix={}".format(join(self.ctx.dist_dir, "root", "python")),
|
||||
_env=build_env)
|
||||
|
||||
def _patch_pyconfig(self):
|
||||
# patch pyconfig to remove some functionnalities
|
||||
# (to have uniform build accross all platfors)
|
||||
|
|
|
@ -69,7 +69,7 @@ class Arch(object):
|
|||
env["CFLAGS"] = " ".join([
|
||||
"-arch", self.arch,
|
||||
"-pipe", "-no-cpp-precomp",
|
||||
"--sysroot={}".format(self.sysroot),
|
||||
"--sysroot", self.sysroot,
|
||||
#"-I{}/common".format(self.ctx.include_dir),
|
||||
#"-I{}/{}".format(self.ctx.include_dir, self.arch),
|
||||
"-O3",
|
||||
|
@ -77,7 +77,7 @@ class Arch(object):
|
|||
] + include_dirs)
|
||||
env["LDFLAGS"] = " ".join([
|
||||
"-arch", self.arch,
|
||||
"--sysroot={}".format(self.sysroot),
|
||||
"--sysroot", self.sysroot,
|
||||
"-L{}/{}".format(self.ctx.dist_dir, "lib"),
|
||||
"-lsqlite3",
|
||||
"-undefined", "dynamic_lookup",
|
||||
|
|
|
@ -74,6 +74,6 @@ f.write(" ".join(libs))
|
|||
f.close()
|
||||
|
||||
print('Liblink redirect linking with', objects)
|
||||
subprocess.call([
|
||||
environ.get('ARM_LD'), '-r',
|
||||
'-o', output + '.o', '-arch', 'armv7'] + objects)
|
||||
ld = environ.get('ARM_LD')
|
||||
arch = environ.get('ARCH', 'armv7')
|
||||
subprocess.call([ld, '-r', '-o', output + '.o', '-arch', arch] + objects)
|
||||
|
|
Loading…
Add table
Reference in a new issue