Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fada0ee
Changed ArchAndroid to specify arch
inclement Nov 28, 2015
7934d52
Changed .mk files to check $ARCH correctly
inclement Nov 29, 2015
88bcb5f
Renamed ArchAndroid<...> to Arch<...>
inclement Nov 29, 2015
9af971f
Added Arch specification support (hackily)
inclement Nov 29, 2015
b9e6e52
Fixed hostpython2 recipe to ignore arch
inclement Nov 29, 2015
0194a23
Changed apply_patch to pass arch argument
inclement Nov 29, 2015
480fb46
Added get_env for different arch types
inclement Nov 29, 2015
1bec42f
Fixed arch pass-through in more places
inclement Nov 30, 2015
87dac5f
Removed more hardcoded 'armeabi' archs
inclement Nov 30, 2015
7174dfe
More fixes to hardcoded armeabi
inclement Nov 30, 2015
cb45693
Fixed inheritance of non-ARM Archs
inclement Nov 30, 2015
f8eb278
Added temporary jpg disable for sdl_image x86
inclement Nov 30, 2015
53e0634
Made jpg disable only occur with x86 build
inclement Nov 30, 2015
d44be85
Fixed armeabi hardcoding in pygame bootstrap
inclement Nov 30, 2015
764ab7a
Fixed $ARCH reference in pygame Android.mk
inclement Dec 4, 2015
13e8501
Removed more hardcoded Archs
inclement Dec 5, 2015
3898585
Changed to find correct compiler in NDK
inclement Dec 5, 2015
475e5f7
Terrible hacks to load x86 gcc if necessary
inclement Dec 5, 2015
2be55f7
Updated README about multiarch
inclement Dec 5, 2015
a9c22fd
Moved toolchain path info to Arch classes
inclement Dec 5, 2015
91b6e07
Added arch argument to should_build
inclement Dec 5, 2015
6beaaf3
Cleaned comments and unused content from toolchain
inclement Dec 5, 2015
28e0527
Deleted more unnecessary comments
inclement Dec 5, 2015
385e0db
pep8 fixes
inclement Dec 5, 2015
2391ff0
Added archs command to list available archs
inclement Dec 5, 2015
ee5dc2b
Documented --arch
inclement Dec 5, 2015
3fcb9d0
Reworded .p4a section of doc
inclement Dec 5, 2015
42dcb39
Added arch to dist_info
inclement Dec 5, 2015
aad5b49
Added arch save in dist_info.json
inclement Dec 5, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Broad goals of the revamp project include:
- (WIP) Support python3 (recipe exists but crashes on android)
- (WIP) Support some kind of binary distribution, including on windows (semi-implemented, just needs finishing)
- ✓ Be a standalone Pypi module (not on pypi yet but setup.py works)
- Support multiple architectures
- Support multiple architectures (full multiarch builds not complete, but arm and x86 with different config both work now)

We are currently working to stabilise all parts of the toolchain and
add more features. Support for pygame-based APKs is almost feature
Expand Down
5 changes: 5 additions & 0 deletions doc/source/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ supply those that you need.
``--force_build BOOL``
Whether the distribution must be compiled from scratch.

``--arch``
The architecture to build for. Currently only one architecture can be
targeted at a time, and a given distribution can only include one architecture.


.. note:: These options are preliminary. Others will include toggles
for allowing downloads, and setting additional directories
from which to load user dists.
8 changes: 4 additions & 4 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ correct and try to continue the build.
Configuration file
~~~~~~~~~~~~~~~~~~

python-for-android look on the current directory if there is a `.p4a`
configuration file. If it found it, it adds all the lines as options
to the command line. For example, you can put the options you would
always write such as:
python-for-android checks in the current directory for a configuration
file named ``.p4a``. If found, it adds all the lines as options to the
command line. For example, you can add the options you would always
include such as:

--dist_name my_example
--android_api 19
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/empty/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchARM, logger, info_main, which
from os.path import join, exists
from os import walk
import glob
Expand Down
10 changes: 6 additions & 4 deletions pythonforandroid/bootstraps/pygame/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchARM, info_main
from os.path import join, exists
from os import walk
import glob
Expand All @@ -19,8 +19,10 @@ def run_distribute(self):
# self.name)
src_path = join(self.bootstrap_dir, 'build')

