Skip to content

Commit 4b742d6

Browse files
committed
Still working on this build thing
1 parent 1583720 commit 4b742d6

File tree

3 files changed

+30
-68
lines changed

3 files changed

+30
-68
lines changed

pythonforandroid/recipes/libxml2/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,32 @@ class Libxml2Recipe(Recipe):
66
version = '2.7.8'
77
url = 'http://xmlsoft.org/sources/libxml2-{version}.tar.gz'
88
depends = []
9+
patches = ['add-glob.c.patch']
910

1011
def should_build(self, arch):
1112
super(Libxml2Recipe, self).should_build(arch)
13+
return True
1214
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a'))
1315

1416
def build_arch(self, arch):
1517
super(Libxml2Recipe, self).build_arch(arch)
1618
env = self.get_recipe_env(arch)
1719
with current_directory(self.get_build_dir(arch.arch)):
20+
# First we need to build glob.c because its not avail
21+
# in android ndk
22+
23+
24+
shprint(sh.Command(env['CC'].split(" ")[0]), env['CC'].split(" ")[1], "-c", "-I.", "glob.c")
25+
shprint(sh.Command("chmod"), "+x", "glob.o")
26+
27+
env['LIBS'] = "./glob.o"
28+
1829
# If the build is done with /bin/sh things blow up,
1930
# try really hard to use bash
2031
sed = sh.Command('sed')
21-
shprint(sh.Command('./configure'), '--build=i686-pc-linux-gnu', '--host=arm-linux-eabi',
22-
'--without-modules', '--without-legacy', '--without-history', '--without-debug', '--without-docbook', '--without-python', '--without-threads', '--without-iconv')
32+
shprint(sh.Command('./configure'), '--host=arm-linux-eabi',
33+
'--without-modules', '--without-legacy', '--without-hfinistory', '--without-debug', '--without-docbook', '--without-python', '--without-threads', '--without-iconv',
34+
_env=env)
2335
shprint(sh.make, _env=env)
2436
shutil.copyfile('.libs/libxml2.a', join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a'))
2537

@@ -28,6 +40,10 @@ def get_recipe_env(self, arch):
2840
env = super(Libxml2Recipe, self).get_recipe_env(arch)
2941
env['CONFIG_SHELL'] = '/bin/bash'
3042
env['SHELL'] = '/bin/bash'
43+
env['CC'] = '/usr/bin/ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer'
44+
env['CCC'] = '/usr/bin/ccache arm-linux-androideabi-g++ -DANDROID -mandroid -fomit-frame-pointer'
45+
#--sysroot /opt/android-sdks/ndk-bundle/platforms/android-16/arch-arm -I/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxml2/armeabi/libxml2//include -I/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxslt/armeabi/libxslt -I/home/zgoldberg/.local/share/python-for-android/build/python-installs/peggo-python/include/python2.7
46+
3147
return env
3248

3349
recipe = Libxml2Recipe()

pythonforandroid/recipes/libxslt/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class LibxsltRecipe(Recipe):
88
depends = ['libxml2']
99
patches = ['fix-dlopen.patch']
1010

11+
call_hostpython_via_targetpython = False
12+
1113
def should_build(self, arch):
1214
super(LibxsltRecipe, self).should_build(arch)
1315
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libxslt.a'))

pythonforandroid/recipes/lxml/__init__.py

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pythonforandroid.toolchain import CompiledComponentsPythonRecipe
33
from pythonforandroid.util import current_directory, ensure_dir
44
from pythonforandroid.logger import debug, shprint, info
5-
from os.path import exists, join
5+
from os.path import exists, join, dirname
66
import sh
77
import glob
88

@@ -19,77 +19,21 @@ def should_build(self, arch):
1919
return True
2020
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'liblxml.so'))
2121

