document new findings, remove build logger, some cleanup
This commit is contained in:
parent
0404d269b4
commit
e0f7ec5197
5 changed files with 50 additions and 70 deletions
|
@ -24,7 +24,7 @@ class CffiRecipe(CythonRecipe):
|
|||
return env
|
||||
|
||||
def install(self):
|
||||
arch = list(self.filtered_archs)[0]
|
||||
arch = [arch for arch in self.filtered_archs if arch.arch == 'x86_64'][0]
|
||||
build_dir = self.get_build_dir(arch.arch)
|
||||
os.chdir(build_dir)
|
||||
# manually create expected directory in build directory
|
||||
|
@ -32,13 +32,35 @@ class CffiRecipe(CythonRecipe):
|
|||
if not os.path.exists(scripts_dir):
|
||||
os.makedirs(scripts_dir)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
|
||||
# install cffi in hostpython
|
||||
#
|
||||
# XXX: installs, module import works, but FFI fails to instanciate:
|
||||
#
|
||||
# myhost:kivy-ios user$ ./dist/hostpython/bin/python
|
||||
# Could not find platform dependent libraries <exec_prefix>
|
||||
# Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
|
||||
# Python 2.7.1 (r271:86832, Nov 4 2016, 10:41:44)
|
||||
# [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
|
||||
# Type "help", "copyright", "credits" or "license" for more information.
|
||||
# >>> import cffi
|
||||
# >>> cffi.api.FFI()
|
||||
# Traceback (most recent call last):
|
||||
# File "<stdin>", line 1, in <module>
|
||||
# File "/.../kivy-ios/dist/hostpython/lib/python2.7/site-packages/cffi/api.py", line 56, in __init__
|
||||
# import _cffi_backend as backend
|
||||
# ImportError: dynamic module does not define init function (init_cffi_backend)
|
||||
r = self.get_recipe('hostlibffi', self.ctx)
|
||||
build_env = r.get_recipe_env(arch)
|
||||
args = [hostpython, "setup.py", "install"]
|
||||
shprint(*args, _env=build_env)
|
||||
|
||||
# install cffi in root site packages
|
||||
build_env = arch.get_env()
|
||||
dest_dir = join(self.ctx.dist_dir, "root", "python")
|
||||
pythonpath = join(dest_dir, 'lib', 'python2.7', 'site-packages')
|
||||
build_env['PYTHONPATH'] = pythonpath
|
||||
args = [hostpython, "setup.py", "install", "--prefix", dest_dir]
|
||||
shprint(*args, _env=build_env)
|
||||
args = [hostpython, "setup.py", "install"]
|
||||
shprint(*args, _env=build_env)
|
||||
|
||||
recipe = CffiRecipe()
|
||||
|
|
|
@ -16,49 +16,30 @@ class CryptographyRecipe(CythonRecipe):
|
|||
cythonize = False
|
||||
|
||||
def get_recipe_env(self, arch):
|
||||
#env['LN_FLAGS'] = "-lboost_thread-mt"
|
||||
#env['PKG_CONFIG_PATH'] = join(self.ctx.dist_dir, "include", arch.arch, "libffi")
|
||||
#env['PKG_CONFIG_PATH'] += ":" + join(self.ctx.dist_dir, "include", arch.arch, "openssl")
|
||||
"""
|
||||
libffi_include = dict()
|
||||
libffi_include['arm64'] = 'build_iphoneos-arm64'
|
||||
libffi_include['armv7'] = 'build_iphoneos-armv7'
|
||||
libffi_include['i386'] = 'build_iphonesimulator-i386'
|
||||
libffi_include['x86_64'] = 'build_iphonesimulator-x86_64'
|
||||
include_path = join(
|
||||
self.ctx.build_dir, 'libffi', arch.arch,
|
||||
'libffi-3.2.1', libffi_include[arch.arch])
|
||||
env['PKG_CONFIG_PATH'] = include_path
|
||||
env["CC"] += " -I{}".format(include_path)
|
||||
env["CC"] += " -I{}".format(
|
||||
join(self.ctx.dist_dir, "include", arch.arch, "libffi"))
|
||||
# env["CFLAGS"]
|
||||
#env["CFLAGS"] += " -I{}".format(
|
||||
# join(self.ctx.dist_dir, "include", arch.arch, "openssl", "openssl"))
|
||||
"""
|
||||
#dest_dir = join(self.ctx.dist_dir, "root", "python")
|
||||
#pythonpath = join(dest_dir, "lib", "python2.7", "site-packages")
|
||||
#env["PYTHONPATH"] = pythonpath
|
||||
#env["CC"] += " -I{}".format(
|
||||
# join(self.ctx.dist_dir, "include", arch.arch, "libffi"))
|
||||
#env["LDFLAGS"] += "-L{}".format(
|
||||
# join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
|
||||
#env["CFLAGS"] += "-I{}".format(
|
||||
# join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include"))
|
||||
env = super(CryptographyRecipe, self).get_recipe_env(arch)
|
||||
r = self.get_recipe('openssl', self.ctx)
|
||||
openssl_dir = r.get_build_dir(arch.arch)
|
||||
env['PYTHON_ROOT'] = join(self.ctx.dist_dir, 'root', 'python')
|
||||
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \
|
||||
' -I' + join(openssl_dir, 'include')
|
||||
# Set linker to use the correct gcc
|
||||
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
|
||||
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
|
||||
' -L' + openssl_dir + \
|
||||
' -lpython2.7' + \
|
||||
' -lssl' + r.version + \
|
||||
' -lcrypto' + r.version
|
||||
env["CC"] += " -I{}".format(
|
||||
join(self.ctx.dist_dir, "include", arch.arch, "libffi"))
|
||||
env["CFLAGS"] += " -I{}".format(
|
||||
join(self.ctx.dist_dir, "include", arch.arch, "openssl", "openssl"))
|
||||
return env
|
||||
|
||||
def install(self):
|
||||
arch = list(self.filtered_archs)[0]
|
||||
build_dir = self.get_build_dir(arch.arch)
|
||||
os.chdir(build_dir)
|
||||
# manually create expected directory in build directory
|
||||
scripts_dir = join("build", "scripts-2.7")
|
||||
if not os.path.exists(scripts_dir):
|
||||
os.makedirs(scripts_dir)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
build_env = arch.get_env()
|
||||
dest_dir = join(self.ctx.dist_dir, "root", "python")
|
||||
pythonpath = join(dest_dir, 'lib', 'python2.7', 'site-packages')
|
||||
build_env['PYTHONPATH'] = pythonpath
|
||||
args = [hostpython, "setup.py", "install", "--prefix", dest_dir]
|
||||
shprint(*args, _env=build_env)
|
||||
#args = [hostpython, "setup.py", "install"]
|
||||
#shprint(*args, _env=build_env)
|
||||
|
||||
recipe = CryptographyRecipe()
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ class HostSetuptools(Recipe):
|
|||
# LINKED SETUPTOOLS CAN CAUSE TROUBLES, UNCOMMENT RETURN IF INSTALLING
|
||||
# PYTHON PACKAGE FAILS. UNPACKED SETUPTOOLS RESULT IN BDIST_EGG COMMAND
|
||||
# NOT FOUND
|
||||
return
|
||||
# Extract setuptools egg and remove .pth files. Otherwise subsequent
|
||||
# python package installations using setuptools will raise exceptions.
|
||||
# Setuptools version 28.3.0
|
||||
|
@ -32,7 +31,9 @@ class HostSetuptools(Recipe):
|
|||
shprint(unzip, setuptools_egg_path)
|
||||
os.remove(setuptools_egg_path)
|
||||
os.remove('setuptools.pth')
|
||||
os.remove('easy-install.pth')
|
||||
# XXX: setuptools egg is referenced in easy-install.pth, check removal
|
||||
# after unpacking setuptools if necessary
|
||||
#os.remove('easy-install.pth')
|
||||
shutil.rmtree('EGG-INFO')
|
||||
|
||||
recipe = HostSetuptools()
|
||||
|
|
|
@ -16,7 +16,6 @@ class PycryptoRecipe(CythonRecipe):
|
|||
|
||||
def build_arch(self, arch):
|
||||
build_env = arch.get_env()
|
||||
build_logger.log(**build_env)
|
||||
self.apply_patch('hash_SHA2_template.c.patch', target_dir=self.build_dir + '/src')
|
||||
configure = sh.Command(join(self.build_dir, "configure"))
|
||||
shprint(configure,
|
||||
|
|
23
toolchain.py
23
toolchain.py
|
@ -32,29 +32,7 @@ import sh
|
|||
IS_PY3 = sys.version_info[0] >= 3
|
||||
|
||||
|
||||
build_log_path = join(__file__[:__file__.rfind('/toolchain.py')], 'build.log')
|
||||
|
||||
|
||||
class BuildLogger(object):
|
||||
|
||||
def __init__(self, filename=build_log_path):
|
||||
self.filename = filename
|
||||
|
||||
def log(self, *args, **kw):
|
||||
msg = ''
|
||||
for arg in args:
|
||||
msg += str(arg) + '\n'
|
||||
for k, v in kw.items():
|
||||
msg += '{}={}\n'.format(k, str(v))
|
||||
with open(self.filename, 'a') as f:
|
||||
f.write(msg)
|
||||
|
||||
|
||||
build_logger = BuildLogger()
|
||||
|
||||
|
||||
def shprint(command, *args, **kwargs):
|
||||
build_logger.log(*(command,) + args, **kwargs)
|
||||
kwargs["_iter"] = True
|
||||
kwargs["_out_bufsize"] = 1
|
||||
kwargs["_err_to_out"] = True
|
||||
|
@ -607,7 +585,6 @@ class Recipe(object):
|
|||
for library in self.libraries:
|
||||
static_fn = join(self.ctx.dist_dir, "lib", basename(library))
|
||||
libraries.append(static_fn)
|
||||
build_logger.log(*['Recipe().dist_libraries'] + libraries)
|
||||
return libraries
|
||||
|
||||
def get_build_dir(self, arch):
|
||||
|
|
Loading…
Reference in a new issue