# AND: Hardcoding armeabi - naughty!
arch = ArchAndroid(self.ctx)
arch = self.ctx.archs[0]
if len(self.ctx.archs) > 1:
raise ValueError('built for more than one arch, but bootstrap cannot handle that yet')
info('Bootstrap running with arch {}'.format(arch))

with current_directory(self.dist_dir):

Expand Down Expand Up @@ -58,7 +60,7 @@ def run_distribute(self):
shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))

# AND: Copylibs stuff should go here
shprint(sh.mv, join('libs', 'armeabi', 'libpymodules.so'), 'private/')
shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))

info('Removing some unwanted files')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LOCAL_CFLAGS := $(foreach D, $(APP_SUBDIRS), -I$(LOCAL_PATH)/$(D)) \
-I$(LOCAL_PATH)/../jpeg \
-I$(LOCAL_PATH)/../intl \
-I$(LOCAL_PATH)/.. \
-I$(LOCAL_PATH)/../../../../other_builds/python2/armeabi/python2/python-install/include/python2.7
-I$(LOCAL_PATH)/../../../../other_builds/python2/$(ARCH)/python2/python-install/include/python2.7
# -I$(LOCAL_PATH)/../../../../python-install/include/python2.7
# -I$(LOCAL_PATH)/../../../build/python-install/include/python2.7

Expand All @@ -39,7 +39,8 @@ LOCAL_STATIC_LIBRARIES := jpeg png
LOCAL_LDLIBS := -lpython2.7 -lGLESv1_CM -ldl -llog -lz

# AND: Another hardcoded path that should be templated
LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../../../other_builds/python2/armeabi/python2/python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS)
# AND: NOT TEMPALTED! We can use $ARCH
LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../../../other_builds/python2/$(ARCH)/python2/python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS)