22-
"""
23-
def build_arch(self, arch):
24-
env = self.get_recipe_env(arch)
25-
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format(
26-
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
27-
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl/include -I{jni_path}/sdl_mixer'.format(
28-
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
29-
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl_ttf -I{jni_path}/sdl_image'.format(
30-
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
31-
debug('pygame cflags', env['CFLAGS'])
32-
33-
34-
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{libs_path} -L{src_path}/obj/local/{arch} -lm -lz'.format(
35-
libs_path=self.ctx.libs_dir, src_path=self.ctx.bootstrap.build_dir, arch=env['ARCH'])
36-
37-
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')
38-
39-
with current_directory(self.get_build_dir(arch.arch)):
40-
info('hostpython is ' + self.ctx.hostpython)
41-
hostpython = sh.Command(self.ctx.hostpython)
42-
shprint(hostpython, 'setup.py',
43-
'build_ext',
44-
"-I/home/zgoldberg/.local/share/python-for-android/dists/peggo-python/python-install/include/python2.7/pyconfig.h",
45-
"-I/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxml2/armeabi/libxml2/include",
46-
"-I/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxslt/armeabi/libxslt",
47-
_tail=10000, _critical=True, _env=env)
48-
49-
build_lib = glob.glob('./build/lib*')
50-
assert len(build_lib) == 1
51-
52-
shprint(sh.find, ".", '-iname', '*.pyx', '-exec',
53-
env['CYTHON'], '{}', ';')
54-
55-
shprint(hostpython, 'setup.py',
56-
'build_ext', "-v",
57-
_tail=10000, _critical=True, _env=env)
58-
59-
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
60-
env['STRIP'], '{}', ';')
61-
62-
shprint(hostpython, 'setup.py',
63-
'install', "-O2",
64-
_tail=10000, _critical=True, _env=env)
65-
66-
#env['PYTHONPATH'] += $BUILD_hostpython/Lib/site-packages
67-
#try $BUILD_hostpython/hostpython setup.py install -O2 --root=$BUILD_PATH/python-install --install-lib=lib/python2.7/site-packages
68-
69-
70-
71-
super(LXMLRecipe, self).build_arch(arch)
72-
"""
7322
def get_recipe_env(self, arch):
7423
env = super(LXMLRecipe, self).get_recipe_env(arch)
7524
bxml = "/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxml2/armeabi/libxml2/"
7625
bxsl = "/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxslt/armeabi/libxslt"
77-
env['CC'] += " -I%s/include -I%s" % (bxml, bxsl)
78-
env['LDFLAGS'] = (" -L%s/libxslt/.libs -L%s/.libs -L%s/libxslt -L%s/ " % (bxsl, bxsl, bxml, bxsl)) + env['LDFLAGS']
79-
env['CYTHON'] = "cython"
80-
env['LDSHARED'] = "$LIBLINK"
81-
env['PATH'] += ":%s" % bxsl
82-
env['CFLAGS'] += ' -Os'
83-
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
84-
self.ctx.get_libs_dir(arch.arch))
26+
targetpython = "%s/include/python2.7/" % dirname(dirname(self.ctx.hostpython))
27+
env['CC'] += " -I%s/include -I%s -I%s" % (bxml, bxsl, targetpython)
28+
#env['LDSHARED'] = ENV['CC']
8529
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')
86-
env['LIBLINK'] = 'NOTNONE'
87-
env['NDKPLATFORM'] = self.ctx.ndk_platform
30+
# WTH is liblink?
31+
env['LDSHARED'] = env['LIBLINK']
32+
# This linking almost works. Going to have to muck with LDSHARED to
33+
# include the libs_collection folder
34+
#zgoldberg@badass:~/.local/share/python-for-android/build/other_builds/lxml/armeabi/lxml (master)$ /usr/bin/ccache arm-linux-androideabi-ld -L/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxml2/armeabi/libxml2//include -L/home/zgoldberg/.local/share/python-for-android/build/other_builds/libxslt/armeabi/libxslt -L/home/zgoldberg/android-sdks/ndk-bundle/platforms/android-16/arch-arm/usr/lib/ -L/home/zgoldberg/android-sdks/ndk-bundle/platforms/android-16/arch-arm/usr/lib/ -L/home/zgoldberg/.local/share/python-for-android/build/libs_collections/peggo-python/armeabi build/temp.linux-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lxml2 -lpython2.7 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/objectify.soi
8835

89-
# Every recipe uses its own liblink path, object files are collected and biglinked later
90-
liblink_path = join(self.get_build_container_dir(arch.arch), 'objects_{}'.format(self.name))
91-
env['LIBLINK_PATH'] = liblink_path
92-
ensure_dir(liblink_path)
36+
import pdb; pdb.set_trace()
9337
return env
9438

9539
recipe = LXMLRecipe()

0 commit comments

Comments
 (0)