build logger experiments

This commit is contained in:
Robert Niederreiter 2016-11-02 14:34:21 +01:00
parent d65c85b0a8
commit 38230677fb
3 changed files with 70 additions and 14 deletions

View file

@ -1,5 +1,7 @@
from os.path import join
from toolchain import CythonRecipe
from toolchain import shprint
import sh
class CryptographyRecipe(CythonRecipe):
@ -13,10 +15,51 @@ class CryptographyRecipe(CythonRecipe):
depends = ["host_setuptools", "cffi", "six", "idna", "pyasn1", "enum34"]
cythonize = False
#def get_recipe_env(self, arch):
# env = super(CryptographyRecipe, self).get_recipe_env(arch)
# env["CC"] += " -I{}".format(
# join(self.ctx.dist_dir, "include", arch.arch, "libffi"))
# return env
def get_recipe_env(self, arch):
env = super(CryptographyRecipe, self).get_recipe_env(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"))
return env
def install(self):
print 'INSTALL #####################################'
super(CryptographyRecipe, self).install()
def build_arch(self, arch):
print 'BUILD_ARCH ###################################'
build_env = self.get_recipe_env(arch)
print 'ENV #################'
for k, v in sorted(build_env.items()):
print k + ': ' + v
hostpython = sh.Command(self.ctx.hostpython)
shprint(hostpython, "setup.py", "build_ext", "-g", "-v", _env=build_env)
self.biglink()
recipe = CryptographyRecipe()

View file

@ -1,6 +1,6 @@
'''Recipe for pycrypto on ios
'''
from toolchain import CythonRecipe, shprint
from toolchain import CythonRecipe, shprint, build_logger
from os.path import join, exists
import sh
import os
@ -15,7 +15,9 @@ class PycryptoRecipe(CythonRecipe):
def build_arch(self, arch):
build_logger.log('PycryptoRecipe.build_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,
@ -32,13 +34,19 @@ class PycryptoRecipe(CythonRecipe):
super(PycryptoRecipe, self).build_arch(arch)
def install(self):
build_logger.log('PycryptoRecipe.install()')
arch = list(self.filtered_archs)[0]
build_logger.log('arch:\n ', arch)
build_dir = self.get_build_dir(arch.arch)
build_logger.log('build_dir:\n ', arch)
os.chdir(build_dir)
hostpython = sh.Command(self.ctx.hostpython)
build_logger.log('hostpython:\n ', hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_logger.log('dest_dir:\n ', dest_dir)
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_logger.log('build_env', **build_env)
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
recipe = PycryptoRecipe()

View file

@ -32,24 +32,29 @@ import sh
IS_PY3 = sys.version_info[0] >= 3
class CommandLogger(object):
build_log_path = join(__file__[:__file__.rfind('/toolchain.py')], 'build.log')
def __init__(self, filename='build.log'):
class BuildLogger(object):
def __init__(self, filename=build_log_path):
self.filename = filename
def log(self, *args, **kw):
msg = ', '.join([str(arg) for arg in args])
for k, v in kw:
msg += '\n{}={}'.format(k, str(v))
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)
command_logger = CommandLogger()
build_logger = BuildLogger()
def shprint(command, *args, **kwargs):
command_logger.log(*(command,) + args, **kwargs)
build_logger.log(*(command,) + args, **kwargs)
kwargs["_iter"] = True
kwargs["_out_bufsize"] = 1
kwargs["_err_to_out"] = True
@ -602,7 +607,7 @@ class Recipe(object):
for library in self.libraries:
static_fn = join(self.ctx.dist_dir, "lib", basename(library))
libraries.append(static_fn)
command_logger.log(*['Recipe().dist_libraries'] + libraries)
build_logger.log(*['Recipe().dist_libraries'] + libraries)
return libraries
def get_build_dir(self, arch):