From 6238831a83812a243ffe4941d529aa7f49028e8b Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Mon, 23 Feb 2015 22:51:16 +0100 Subject: [PATCH] toolchain: factorize cythonize_build, cythonize and big link --- recipes/ffpyplayer/__init__.py | 21 --------------------- recipes/ios/__init__.py | 21 --------------------- recipes/kivy/__init__.py | 21 --------------------- recipes/pyobjus/__init__.py | 21 --------------------- toolchain.py | 24 +++++++++++++++++++++++- 5 files changed, 23 insertions(+), 85 deletions(-) diff --git a/recipes/ffpyplayer/__init__.py b/recipes/ffpyplayer/__init__.py index cee285d..ecfe9dd 100644 --- a/recipes/ffpyplayer/__init__.py +++ b/recipes/ffpyplayer/__init__.py @@ -16,19 +16,6 @@ class FFPyplayerRecipe(Recipe): "CoreMotion"] pbx_libraries = ["libiconv"] - def cythonize(self, filename): - if filename.startswith(self.build_dir): - filename = filename[len(self.build_dir) + 1:] - print("Cythonize {}".format(filename)) - cmd = sh.Command(join(self.ctx.root_dir, "tools", "cythonize.py")) - shprint(cmd, filename) - - def cythonize_build(self): - root_dir = self.build_dir - for root, dirnames, filenames in os.walk(root_dir): - for filename in fnmatch.filter(filenames, "*.pyx"): - self.cythonize(join(root, filename)) - def get_kivy_env(self, arch): build_env = arch.get_env() build_env["KIVYIOSROOT"] = self.ctx.root_dir @@ -59,14 +46,6 @@ class FFPyplayerRecipe(Recipe): _env=build_env) 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, "libffpyplayer.a"), *dirs) - def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) diff --git a/recipes/ios/__init__.py b/recipes/ios/__init__.py index d7ae8b7..54ff9b8 100644 --- a/recipes/ios/__init__.py +++ b/recipes/ios/__init__.py @@ -13,19 +13,6 @@ class IosRecipe(Recipe): depends = ["python"] pbx_frameworks = ["MessageUI", "CoreMotion", "UIKit"] - def cythonize(self, filename): - if filename.startswith(self.build_dir): - filename = filename[len(self.build_dir) + 1:] - print("Cythonize {}".format(filename)) - cmd = sh.Command(join(self.ctx.root_dir, "tools", "cythonize.py")) - shprint(cmd, filename) - - def cythonize_build(self): - root_dir = self.build_dir - for root, dirnames, filenames in os.walk(root_dir): - for filename in fnmatch.filter(filenames, "*.pyx"): - self.cythonize(join(root, filename)) - def get_kivy_env(self, arch): build_env = arch.get_env() build_env["KIVYIOSROOT"] = self.ctx.root_dir @@ -43,14 +30,6 @@ class IosRecipe(Recipe): _env=build_env) 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, "libios.a"), *dirs) - def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) diff --git a/recipes/kivy/__init__.py b/recipes/kivy/__init__.py index 88558f9..9f301a6 100644 --- a/recipes/kivy/__init__.py +++ b/recipes/kivy/__init__.py @@ -13,19 +13,6 @@ class KivyRecipe(Recipe): depends = ["python", "sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios"] pbx_frameworks = ["OpenGLES", "Accelerate"] - def cythonize(self, filename): - if filename.startswith(self.build_dir): - filename = filename[len(self.build_dir) + 1:] - print("Cythonize {}".format(filename)) - cmd = sh.Command(join(self.ctx.root_dir, "tools", "cythonize.py")) - shprint(cmd, filename) - - def cythonize_build(self): - root_dir = join(self.build_dir, "kivy") - for root, dirnames, filenames in os.walk(root_dir): - for filename in fnmatch.filter(filenames, "*.pyx"): - self.cythonize(join(root, filename)) - def get_kivy_env(self, arch): build_env = arch.get_env() build_env["KIVYIOSROOT"] = self.ctx.root_dir @@ -55,14 +42,6 @@ class KivyRecipe(Recipe): _env=build_env) 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") diff --git a/recipes/pyobjus/__init__.py b/recipes/pyobjus/__init__.py index edd8708..ab3d8ca 100644 --- a/recipes/pyobjus/__init__.py +++ b/recipes/pyobjus/__init__.py @@ -12,19 +12,6 @@ class PyobjusRecipe(Recipe): library = "libpyobjus.a" depends = ["python"] - def cythonize(self, filename): - if filename.startswith(self.build_dir): - filename = filename[len(self.build_dir) + 1:] - print("Cythonize {}".format(filename)) - cmd = sh.Command(join(self.ctx.root_dir, "tools", "cythonize.py")) - shprint(cmd, filename) - - def cythonize_build(self): - root_dir = self.build_dir - for root, dirnames, filenames in os.walk(root_dir): - for filename in fnmatch.filter(filenames, "*.pyx"): - self.cythonize(join(root, filename)) - def get_kivy_env(self, arch): build_env = arch.get_env() build_env["KIVYIOSROOT"] = self.ctx.root_dir @@ -54,14 +41,6 @@ class PyobjusRecipe(Recipe): _env=build_env) 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, "libpyobjus.a"), *dirs) - def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) diff --git a/toolchain.py b/toolchain.py index 94a7ba4..14d9c55 100755 --- a/toolchain.py +++ b/toolchain.py @@ -9,13 +9,14 @@ This tool intend to replace all the previous tools/ in shell script. import sys from sys import stdout from os.path import join, dirname, realpath, exists, isdir, basename -from os import listdir, unlink, makedirs, environ, chdir, getcwd +from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk import zipfile import tarfile import importlib import io import json import shutil +import fnmatch from datetime import datetime try: from urllib.request import FancyURLopener @@ -505,6 +506,27 @@ class Recipe(object): def get_build_dir(self, arch): return join(self.ctx.build_dir, self.name, arch, self.archive_root) + def cythonize(self, filename): + if filename.startswith(self.build_dir): + filename = filename[len(self.build_dir) + 1:] + print("Cythonize {}".format(filename)) + cmd = sh.Command(join(self.ctx.root_dir, "tools", "cythonize.py")) + shprint(cmd, filename) + + def cythonize_build(self): + root_dir = self.build_dir + for root, dirnames, filenames in walk(root_dir): + for filename in fnmatch.filter(filenames, "*.pyx"): + self.cythonize(join(root, filename)) + + def biglink(self): + dirs = [] + for root, dirnames, filenames in 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, "lib{}.a".format(self.name)), *dirs) + # Public Recipe API to be subclassed if needed def init_with_ctx(self, ctx):