LIBS_WITH_LONG_SYMBOLS := $(strip $(shell \
for f in $(LOCAL_PATH)/../../libs/$ARCH/*.so ; do \
Expand Down
13 changes: 7 additions & 6 deletions pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchARM, info_main
from os.path import join, exists
from os import walk
import glob
Expand All @@ -20,8 +20,10 @@ def run_distribute(self):
with open('local.properties', 'w') as fileh:
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))

# AND: Hardcoding armeabi - naughty!
arch = ArchAndroid(self.ctx)
arch = self.ctx.archs[0]
if len(self.ctx.archs) > 1:
raise ValueError('built for more than one arch, but bootstrap cannot handle that yet')
info('Bootstrap running with arch {}'.format(arch))

with current_directory(self.dist_dir):
info('Copying python distribution')
Expand All @@ -32,7 +34,6 @@ def run_distribute(self):
shprint(sh.mkdir, 'assets')

hostpython = sh.Command(self.ctx.hostpython)
# AND: This *doesn't* need to be in arm env?
shprint(hostpython, '-OO', '-m', 'compileall',
self.ctx.get_python_install_dir(),
_tail=10, _filterout="^Listing", _critical=True)
Expand All @@ -50,8 +51,8 @@ def run_distribute(self):
shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))

# AND: Copylibs stuff should go here
if exists(join('libs', 'armeabi', 'libpymodules.so')):
shprint(sh.mv, join('libs', 'armeabi', 'libpymodules.so'), 'private/')
if exists(join('libs', arch.arch, 'libpymodules.so')):
shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))

info('Removing some unwanted files')
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/sdl2/build/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# APP_STL := stlport_static

# APP_ABI := armeabi armeabi-v7a x86
APP_ABI := armeabi
APP_ABI := $(ARCH)
4 changes: 2 additions & 2 deletions pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
start.c

LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../other_builds/python2/armeabi/python2/python-install/include/python2.7
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../other_builds/python2/$(ARCH)/python2/python-install/include/python2.7

LOCAL_SHARED_LIBRARIES := SDL2

LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog -lpython2.7

LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../../../other_builds/python2/armeabi/python2/python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS)
LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../../../other_builds/python2/$(ARCH)/python2/python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS)

include $(BUILD_SHARED_LIBRARY)
4 changes: 2 additions & 2 deletions pythonforandroid/bootstraps/sdl2python3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchARM, info_main
from os.path import join, exists
from os import walk
import glob
Expand All @@ -23,7 +23,7 @@ def run_distribute(self):
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))

# AND: Hardcoding armeabi - naughty!
arch = ArchAndroid(self.ctx)
arch = ArchARM(self.ctx)

with current_directory(self.dist_dir):
info('Copying python distribution')
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/android/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import CythonRecipe, shprint, ensure_dir, current_directory, ArchAndroid, IncludedFilesBehaviour
from pythonforandroid.toolchain import CythonRecipe, shprint, ensure_dir, current_directory, ArchARM, IncludedFilesBehaviour
import sh
from os.path import exists, join

Expand Down
6 changes: 3 additions & 3 deletions pythonforandroid/recipes/freetype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroid
from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchARM
from os.path import exists, join, realpath
from os import uname
import glob
Expand All @@ -12,8 +12,8 @@ class FreetypeRecipe(Recipe):

depends = ['harfbuzz']

def should_build(self):
if exists(join(self.get_build_dir('armeabi'), 'objs', '.libs', 'libfreetype.so')):
def should_build(self, arch):
if exists(join(self.get_build_dir(arch.arch), 'objs', '.libs', 'libfreetype.so')):
return False
return True

Expand Down
6 changes: 3 additions & 3 deletions pythonforandroid/recipes/harfbuzz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroid
from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchARM
from os.path import exists, join, realpath
from os import uname
import glob
Expand All @@ -10,8 +10,8 @@ class HarfbuzzRecipe(Recipe):
version = '0.9.40'
url = 'http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-{version}.tar.bz2'

def should_build(self):
if exists(join(self.get_build_dir('armeabi'), 'src', '.libs', 'libharfbuzz.so')):
def should_build(self, arch):
if exists(join(self.get_build_dir(arch.arch), 'src', '.libs', 'libharfbuzz.so')):
return False
return True

Expand Down
29 changes: 16 additions & 13 deletions pythonforandroid/recipes/hostpython2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ class Hostpython2Recipe(Recipe):

conflicts = ['hostpython3']

def prebuild_armeabi(self):
def get_build_container_dir(self, arch=None):
choices = self.check_recipe_choices()
dir_name = '-'.join([self.name] + choices)
return join(self.ctx.build_dir, 'other_builds', dir_name, 'desktop')

def get_build_dir(self, arch=None):
return join(self.get_build_container_dir(), self.name)

def prebuild_arch(self, arch):
# Override hostpython Setup?
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
join(self.get_build_dir('armeabi'), 'Modules', 'Setup'))

def build_armeabi(self):
# AND: Should use an i386 recipe system
warning('Running hostpython build. Arch is armeabi! '
'This is naughty, need to fix the Arch system!')
join(self.get_build_dir(), 'Modules', 'Setup'))

# AND: Fix armeabi again
with current_directory(self.get_build_dir('armeabi')):
def build_arch(self, arch):
with current_directory(self.get_build_dir()):

if exists('hostpython'):
info('hostpython already exists, skipping build')
self.ctx.hostpython = join(self.get_build_dir('armeabi'),
self.ctx.hostpython = join(self.get_build_dir(),
'hostpython')
self.ctx.hostpgen = join(self.get_build_dir('armeabi'),
self.ctx.hostpgen = join(self.get_build_dir(),
'hostpgen')
return

Expand All @@ -49,8 +52,8 @@ def build_armeabi(self):
'hostpython build! Exiting.')
exit(1)

self.ctx.hostpython = join(self.get_build_dir('armeabi'), 'hostpython')
self.ctx.hostpgen = join(self.get_build_dir('armeabi'), 'hostpgen')
self.ctx.hostpython = join(self.get_build_dir(), 'hostpython')
self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')


recipe = Hostpython2Recipe()
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/kivy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroid
from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchARM
from os.path import exists, join
import sh
import glob
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/kivysdl2python3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroid
from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchARM
from os.path import exists, join
import sh
import glob
Expand Down Expand Up @@ -35,7 +35,7 @@ def get_recipe_env(self, arch):
return env

# def build_armeabi(self):
# env = ArchAndroid(self.ctx).get_env()
# env = ArchARM(self.ctx).get_env()

# env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(self.ctx.libs_dir)
# env['LDSHARED'] = env['LIBLINK']
Expand Down
8 changes: 4 additions & 4 deletions pythonforandroid/recipes/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def prebuild_arch(self, arch):
print('numpy already patched, skipping')
return

self.apply_patch('patches/fix-numpy.patch')
self.apply_patch('patches/prevent_libs_check.patch')
self.apply_patch('patches/ar.patch')
self.apply_patch('patches/lib.patch')
self.apply_patch('patches/fix-numpy.patch', arch.arch)
self.apply_patch('patches/prevent_libs_check.patch', arch.arch)
self.apply_patch('patches/ar.patch', arch.arch)
self.apply_patch('patches/lib.patch', arch.arch)

# AND: Fix this warning!
warning('Numpy is built assuming the archiver name is '
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/openssl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class OpenSSLRecipe(Recipe):
version = '1.0.2d'
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'

def should_build(self):
return not exists(join(self.get_build_dir('armeabi'), 'libssl.a'))
def should_build(self, arch):
return not exists(join(self.get_build_dir(arch.arch), 'libssl.a'))

def build_arch(self, arch):
env = self.get_recipe_env(arch)
Expand Down
21 changes: 10 additions & 11 deletions pythonforandroid/recipes/pygame/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import Recipe, shprint, ArchAndroid, current_directory, debug, info, ensure_dir
from pythonforandroid.toolchain import Recipe, shprint, ArchARM, current_directory, debug, info, ensure_dir
from os.path import exists, join
import sh
import glob
Expand All @@ -26,21 +26,20 @@ def get_recipe_env(self, arch):
ensure_dir(liblink_path)
return env

def prebuild_armeabi(self):
if exists(join(self.get_build_container_dir('armeabi'), '.patched')):
def prebuild_arch(self, arch):
if exists(join(self.get_build_container_dir(arch.arch), '.patched')):
info('Pygame already patched, skipping.')
return
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
join(self.get_build_dir('armeabi'), 'Setup'))
self.apply_patch(join('patches', 'fix-surface-access.patch'))
self.apply_patch(join('patches', 'fix-array-surface.patch'))
self.apply_patch(join('patches', 'fix-sdl-spam-log.patch'))
shprint(sh.touch, join(self.get_build_container_dir('armeabi'), '.patched'))
join(self.get_build_dir(arch.arch), 'Setup'))
self.apply_patch(join('patches', 'fix-surface-access.patch'), arch.arch)
self.apply_patch(join('patches', 'fix-array-surface.patch'), arch.arch)
self.apply_patch(join('patches', 'fix-sdl-spam-log.patch'), arch.arch)
shprint(sh.touch, join(self.get_build_container_dir(arch.arch), '.patched'))

def build_armeabi(self):
def build_arch(self, arch):
# AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now

arch = ArchAndroid(self.ctx)
env = self.get_recipe_env(arch)

env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format(
Expand All @@ -57,7 +56,7 @@ def build_armeabi(self):

env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')

with current_directory(self.get_build_dir('armeabi')):
with current_directory(self.get_build_dir(arch.arch)):
info('hostpython is ' + self.ctx.hostpython)
hostpython = sh.Command(self.ctx.hostpython)
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/pyjnius/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroid, current_directory, info
from pythonforandroid.toolchain import CythonRecipe, shprint, ArchARM, current_directory, info
import sh
import glob
from os.path import join, exists
Expand All @@ -18,7 +18,7 @@ def prebuild_arch(self, arch):
if exists(join(build_dir, '.patched')):
print('pyjniussdl2 already pathed, skipping')
return
self.apply_patch('sdl2_jnienv_getter.patch')
self.apply_patch('sdl2_jnienv_getter.patch', arch.arch)
shprint(sh.touch, join(build_dir, '.patched'))

def postbuild_arch(self, arch):
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/pyopenssl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def prebuild_arch(self, arch):
if exists(join(build_dir, '.patched')):
print('pyOpenSSL already patched, skipping')
return
self.apply_patch('fix-dlfcn.patch')
self.apply_patch('fix-dlfcn.patch', arch.arch)
shprint(sh.touch, join(build_dir, '.patched'))

def get_recipe_env(self, arch):
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/pysdl2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pythonforandroid.toolchain import PythonRecipe, shprint, current_directory, ArchAndroid
from pythonforandroid.toolchain import PythonRecipe, shprint, current_directory, ArchARM
from os.path import exists, join
import sh
import glob
Expand Down
Loading