From fada0ee3f51dc939a0adb6abc8be6e27dc80c824 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 28 Nov 2015 23:47:01 +0000 Subject: [PATCH 01/29] Changed ArchAndroid to specify arch --- pythonforandroid/bootstraps/empty/__init__.py | 2 +- .../bootstraps/pygame/__init__.py | 4 ++-- pythonforandroid/bootstraps/sdl2/__init__.py | 4 ++-- .../bootstraps/sdl2python3/__init__.py | 4 ++-- pythonforandroid/recipes/android/__init__.py | 2 +- pythonforandroid/recipes/freetype/__init__.py | 2 +- pythonforandroid/recipes/harfbuzz/__init__.py | 2 +- pythonforandroid/recipes/kivy/__init__.py | 2 +- .../recipes/kivysdl2python3/__init__.py | 4 ++-- pythonforandroid/recipes/pygame/__init__.py | 4 ++-- pythonforandroid/recipes/pyjnius/__init__.py | 2 +- pythonforandroid/recipes/pysdl2/__init__.py | 2 +- pythonforandroid/recipes/python2/__init__.py | 4 ++-- pythonforandroid/recipes/python3/__init__.py | 4 ++-- pythonforandroid/recipes/sdl/__init__.py | 4 ++-- pythonforandroid/toolchain.py | 21 ++++++++++++++----- 16 files changed, 39 insertions(+), 28 deletions(-) diff --git a/pythonforandroid/bootstraps/empty/__init__.py b/pythonforandroid/bootstraps/empty/__init__.py index 53f7334166..13742396dd 100644 --- a/pythonforandroid/bootstraps/empty/__init__.py +++ b/pythonforandroid/bootstraps/empty/__init__.py @@ -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, ArchAndroidARM, logger, info_main, which from os.path import join, exists from os import walk import glob diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index a0ddaac626..2c3e4db3b2 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -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, ArchAndroidARM, info_main from os.path import join, exists from os import walk import glob @@ -20,7 +20,7 @@ def run_distribute(self): src_path = join(self.bootstrap_dir, 'build') # AND: Hardcoding armeabi - naughty! - arch = ArchAndroid(self.ctx) + arch = ArchAndroidARM(self.ctx) with current_directory(self.dist_dir): diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index 10c9e0f118..7882722cc6 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -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, ArchAndroidARM, info_main from os.path import join, exists from os import walk import glob @@ -21,7 +21,7 @@ def run_distribute(self): fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) # AND: Hardcoding armeabi - naughty! - arch = ArchAndroid(self.ctx) + arch = ArchAndroidARM(self.ctx) with current_directory(self.dist_dir): info('Copying python distribution') diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index 4218e827be..14ec1f05bb 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -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, ArchAndroidARM, info_main from os.path import join, exists from os import walk import glob @@ -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 = ArchAndroidARM(self.ctx) with current_directory(self.dist_dir): info('Copying python distribution') diff --git a/pythonforandroid/recipes/android/__init__.py b/pythonforandroid/recipes/android/__init__.py index 2f669b5768..9411184220 100644 --- a/pythonforandroid/recipes/android/__init__.py +++ b/pythonforandroid/recipes/android/__init__.py @@ -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, ArchAndroidARM, IncludedFilesBehaviour import sh from os.path import exists, join diff --git a/pythonforandroid/recipes/freetype/__init__.py b/pythonforandroid/recipes/freetype/__init__.py index 94082d9834..1bc42e8f05 100644 --- a/pythonforandroid/recipes/freetype/__init__.py +++ b/pythonforandroid/recipes/freetype/__init__.py @@ -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, ArchAndroidARM from os.path import exists, join, realpath from os import uname import glob diff --git a/pythonforandroid/recipes/harfbuzz/__init__.py b/pythonforandroid/recipes/harfbuzz/__init__.py index 74f3489a29..9424cdd688 100644 --- a/pythonforandroid/recipes/harfbuzz/__init__.py +++ b/pythonforandroid/recipes/harfbuzz/__init__.py @@ -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, ArchAndroidARM from os.path import exists, join, realpath from os import uname import glob diff --git a/pythonforandroid/recipes/kivy/__init__.py b/pythonforandroid/recipes/kivy/__init__.py index f6add058c8..62a7e5808d 100644 --- a/pythonforandroid/recipes/kivy/__init__.py +++ b/pythonforandroid/recipes/kivy/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroid +from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroidARM from os.path import exists, join import sh import glob diff --git a/pythonforandroid/recipes/kivysdl2python3/__init__.py b/pythonforandroid/recipes/kivysdl2python3/__init__.py index 63778560ea..ae7bdfe9e5 100644 --- a/pythonforandroid/recipes/kivysdl2python3/__init__.py +++ b/pythonforandroid/recipes/kivysdl2python3/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroid +from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroidARM from os.path import exists, join import sh import glob @@ -35,7 +35,7 @@ def get_recipe_env(self, arch): return env # def build_armeabi(self): - # env = ArchAndroid(self.ctx).get_env() + # env = ArchAndroidARM(self.ctx).get_env() # env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(self.ctx.libs_dir) # env['LDSHARED'] = env['LIBLINK'] diff --git a/pythonforandroid/recipes/pygame/__init__.py b/pythonforandroid/recipes/pygame/__init__.py index 6fcf33b500..1b2afad7b1 100644 --- a/pythonforandroid/recipes/pygame/__init__.py +++ b/pythonforandroid/recipes/pygame/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, ArchAndroid, current_directory, debug, info, ensure_dir +from pythonforandroid.toolchain import Recipe, shprint, ArchAndroidARM, current_directory, debug, info, ensure_dir from os.path import exists, join import sh import glob @@ -40,7 +40,7 @@ def prebuild_armeabi(self): def build_armeabi(self): # AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now - arch = ArchAndroid(self.ctx) + arch = ArchAndroidARM(self.ctx) env = self.get_recipe_env(arch) env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format( diff --git a/pythonforandroid/recipes/pyjnius/__init__.py b/pythonforandroid/recipes/pyjnius/__init__.py index 5fa643fd69..47952bc8fb 100644 --- a/pythonforandroid/recipes/pyjnius/__init__.py +++ b/pythonforandroid/recipes/pyjnius/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroid, current_directory, info +from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroidARM, current_directory, info import sh import glob from os.path import join, exists diff --git a/pythonforandroid/recipes/pysdl2/__init__.py b/pythonforandroid/recipes/pysdl2/__init__.py index 2f872f0cef..843785d6d1 100644 --- a/pythonforandroid/recipes/pysdl2/__init__.py +++ b/pythonforandroid/recipes/pysdl2/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import PythonRecipe, shprint, current_directory, ArchAndroid +from pythonforandroid.toolchain import PythonRecipe, shprint, current_directory, ArchAndroidARM from os.path import exists, join import sh import glob diff --git a/pythonforandroid/recipes/python2/__init__.py b/pythonforandroid/recipes/python2/__init__.py index 41c12b2457..f03b38e716 100644 --- a/pythonforandroid/recipes/python2/__init__.py +++ b/pythonforandroid/recipes/python2/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroid, info +from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroidARM, info from os.path import exists, join, realpath from os import uname import glob @@ -92,7 +92,7 @@ def do_python_build(self): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') - env = ArchAndroid(self.ctx).get_env() + env = ArchAndroidARM(self.ctx).get_env() # AND: Should probably move these to get_recipe_env for # neatness, but the whole recipe needs tidying along these diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index 0fd3edcb15..4a3ea882c8 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -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, ArchAndroidARM from os.path import exists, join from os import uname import glob @@ -67,7 +67,7 @@ def build_armeabi(self): hostpython_recipe = Recipe.get_recipe('hostpython3', self.ctx) # shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') - env = ArchAndroid(self.ctx).get_env() + env = ArchAndroidARM(self.ctx).get_env() env["LDFLAGS"] = env["LDFLAGS"] + ' -llog' # AND: Should probably move these to get_recipe_env for diff --git a/pythonforandroid/recipes/sdl/__init__.py b/pythonforandroid/recipes/sdl/__init__.py index 1da3999d26..ed836817cc 100644 --- a/pythonforandroid/recipes/sdl/__init__.py +++ b/pythonforandroid/recipes/sdl/__init__.py @@ -1,4 +1,4 @@ -from pythonforandroid.toolchain import NDKRecipe, shprint, ArchAndroid, current_directory, info +from pythonforandroid.toolchain import NDKRecipe, shprint, ArchAndroidARM, current_directory, info from os.path import exists, join import sh @@ -15,7 +15,7 @@ def build_armeabi(self): info('libsdl.so already exists, skipping sdl build.') return - env = ArchAndroid(self.ctx).get_env() + env = ArchAndroidARM(self.ctx).get_env() with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, 'V=1', _env=env, _tail=20, _critical=True) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 3dbb16f9d7..1990709ca1 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -456,6 +456,13 @@ def include_dirs(self): d.format(arch=self)) for d in self.ctx.include_dirs] + def get_env(self): + raise ValueError('Tried to get_env of Arch, this needs ' + 'a specific Arch subclass') + +class ArchAndroidARM(Arch): + arch = "armeabi" + def get_env(self): include_dirs = [ "-I{}/{}".format( @@ -526,9 +533,13 @@ def get_env(self): return env +class ArchAndroidARMv7_a(ArchAndroidARM): + arch = 'armeabi-v7' -class ArchAndroid(Arch): - arch = "armeabi" + def get_env(self): + env = super(ArchAndroidARMv7_a, self).get_env() + env['CFLAGS'] = env['CFLAGS'] + ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb' + env['CXXFLAGS'] = env['CFLAGS'] # class ArchSimulator(Arch): # sdk = "iphonesimulator" @@ -1072,7 +1083,7 @@ def __init__(self): # AND: Currently only the Android architecture is supported self.archs = ( - ArchAndroid(self), + ArchAndroidARM(self), ) ensure_dir(join(self.build_dir, 'bootstrap_builds')) @@ -2446,8 +2457,8 @@ def biglink(ctx, arch): # AND: Shouldn't hardcode ArchAndroid! In reality need separate # build dirs for each arch - arch = ArchAndroid(ctx) - env = ArchAndroid(ctx).get_env() + arch = ArchAndroidARM(ctx) + env = ArchAndroidARM(ctx).get_env() env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( join(ctx.bootstrap.build_dir, 'obj', 'local', 'armeabi')) From 7934d5263cb2cf7d4ae190cb5babf95b959429cf Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 29 Nov 2015 01:32:42 +0000 Subject: [PATCH 02/29] Changed .mk files to check $ARCH correctly --- .../bootstraps/pygame/build/jni/application/Android.mk | 5 +++-- pythonforandroid/bootstraps/sdl2/build/jni/Application.mk | 2 +- pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk b/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk index 00adb4d9af..7d3adcce47 100644 --- a/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk +++ b/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk @@ -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 @@ -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 \ diff --git a/pythonforandroid/bootstraps/sdl2/build/jni/Application.mk b/pythonforandroid/bootstraps/sdl2/build/jni/Application.mk index 79b504d3f0..e79e378f94 100644 --- a/pythonforandroid/bootstraps/sdl2/build/jni/Application.mk +++ b/pythonforandroid/bootstraps/sdl2/build/jni/Application.mk @@ -4,4 +4,4 @@ # APP_STL := stlport_static # APP_ABI := armeabi armeabi-v7a x86 -APP_ABI := armeabi +APP_ABI := $(ARCH) diff --git a/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk b/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk index ec5eaa48ed..6cc877137b 100644 --- a/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk +++ b/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk @@ -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) From 88bcb5fd3d21d3985479f1715685a0cc58c742f3 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 29 Nov 2015 01:44:56 +0000 Subject: [PATCH 03/29] Renamed ArchAndroid<...> to Arch<...> ...since everything we target is naturally Android --- pythonforandroid/bootstraps/empty/__init__.py | 2 +- .../bootstraps/pygame/__init__.py | 4 ++-- pythonforandroid/bootstraps/sdl2/__init__.py | 4 ++-- .../bootstraps/sdl2python3/__init__.py | 4 ++-- pythonforandroid/recipes/android/__init__.py | 2 +- pythonforandroid/recipes/freetype/__init__.py | 2 +- pythonforandroid/recipes/harfbuzz/__init__.py | 2 +- pythonforandroid/recipes/kivy/__init__.py | 2 +- .../recipes/kivysdl2python3/__init__.py | 4 ++-- pythonforandroid/recipes/pygame/__init__.py | 4 ++-- pythonforandroid/recipes/pyjnius/__init__.py | 2 +- pythonforandroid/recipes/pysdl2/__init__.py | 2 +- pythonforandroid/recipes/python2/__init__.py | 4 ++-- pythonforandroid/recipes/python3/__init__.py | 4 ++-- pythonforandroid/recipes/sdl/__init__.py | 4 ++-- pythonforandroid/toolchain.py | 20 ++++++++++++------- 16 files changed, 36 insertions(+), 30 deletions(-) diff --git a/pythonforandroid/bootstraps/empty/__init__.py b/pythonforandroid/bootstraps/empty/__init__.py index 13742396dd..10137a78e8 100644 --- a/pythonforandroid/bootstraps/empty/__init__.py +++ b/pythonforandroid/bootstraps/empty/__init__.py @@ -1,4 +1,4 @@ -from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroidARM, 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 diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 2c3e4db3b2..ae89b353a8 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -1,4 +1,4 @@ -from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroidARM, 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 @@ -20,7 +20,7 @@ def run_distribute(self): src_path = join(self.bootstrap_dir, 'build') # AND: Hardcoding armeabi - naughty! - arch = ArchAndroidARM(self.ctx) + arch = ArchARM(self.ctx) with current_directory(self.dist_dir): diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index 7882722cc6..a72c78b0bd 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -1,4 +1,4 @@ -from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroidARM, 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 @@ -21,7 +21,7 @@ def run_distribute(self): fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) # AND: Hardcoding armeabi - naughty! - arch = ArchAndroidARM(self.ctx) + arch = ArchARM(self.ctx) with current_directory(self.dist_dir): info('Copying python distribution') diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index 14ec1f05bb..ae693e79eb 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -1,4 +1,4 @@ -from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroidARM, 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 @@ -23,7 +23,7 @@ def run_distribute(self): fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) # AND: Hardcoding armeabi - naughty! - arch = ArchAndroidARM(self.ctx) + arch = ArchARM(self.ctx) with current_directory(self.dist_dir): info('Copying python distribution') diff --git a/pythonforandroid/recipes/android/__init__.py b/pythonforandroid/recipes/android/__init__.py index 9411184220..00da87a001 100644 --- a/pythonforandroid/recipes/android/__init__.py +++ b/pythonforandroid/recipes/android/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import CythonRecipe, shprint, ensure_dir, current_directory, ArchAndroidARM, IncludedFilesBehaviour +from pythonforandroid.toolchain import CythonRecipe, shprint, ensure_dir, current_directory, ArchARM, IncludedFilesBehaviour import sh from os.path import exists, join diff --git a/pythonforandroid/recipes/freetype/__init__.py b/pythonforandroid/recipes/freetype/__init__.py index 1bc42e8f05..90cd312a1c 100644 --- a/pythonforandroid/recipes/freetype/__init__.py +++ b/pythonforandroid/recipes/freetype/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroidARM +from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchARM from os.path import exists, join, realpath from os import uname import glob diff --git a/pythonforandroid/recipes/harfbuzz/__init__.py b/pythonforandroid/recipes/harfbuzz/__init__.py index 9424cdd688..e6a77a60ef 100644 --- a/pythonforandroid/recipes/harfbuzz/__init__.py +++ b/pythonforandroid/recipes/harfbuzz/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroidARM +from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchARM from os.path import exists, join, realpath from os import uname import glob diff --git a/pythonforandroid/recipes/kivy/__init__.py b/pythonforandroid/recipes/kivy/__init__.py index 62a7e5808d..2430fa7aec 100644 --- a/pythonforandroid/recipes/kivy/__init__.py +++ b/pythonforandroid/recipes/kivy/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroidARM +from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchARM from os.path import exists, join import sh import glob diff --git a/pythonforandroid/recipes/kivysdl2python3/__init__.py b/pythonforandroid/recipes/kivysdl2python3/__init__.py index ae7bdfe9e5..22a2493294 100644 --- a/pythonforandroid/recipes/kivysdl2python3/__init__.py +++ b/pythonforandroid/recipes/kivysdl2python3/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroidARM +from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchARM from os.path import exists, join import sh import glob @@ -35,7 +35,7 @@ def get_recipe_env(self, arch): return env # def build_armeabi(self): - # env = ArchAndroidARM(self.ctx).get_env() + # env = ArchARM(self.ctx).get_env() # env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(self.ctx.libs_dir) # env['LDSHARED'] = env['LIBLINK'] diff --git a/pythonforandroid/recipes/pygame/__init__.py b/pythonforandroid/recipes/pygame/__init__.py index 1b2afad7b1..be6a32c293 100644 --- a/pythonforandroid/recipes/pygame/__init__.py +++ b/pythonforandroid/recipes/pygame/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, ArchAndroidARM, 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 @@ -40,7 +40,7 @@ def prebuild_armeabi(self): def build_armeabi(self): # AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now - arch = ArchAndroidARM(self.ctx) + arch = ArchARM(self.ctx) env = self.get_recipe_env(arch) env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format( diff --git a/pythonforandroid/recipes/pyjnius/__init__.py b/pythonforandroid/recipes/pyjnius/__init__.py index 47952bc8fb..173dbaaaff 100644 --- a/pythonforandroid/recipes/pyjnius/__init__.py +++ b/pythonforandroid/recipes/pyjnius/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroidARM, current_directory, info +from pythonforandroid.toolchain import CythonRecipe, shprint, ArchARM, current_directory, info import sh import glob from os.path import join, exists diff --git a/pythonforandroid/recipes/pysdl2/__init__.py b/pythonforandroid/recipes/pysdl2/__init__.py index 843785d6d1..cd22b639ea 100644 --- a/pythonforandroid/recipes/pysdl2/__init__.py +++ b/pythonforandroid/recipes/pysdl2/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import PythonRecipe, shprint, current_directory, ArchAndroidARM +from pythonforandroid.toolchain import PythonRecipe, shprint, current_directory, ArchARM from os.path import exists, join import sh import glob diff --git a/pythonforandroid/recipes/python2/__init__.py b/pythonforandroid/recipes/python2/__init__.py index f03b38e716..216ea4eb20 100644 --- a/pythonforandroid/recipes/python2/__init__.py +++ b/pythonforandroid/recipes/python2/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroidARM, info +from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchARM, info from os.path import exists, join, realpath from os import uname import glob @@ -92,7 +92,7 @@ def do_python_build(self): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') - env = ArchAndroidARM(self.ctx).get_env() + env = ArchARM(self.ctx).get_env() # AND: Should probably move these to get_recipe_env for # neatness, but the whole recipe needs tidying along these diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index 4a3ea882c8..f101d19f57 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchAndroidARM +from pythonforandroid.toolchain import Recipe, shprint, get_directory, current_directory, ArchARM from os.path import exists, join from os import uname import glob @@ -67,7 +67,7 @@ def build_armeabi(self): hostpython_recipe = Recipe.get_recipe('hostpython3', self.ctx) # shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') - env = ArchAndroidARM(self.ctx).get_env() + env = ArchARM(self.ctx).get_env() env["LDFLAGS"] = env["LDFLAGS"] + ' -llog' # AND: Should probably move these to get_recipe_env for diff --git a/pythonforandroid/recipes/sdl/__init__.py b/pythonforandroid/recipes/sdl/__init__.py index ed836817cc..dcb7d12818 100644 --- a/pythonforandroid/recipes/sdl/__init__.py +++ b/pythonforandroid/recipes/sdl/__init__.py @@ -1,4 +1,4 @@ -from pythonforandroid.toolchain import NDKRecipe, shprint, ArchAndroidARM, current_directory, info +from pythonforandroid.toolchain import NDKRecipe, shprint, ArchARM, current_directory, info from os.path import exists, join import sh @@ -15,7 +15,7 @@ def build_armeabi(self): info('libsdl.so already exists, skipping sdl build.') return - env = ArchAndroidARM(self.ctx).get_env() + env = ArchARM(self.ctx).get_env() with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, 'V=1', _env=env, _tail=20, _critical=True) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 1990709ca1..89c5e042cf 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -460,7 +460,7 @@ def get_env(self): raise ValueError('Tried to get_env of Arch, this needs ' 'a specific Arch subclass') -class ArchAndroidARM(Arch): +class ArchARM(Arch): arch = "armeabi" def get_env(self): @@ -533,14 +533,20 @@ def get_env(self): return env -class ArchAndroidARMv7_a(ArchAndroidARM): +class ArchARMv7_a(ArchARM): arch = 'armeabi-v7' def get_env(self): - env = super(ArchAndroidARMv7_a, self).get_env() + env = super(ArchARMv7_a, self).get_env() env['CFLAGS'] = env['CFLAGS'] + ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb' env['CXXFLAGS'] = env['CFLAGS'] +class Archx86(Arch): + arch = 'x86' + + def get_env(self): + raise ValueError('Archx86 not supported yet!') + # class ArchSimulator(Arch): # sdk = "iphonesimulator" # arch = "i386" @@ -1083,7 +1089,7 @@ def __init__(self): # AND: Currently only the Android architecture is supported self.archs = ( - ArchAndroidARM(self), + ArchARM(self), ) ensure_dir(join(self.build_dir, 'bootstrap_builds')) @@ -2455,10 +2461,10 @@ def biglink(ctx, arch): files.append(obj_dir) shprint(sh.cp, '-r', *files) - # AND: Shouldn't hardcode ArchAndroid! In reality need separate + # AND: Shouldn't hardcode Arch! In reality need separate # build dirs for each arch - arch = ArchAndroidARM(ctx) - env = ArchAndroidARM(ctx).get_env() + arch = ArchARM(ctx) + env = ArchARM(ctx).get_env() env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( join(ctx.bootstrap.build_dir, 'obj', 'local', 'armeabi')) From 9af971f328786310307826a048a2acf610769bd0 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 29 Nov 2015 21:02:38 +0000 Subject: [PATCH 04/29] Added Arch specification support (hackily) --- pythonforandroid/toolchain.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 89c5e042cf..774a871333 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -290,6 +290,7 @@ def wrapper_func(self, args): user_ndk_dir=self.ndk_dir, user_android_api=self.android_api, user_ndk_ver=self.ndk_version) + ctx.set_archs(self.archs) dist = self._dist if dist.needs_build: info_notify('No dist exists that meets your requirements, ' @@ -1087,9 +1088,11 @@ def __init__(self): # root of the toolchain self.setup_dirs() - # AND: Currently only the Android architecture is supported + # this list should contain all Archs, it is pruned later self.archs = ( ArchARM(self), + ArchARMv7_a(self), + Archx86(self) ) ensure_dir(join(self.build_dir, 'bootstrap_builds')) @@ -1104,6 +1107,22 @@ def __init__(self): # set the state self.state = JsonStore(join(self.dist_dir, "state.db")) + def set_archs(self, arch_names): + all_archs = self.archs + new_archs = set() + for name in arch_names: + matching = [arch for arch in all_archs if arch.arch == name] + for match in matching: + new_archs.add(match) + self.archs = list(new_archs) + if not self.archs: + warning('Asked to compile for no Archs, so failing.') + exit(1) + info('Will compile for the following archs: {}'.format( + ', '.join([arch.arch for arch in self.archs]))) + exit(1) + + def prepare_bootstrap(self, bs): bs.ctx = self self.bootstrap = bs @@ -2771,6 +2790,14 @@ def __init__(self): help=('The version of the Android NDK. This is optional, ' 'we try to work it out automatically from the ndk_dir.')) + + # AND: This option doesn't really fit in the other categories, the + # arg structure needs a rethink + parser.add_argument( + '--arch', + help='The archs to build for, separated by commas.', + default='armeabi') + # Options for specifying the Distribution parser.add_argument( '--dist_name', @@ -2808,6 +2835,7 @@ def __init__(self): description=('Whether the dist recipes must perfectly match ' 'those requested')) + self._read_configuration() args, unknown = parser.parse_known_args(sys.argv[1:]) @@ -2820,8 +2848,8 @@ def __init__(self): self.android_api = args.android_api self.ndk_version = args.ndk_version - # import ipdb - # ipdb.set_trace() + self.archs = split_argument_list(args.arch) + # AND: Fail nicely if the args aren't handled yet if args.extra_dist_dirs: warning('Received --extra_dist_dirs but this arg currently is not ' From b9e6e5257b6e261e72645812ebc06315f4d55d7f Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 29 Nov 2015 22:23:18 +0000 Subject: [PATCH 05/29] Fixed hostpython2 recipe to ignore arch Since this is always built for the desktop, we don't need multiple targets --- .../recipes/hostpython2/__init__.py | 22 +++++++++++++------ pythonforandroid/toolchain.py | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/pythonforandroid/recipes/hostpython2/__init__.py b/pythonforandroid/recipes/hostpython2/__init__.py index 3f8d974c14..5b775f2850 100644 --- a/pythonforandroid/recipes/hostpython2/__init__.py +++ b/pythonforandroid/recipes/hostpython2/__init__.py @@ -12,24 +12,32 @@ 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): + def build_arch(self, arch): # AND: Should use an i386 recipe system warning('Running hostpython build. Arch is armeabi! ' 'This is naughty, need to fix the Arch system!') # AND: Fix armeabi again - with current_directory(self.get_build_dir('armeabi')): + 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 @@ -49,8 +57,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() diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 774a871333..6f1f14e60e 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -72,6 +72,8 @@ def __getattr__(self, key): else: Err_Style = Null_Style Err_Fore = Null_Fore +Fore = Colo_Fore +Style = Colo_Style user_dir = dirname(realpath(os.path.curdir)) toolchain_dir = dirname(__file__) @@ -1120,8 +1122,6 @@ def set_archs(self, arch_names): exit(1) info('Will compile for the following archs: {}'.format( ', '.join([arch.arch for arch in self.archs]))) - exit(1) - def prepare_bootstrap(self, bs): bs.ctx = self From 0194a234e84f2b628f9b8ea2f28fffc75f2ca5c0 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 29 Nov 2015 22:56:59 +0000 Subject: [PATCH 06/29] Changed apply_patch to pass arch argument --- pythonforandroid/recipes/numpy/__init__.py | 8 +-- pythonforandroid/recipes/pygame/__init__.py | 6 +- pythonforandroid/recipes/pyjnius/__init__.py | 2 +- .../recipes/pyopenssl/__init__.py | 2 +- pythonforandroid/recipes/python2/__init__.py | 68 ++++++++++--------- pythonforandroid/recipes/python3/__init__.py | 35 +++++----- pythonforandroid/recipes/sdl2/__init__.py | 2 +- .../recipes/sdl2_image/__init__.py | 2 +- .../recipes/sdl2_mixer/__init__.py | 3 +- .../recipes/sdl2python3/__init__.py | 2 +- pythonforandroid/recipes/vispy/__init__.py | 12 ++-- pythonforandroid/toolchain.py | 2 +- 12 files changed, 74 insertions(+), 70 deletions(-) diff --git a/pythonforandroid/recipes/numpy/__init__.py b/pythonforandroid/recipes/numpy/__init__.py index 01cb0acba7..5c8ae5d0a9 100644 --- a/pythonforandroid/recipes/numpy/__init__.py +++ b/pythonforandroid/recipes/numpy/__init__.py @@ -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 ' diff --git a/pythonforandroid/recipes/pygame/__init__.py b/pythonforandroid/recipes/pygame/__init__.py index be6a32c293..f4ae1e6811 100644 --- a/pythonforandroid/recipes/pygame/__init__.py +++ b/pythonforandroid/recipes/pygame/__init__.py @@ -32,9 +32,9 @@ def prebuild_armeabi(self): 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')) + 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('armeabi'), '.patched')) def build_armeabi(self): diff --git a/pythonforandroid/recipes/pyjnius/__init__.py b/pythonforandroid/recipes/pyjnius/__init__.py index 173dbaaaff..7ef1709c51 100644 --- a/pythonforandroid/recipes/pyjnius/__init__.py +++ b/pythonforandroid/recipes/pyjnius/__init__.py @@ -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): diff --git a/pythonforandroid/recipes/pyopenssl/__init__.py b/pythonforandroid/recipes/pyopenssl/__init__.py index fe3c995ac0..452ae85a46 100644 --- a/pythonforandroid/recipes/pyopenssl/__init__.py +++ b/pythonforandroid/recipes/pyopenssl/__init__.py @@ -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): diff --git a/pythonforandroid/recipes/python2/__init__.py b/pythonforandroid/recipes/python2/__init__.py index 216ea4eb20..c050e552e3 100644 --- a/pythonforandroid/recipes/python2/__init__.py +++ b/pythonforandroid/recipes/python2/__init__.py @@ -15,44 +15,46 @@ class Python2Recipe(Recipe): conflicts = ['python3'] opt_depends = ['openssl'] - def prebuild_armeabi(self): - build_dir = self.get_build_container_dir('armeabi') + def prebuild_arch(self, arch): + build_dir = self.get_build_container_dir(arch.arch) if exists(join(build_dir, '.patched')): info('Python2 already patched, skipping.') return - self.apply_patch(join('patches', 'Python-{}-xcompile.patch'.format(self.version))) - self.apply_patch(join('patches', 'Python-{}-ctypes-disable-wchar.patch'.format(self.version))) - self.apply_patch(join('patches', 'disable-modules.patch')) - self.apply_patch(join('patches', 'fix-locale.patch')) - self.apply_patch(join('patches', 'fix-gethostbyaddr.patch')) - self.apply_patch(join('patches', 'fix-setup-flags.patch')) - self.apply_patch(join('patches', 'fix-filesystemdefaultencoding.patch')) - self.apply_patch(join('patches', 'fix-termios.patch')) - self.apply_patch(join('patches', 'custom-loader.patch')) - self.apply_patch(join('patches', 'verbose-compilation.patch')) - self.apply_patch(join('patches', 'fix-remove-corefoundation.patch')) - self.apply_patch(join('patches', 'fix-dynamic-lookup.patch')) - self.apply_patch(join('patches', 'fix-dlfcn.patch')) - self.apply_patch(join('patches', 'parsetuple.patch')) - # self.apply_patch(join('patches', 'ctypes-find-library.patch')) - self.apply_patch(join('patches', 'ctypes-find-library-updated.patch')) + self.apply_patch(join('patches', 'Python-{}-xcompile.patch'.format(self.version)), + arch.arch) + self.apply_patch(join('patches', 'Python-{}-ctypes-disable-wchar.patch'.format(self.version)), + arch.arch) + self.apply_patch(join('patches', 'disable-modules.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-locale.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-gethostbyaddr.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-setup-flags.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-filesystemdefaultencoding.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-termios.patch'), arch.arch) + self.apply_patch(join('patches', 'custom-loader.patch'), arch.arch) + self.apply_patch(join('patches', 'verbose-compilation.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-remove-corefoundation.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-dynamic-lookup.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-dlfcn.patch'), arch.arch) + self.apply_patch(join('patches', 'parsetuple.patch'), arch.arch) + # self.apply_patch(join('patches', 'ctypes-find-library.patch'), arch.arch) + self.apply_patch(join('patches', 'ctypes-find-library-updated.patch'), arch.arch) if uname()[0] == 'Linux': - self.apply_patch(join('patches', 'fix-configure-darwin.patch')) - self.apply_patch(join('patches', 'fix-distutils-darwin.patch')) + self.apply_patch(join('patches', 'fix-configure-darwin.patch'), arch.arch) + self.apply_patch(join('patches', 'fix-distutils-darwin.patch'), arch.arch) if self.ctx.android_api > 19: - self.apply_patch(join('patches', 'fix-ftime-removal.patch')) + self.apply_patch(join('patches', 'fix-ftime-removal.patch'), arch.arch) shprint(sh.touch, join(build_dir, '.patched')) - def build_armeabi(self): + def build_arch(self, arch): - if not exists(join(self.get_build_dir('armeabi'), 'libpython2.7.so')): + if not exists(join(self.get_build_dir(arch.arch), 'libpython2.7.so')): self.do_python_build() if not exists(self.ctx.get_python_install_dir()): - shprint(sh.cp, '-a', join(self.get_build_dir('armeabi'), 'python-install'), + shprint(sh.cp, '-a', join(self.get_build_dir(arch.arch), 'python-install'), self.ctx.get_python_install_dir()) # This should be safe to run every time @@ -61,11 +63,11 @@ def build_armeabi(self): join(self.ctx.get_python_install_dir(), 'bin', 'python.host')) self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host') - if not exists(join(self.ctx.get_libs_dir('armeabi'), 'libpython2.7.so')): - shprint(sh.cp, join(self.get_build_dir('armeabi'), 'libpython2.7.so'), self.ctx.get_libs_dir('armeabi')) + if not exists(join(self.ctx.get_libs_dir(arch.arch), 'libpython2.7.so')): + shprint(sh.cp, join(self.get_build_dir(arch.arch), 'libpython2.7.so'), self.ctx.get_libs_dir(arch.arch)) - # # if exists(join(self.get_build_dir('armeabi'), 'libpython2.7.so')): + # # if exists(join(self.get_build_dir(arch.arch), 'libpython2.7.so')): # if exists(join(self.ctx.libs_dir, 'libpython2.7.so')): # info('libpython2.7.so already exists, skipping python build.') # if not exists(join(self.ctx.get_python_install_dir(), 'libpython2.7.so')): @@ -81,12 +83,12 @@ def do_python_build(self): exit(1) hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) - shprint(sh.cp, self.ctx.hostpython, self.get_build_dir('armeabi')) - shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir('armeabi')) - hostpython = join(self.get_build_dir('armeabi'), 'hostpython') - hostpgen = join(self.get_build_dir('armeabi'), 'hostpython') + shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch)) + shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir(arch.arch)) + hostpython = join(self.get_build_dir(arch.arch), 'hostpython') + hostpgen = join(self.get_build_dir(arch.arch), 'hostpython') - with current_directory(self.get_build_dir('armeabi')): + with current_directory(self.get_build_dir(arch.arch)): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) @@ -104,7 +106,7 @@ def do_python_build(self): # TODO need to add a should_build that checks if optional # dependencies have changed (possibly in a generic way) if 'openssl' in self.ctx.recipe_build_order: - openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir('armeabi') + openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) env['CFLAGS'] = ' '.join([env['CFLAGS'], '-I{}'.format(join(openssl_build_dir, 'include'))]) env['LDFLAGS'] = ' '.join([env['LDFLAGS'], diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index f101d19f57..3bb7d84199 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -13,8 +13,8 @@ class Python3Recipe(Recipe): depends = ['hostpython3'] conflicts = ['python2'] - def prebuild_armeabi(self): - build_dir = self.get_build_container_dir('armeabi') + def prebuild_arch(self, arch): + build_dir = self.get_build_container_dir(arch.arch) if exists(join(build_dir, '.patched')): print('Python3 already patched, skipping.') return @@ -30,38 +30,39 @@ def prebuild_armeabi(self): # 'python-{version}-locale_and_android_misc.patch'.format(version=self.version))) - self.apply_patch(join('patches', 'python-{version}-android-libmpdec.patch'.format(version=self.version))) - self.apply_patch(join('patches', 'python-{version}-android-locale.patch'.format(version=self.version))) - self.apply_patch(join('patches', 'python-{version}-android-misc.patch'.format(version=self.version))) - # self.apply_patch(join('patches', 'python-{version}-android-missing-getdents64-definition.patch'.format(version=self.version))) - self.apply_patch(join('patches', 'python-{version}-cross-compile.patch'.format(version=self.version))) - self.apply_patch(join('patches', 'python-{version}-python-misc.patch'.format(version=self.version))) + self.apply_patch(join('patches', 'python-{version}-android-libmpdec.patch'.format(version=self.version)), + arch.arch) + self.apply_patch(join('patches', 'python-{version}-android-locale.patch'.format(version=self.version)), arch.arch) + self.apply_patch(join('patches', 'python-{version}-android-misc.patch'.format(version=self.version)), arch.arch) + # self.apply_patch(join('patches', 'python-{version}-android-missing-getdents64-definition.patch'.format(version=self.version)), arch.arch) + self.apply_patch(join('patches', 'python-{version}-cross-compile.patch'.format(version=self.version)), arch.arch) + self.apply_patch(join('patches', 'python-{version}-python-misc.patch'.format(version=self.version)), arch.arch) - self.apply_patch(join('patches', 'python-{version}-libpymodules_loader.patch'.format(version=self.version))) - self.apply_patch('log_failures.patch') + self.apply_patch(join('patches', 'python-{version}-libpymodules_loader.patch'.format(version=self.version)), arch.arch) + self.apply_patch('log_failures.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched')) - def build_armeabi(self): + def build_arch(self, arch): if 'sqlite' in self.ctx.recipe_build_order or 'openssl' in self.ctx.recipe_build_order: print('sqlite or openssl support not yet enabled in python recipe') exit(1) hostpython_recipe = Recipe.get_recipe('hostpython3', self.ctx) - shprint(sh.cp, self.ctx.hostpython, self.get_build_dir('armeabi')) - shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir('armeabi')) - hostpython = join(self.get_build_dir('armeabi'), 'hostpython') - hostpgen = join(self.get_build_dir('armeabi'), 'hostpython') + shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch)) + shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir(arch.arch)) + hostpython = join(self.get_build_dir(arch.arch), 'hostpython') + hostpgen = join(self.get_build_dir(arch.arch), 'hostpython') - if exists(join(self.get_build_dir('armeabi'), 'libpython3.4m.so')): + if exists(join(self.get_build_dir(arch.arch), 'libpython3.4m.so')): print('libpython3.4m.so already exists, skipping python build.') self.ctx.hostpython = join(self.ctx.build_dir, 'python-install', 'bin', 'python.host') return - with current_directory(self.get_build_dir('armeabi')): + with current_directory(self.get_build_dir(arch.arch)): hostpython_recipe = Recipe.get_recipe('hostpython3', self.ctx) diff --git a/pythonforandroid/recipes/sdl2/__init__.py b/pythonforandroid/recipes/sdl2/__init__.py index aeb436915b..9edec09842 100644 --- a/pythonforandroid/recipes/sdl2/__init__.py +++ b/pythonforandroid/recipes/sdl2/__init__.py @@ -18,7 +18,7 @@ def prebuild_arch(self, arch): if exists(join(build_dir, '.patched')): info('SDL2 already patched, skipping') return - self.apply_patch('add_nativeSetEnv.patch') + self.apply_patch('add_nativeSetEnv.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched')) def build_arch(self, arch): diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index e4444ba0a3..000d863b21 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -13,7 +13,7 @@ def prebuild_arch(self, arch): if exists(join(build_dir, '.patched')): info('SDL2_image already patched, skipping') return - self.apply_patch('disable_webp.patch') + self.apply_patch('disable_webp.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched')) recipe = LibSDL2Image() diff --git a/pythonforandroid/recipes/sdl2_mixer/__init__.py b/pythonforandroid/recipes/sdl2_mixer/__init__.py index d832fd8437..8788330363 100644 --- a/pythonforandroid/recipes/sdl2_mixer/__init__.py +++ b/pythonforandroid/recipes/sdl2_mixer/__init__.py @@ -14,7 +14,8 @@ def prebuild_arch(self, arch): if exists(join(build_dir, '.patched')): info('SDL2_mixer already patched, skipping') return - self.apply_patch('disable_modplug_mikmod_smpeg.patch') + self.apply_patch('disable_modplug_mikmod_smpeg.patch', + arch.arch) shprint(sh.touch, join(build_dir, '.patched')) recipe = LibSDL2Mixer() diff --git a/pythonforandroid/recipes/sdl2python3/__init__.py b/pythonforandroid/recipes/sdl2python3/__init__.py index 7e3b6f9ccf..8c51684c9d 100644 --- a/pythonforandroid/recipes/sdl2python3/__init__.py +++ b/pythonforandroid/recipes/sdl2python3/__init__.py @@ -17,7 +17,7 @@ def prebuild_arch(self, arch): if exists(join(build_dir, '.patched')): print('SDL2 already patched, skipping') return - self.apply_patch('add_nativeSetEnv.patch') + self.apply_patch('add_nativeSetEnv.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched')) def build_arch(self, arch): diff --git a/pythonforandroid/recipes/vispy/__init__.py b/pythonforandroid/recipes/vispy/__init__.py index cf1b814ded..130a500009 100644 --- a/pythonforandroid/recipes/vispy/__init__.py +++ b/pythonforandroid/recipes/vispy/__init__.py @@ -22,13 +22,13 @@ def prebuild_arch(self, arch): if exists(join(build_dir, '.patched')): print('vispy already patched, skipping') return - self.apply_patch('disable_freetype.patch') - self.apply_patch('disable_font_triage.patch') - self.apply_patch('use_es2.patch') - self.apply_patch('remove_ati_check.patch') + self.apply_patch('disable_freetype.patch', arch.arch) + self.apply_patch('disable_font_triage.patch', arch.arch) + self.apply_patch('use_es2.patch', arch.arch) + self.apply_patch('remove_ati_check.patch', arch.arch) - self.apply_patch('make_shader_es2_compliant.patch') - self.apply_patch('detect_finger_events.patch') + self.apply_patch('make_shader_es2_compliant.patch', arch.arch) + self.apply_patch('detect_finger_events.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched')) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 6f1f14e60e..14c60155f9 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -1716,7 +1716,7 @@ def extract_source(self, source, cwd): # print("Unrecognized extension for {}".format(filename)) # raise Exception() - def apply_patch(self, filename, arch='armeabi'): + def apply_patch(self, filename, arch): """ Apply a patch from the current recipe directory into the current build directory. From 480fb468444e1ce3bd16853bd2919b4bfabb9f07 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 29 Nov 2015 23:43:41 +0000 Subject: [PATCH 07/29] Added get_env for different arch types --- pythonforandroid/toolchain.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 14c60155f9..26e720148d 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -459,13 +459,6 @@ def include_dirs(self): d.format(arch=self)) for d in self.ctx.include_dirs] - def get_env(self): - raise ValueError('Tried to get_env of Arch, this needs ' - 'a specific Arch subclass') - -class ArchARM(Arch): - arch = "armeabi" - def get_env(self): include_dirs = [ "-I{}/{}".format( @@ -536,6 +529,9 @@ def get_env(self): return env +class ArchARM(Arch): + arch = "armeabi" + class ArchARMv7_a(ArchARM): arch = 'armeabi-v7' @@ -548,7 +544,19 @@ class Archx86(Arch): arch = 'x86' def get_env(self): - raise ValueError('Archx86 not supported yet!') + env = super(ArchARMv7_a, self).get_env() + env['CFLAGS'] = env['CFLAGS'] + ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32' + env['CXXFLAGS'] = env['CFLAGS'] + return env + +class Archx86_64(Arch): + arch = 'x86_64' + + def get_env(self): + env = super(ArchARMv7_a, self).get_env() + env['CFLAGS'] = env['CFLAGS'] + ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel' + env['CXXFLAGS'] = env['CFLAGS'] + return env # class ArchSimulator(Arch): # sdk = "iphonesimulator" From 1bec42fdbcc45a751e5541dfa2c909a0ec0efd9d Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 30 Nov 2015 21:20:20 +0000 Subject: [PATCH 08/29] Fixed arch pass-through in more places --- pythonforandroid/recipes/python2/__init__.py | 4 ++-- pythonforandroid/toolchain.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pythonforandroid/recipes/python2/__init__.py b/pythonforandroid/recipes/python2/__init__.py index c050e552e3..1f5e34609a 100644 --- a/pythonforandroid/recipes/python2/__init__.py +++ b/pythonforandroid/recipes/python2/__init__.py @@ -51,7 +51,7 @@ def prebuild_arch(self, arch): def build_arch(self, arch): if not exists(join(self.get_build_dir(arch.arch), 'libpython2.7.so')): - self.do_python_build() + self.do_python_build(arch) if not exists(self.ctx.get_python_install_dir()): shprint(sh.cp, '-a', join(self.get_build_dir(arch.arch), 'python-install'), @@ -77,7 +77,7 @@ def build_arch(self, arch): # return - def do_python_build(self): + def do_python_build(self, arch): if 'sqlite' in self.ctx.recipe_build_order: print('sqlite support not yet enabled in python recipe') exit(1) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 26e720148d..2e70f52632 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -533,12 +533,13 @@ class ArchARM(Arch): arch = "armeabi" class ArchARMv7_a(ArchARM): - arch = 'armeabi-v7' + arch = 'armeabi-v7a' def get_env(self): env = super(ArchARMv7_a, self).get_env() env['CFLAGS'] = env['CFLAGS'] + ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb' env['CXXFLAGS'] = env['CFLAGS'] + return env class Archx86(Arch): arch = 'x86' @@ -1918,7 +1919,7 @@ def unpack(self, arch): ensure_dir(build_dir) # shprint(sh.ln, '-s', user_dir, # join(build_dir, get_directory(self.versioned_url))) - shprint(sh.git, 'clone', user_dir, self.get_build_dir('armeabi')) + shprint(sh.git, 'clone', user_dir, self.get_build_dir(arch)) return if self.url is None: @@ -2225,16 +2226,16 @@ def build_arch(self, arch): '''Install the Python module by calling setup.py install with the target Python dir.''' super(PythonRecipe, self).build_arch(arch) - self.install_python_package() + self.install_python_package(arch) # @cache_execution # def install(self): # self.install_python_package() # self.reduce_python_package() - def install_python_package(self, name=None, env=None, is_dir=True): + def install_python_package(self, arch, name=None, env=None, is_dir=True): '''Automate the installation of a Python package (or a cython package where the cython components are pre-built).''' - arch = self.filtered_archs[0] + # arch = self.filtered_archs[0] # old kivy-ios way if name is None: name = self.name if env is None: @@ -2276,7 +2277,7 @@ def build_arch(self, arch): # # after everything else but isn't # # used by a normal recipe. self.build_compiled_components(arch) - self.install_python_package() + self.install_python_package(arch) def build_compiled_components(self, arch): info('Building compiled components in {}'.format(self.name)) @@ -2305,7 +2306,7 @@ def build_arch(self, arch): # # after everything else but isn't # # used by a normal recipe. self.build_cython_components(arch) - self.install_python_package() + self.install_python_package(arch) def build_cython_components(self, arch): # AND: Should we use tito's cythonize methods? How do they work? @@ -2322,7 +2323,7 @@ def build_cython_components(self, arch): info('{} first build failed (as expected)'.format(self.name)) info('Running cython where appropriate') - shprint(sh.find, self.get_build_dir('armeabi'), '-iname', '*.pyx', + shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx', '-exec', self.ctx.cython, '{}', ';', _env=env) info('ran cython') @@ -2490,6 +2491,7 @@ def biglink(ctx, arch): # AND: Shouldn't hardcode Arch! In reality need separate # build dirs for each arch + raise ValueError('hardcoded Arch to fix!') arch = ArchARM(ctx) env = ArchARM(ctx).get_env() env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( From 87dac5f3162858a12299efc2dc862f8f5a52b810 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 30 Nov 2015 21:27:48 +0000 Subject: [PATCH 09/29] Removed more hardcoded 'armeabi' archs --- pythonforandroid/toolchain.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 2e70f52632..96099bfb08 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -515,7 +515,7 @@ def get_env(self): # AND: This also hardcodes armeabi, which isn't even correct, # don't forget to fix! env['BUILDLIB_PATH'] = join( - hostpython_recipe.get_build_dir('armeabi'), + hostpython_recipe.get_build_dir(self.arch), 'build', 'lib.linux-{}-2.7'.format(uname()[-1])) env['PATH'] = environ['PATH'] @@ -1839,12 +1839,6 @@ def get_recipe_dir(self): # Public Recipe API to be subclassed if needed - def ensure_build_container_dir(self): - info_main('Preparing build dir for {}'.format(self.name)) - - build_dir = self.get_build_container_dir('armeabi') - ensure_dir(build_dir) - def download_if_necessary(self): info_main('Downloading {}'.format(self.name)) user_dir = environ.get('P4A_{}_DIR'.format(self.name.lower())) @@ -2204,8 +2198,8 @@ class PythonRecipe(Recipe): def hostpython_location(self): if not self.call_hostpython_via_targetpython: return join( - Recipe.get_recipe('hostpython2', self.ctx).get_build_dir( - 'armeabi'), 'hostpython') + Recipe.get_recipe('hostpython2', self.ctx).get_build_dir(), + 'hostpython') return self.ctx.hostpython def should_build(self): @@ -2495,7 +2489,7 @@ def biglink(ctx, arch): arch = ArchARM(ctx) env = ArchARM(ctx).get_env() env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( - join(ctx.bootstrap.build_dir, 'obj', 'local', 'armeabi')) + join(ctx.bootstrap.build_dir, 'obj', 'local', arch.arch)) if not len(glob.glob(join(obj_dir, '*'))): info('There seem to be no libraries to biglink, skipping.') @@ -2507,7 +2501,7 @@ def biglink(ctx, arch): join(ctx.get_libs_dir(arch.arch), 'libpymodules.so'), obj_dir.split(' '), extra_link_dirs=[join(ctx.bootstrap.build_dir, - 'obj', 'local', 'armeabi')], + 'obj', 'local', arch.arch)], env=env) From 7174dfe82a1828067aa10a157b42a0af5a49e0b3 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 30 Nov 2015 22:19:00 +0000 Subject: [PATCH 10/29] More fixes to hardcoded armeabi Build works with armeabi-v7a now --- pythonforandroid/bootstraps/sdl2/__init__.py | 10 ++++++---- pythonforandroid/toolchain.py | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index a72c78b0bd..ff9c9eac96 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -21,7 +21,10 @@ def run_distribute(self): fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) # AND: Hardcoding armeabi - naughty! - arch = ArchARM(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') @@ -32,7 +35,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) @@ -50,8 +52,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') diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 96099bfb08..8a3deed4ee 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -2485,9 +2485,7 @@ def biglink(ctx, arch): # AND: Shouldn't hardcode Arch! In reality need separate # build dirs for each arch - raise ValueError('hardcoded Arch to fix!') - arch = ArchARM(ctx) - env = ArchARM(ctx).get_env() + env = arch.get_env() env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( join(ctx.bootstrap.build_dir, 'obj', 'local', arch.arch)) From cb456938c56385125df6b69baf479f51285e4c2a Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 30 Nov 2015 23:01:15 +0000 Subject: [PATCH 11/29] Fixed inheritance of non-ARM Archs --- pythonforandroid/toolchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 8a3deed4ee..1c858699b7 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -545,7 +545,7 @@ class Archx86(Arch): arch = 'x86' def get_env(self): - env = super(ArchARMv7_a, self).get_env() + env = super(Archx86, self).get_env() env['CFLAGS'] = env['CFLAGS'] + ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32' env['CXXFLAGS'] = env['CFLAGS'] return env @@ -554,7 +554,7 @@ class Archx86_64(Arch): arch = 'x86_64' def get_env(self): - env = super(ArchARMv7_a, self).get_env() + env = super(Archx86_64, self).get_env() env['CFLAGS'] = env['CFLAGS'] + ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel' env['CXXFLAGS'] = env['CFLAGS'] return env From f8eb278e7fb285961a837754aea722d9b38383cc Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 30 Nov 2015 23:03:04 +0000 Subject: [PATCH 12/29] Added temporary jpg disable for sdl_image x86 --- pythonforandroid/recipes/sdl2_image/__init__.py | 1 + .../recipes/sdl2_image/disable_jpg.patch | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 pythonforandroid/recipes/sdl2_image/disable_jpg.patch diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index 000d863b21..8dac117e02 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -14,6 +14,7 @@ def prebuild_arch(self, arch): info('SDL2_image already patched, skipping') return self.apply_patch('disable_webp.patch', arch.arch) + self.apply_patch('disable_jpg.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched')) recipe = LibSDL2Image() diff --git a/pythonforandroid/recipes/sdl2_image/disable_jpg.patch b/pythonforandroid/recipes/sdl2_image/disable_jpg.patch new file mode 100644 index 0000000000..2b5fc38280 --- /dev/null +++ b/pythonforandroid/recipes/sdl2_image/disable_jpg.patch @@ -0,0 +1,13 @@ +diff --git a/Android.mk b/Android.mk +index 31e2118..8cd2cb9 100644 +--- a/Android.mk ++++ b/Android.mk +@@ -6,7 +6,7 @@ LOCAL_MODULE := SDL2_image + + # Enable this if you want to support loading JPEG images + # The library path should be a relative path to this directory. +-SUPPORT_JPG := true ++SUPPORT_JPG := false + JPG_LIBRARY_PATH := external/jpeg-9 + + # Enable this if you want to support loading PNG images From 53e063422107af17e5187dcfcd574b26d0bbd8d3 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 30 Nov 2015 23:04:05 +0000 Subject: [PATCH 13/29] Made jpg disable only occur with x86 build --- pythonforandroid/recipes/sdl2_image/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index 8dac117e02..8265d4ec88 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -14,7 +14,8 @@ def prebuild_arch(self, arch): info('SDL2_image already patched, skipping') return self.apply_patch('disable_webp.patch', arch.arch) - self.apply_patch('disable_jpg.patch', arch.arch) + if arch.arch == 'x86': + self.apply_patch('disable_jpg.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched')) recipe = LibSDL2Image() From d44be857c570612215a999a43c6a96c5398ab5cd Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 30 Nov 2015 23:13:14 +0000 Subject: [PATCH 14/29] Fixed armeabi hardcoding in pygame bootstrap --- pythonforandroid/bootstraps/pygame/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index ae89b353a8..be2589364e 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -19,8 +19,10 @@ def run_distribute(self): # self.name) src_path = join(self.bootstrap_dir, 'build') - # AND: Hardcoding armeabi - naughty! - arch = ArchARM(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): @@ -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') From 764ab7af459626f00eb7134f18f7383e46dae260 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Fri, 4 Dec 2015 21:24:45 +0000 Subject: [PATCH 15/29] Fixed $ARCH reference in pygame Android.mk --- .../bootstraps/pygame/build/jni/application/Android.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk b/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk index 7d3adcce47..75fb5d5ff5 100644 --- a/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk +++ b/pythonforandroid/bootstraps/pygame/build/jni/application/Android.mk @@ -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/$ARCH/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 @@ -40,7 +40,7 @@ LOCAL_LDLIBS := -lpython2.7 -lGLESv1_CM -ldl -llog -lz # AND: Another hardcoded path that should be templated # AND: NOT TEMPALTED! We can use $ARCH -LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../../../other_builds/python2/$ARCH/python2/python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS) +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 \ From 13e850127f6f23380f44eabf7ca7e0c3a97c59c3 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 00:26:33 +0000 Subject: [PATCH 16/29] Removed more hardcoded Archs --- pythonforandroid/recipes/pygame/__init__.py | 13 ++++++------- pythonforandroid/recipes/python2/__init__.py | 2 +- pythonforandroid/recipes/sdl/__init__.py | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pythonforandroid/recipes/pygame/__init__.py b/pythonforandroid/recipes/pygame/__init__.py index f4ae1e6811..231563ef80 100644 --- a/pythonforandroid/recipes/pygame/__init__.py +++ b/pythonforandroid/recipes/pygame/__init__.py @@ -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')) + 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('armeabi'), '.patched')) + 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 = ArchARM(self.ctx) env = self.get_recipe_env(arch) env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format( @@ -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, diff --git a/pythonforandroid/recipes/python2/__init__.py b/pythonforandroid/recipes/python2/__init__.py index 1f5e34609a..4e49a4fa5a 100644 --- a/pythonforandroid/recipes/python2/__init__.py +++ b/pythonforandroid/recipes/python2/__init__.py @@ -94,7 +94,7 @@ def do_python_build(self, arch): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') - env = ArchARM(self.ctx).get_env() + env = arch.get_env() # AND: Should probably move these to get_recipe_env for # neatness, but the whole recipe needs tidying along these diff --git a/pythonforandroid/recipes/sdl/__init__.py b/pythonforandroid/recipes/sdl/__init__.py index dcb7d12818..a8044f65e2 100644 --- a/pythonforandroid/recipes/sdl/__init__.py +++ b/pythonforandroid/recipes/sdl/__init__.py @@ -9,22 +9,22 @@ class LibSDLRecipe(NDKRecipe): depends = ['python2', 'pygame_bootstrap_components'] conflicts = ['sdl2'] - def build_armeabi(self): + def build_arch(self, arch): if exists(join(self.ctx.libs_dir, 'libsdl.so')): info('libsdl.so already exists, skipping sdl build.') return - env = ArchARM(self.ctx).get_env() + env = arch.get_env() with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, 'V=1', _env=env, _tail=20, _critical=True) - libs_dir = join(self.ctx.bootstrap.build_dir, 'libs', 'armeabi') + libs_dir = join(self.ctx.bootstrap.build_dir, 'libs', arch.arch) import os contents = list(os.walk(libs_dir))[0][-1] for content in contents: - shprint(sh.cp, '-a', join(self.ctx.bootstrap.build_dir, 'libs', 'armeabi', content), + shprint(sh.cp, '-a', join(self.ctx.bootstrap.build_dir, 'libs', arch.arch, content), self.ctx.libs_dir) From 389858557f0510770908d46414b13a9f7505d3e0 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 00:47:44 +0000 Subject: [PATCH 17/29] Changed to find correct compiler in NDK --- pythonforandroid/toolchain.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 1c858699b7..e530cb4f25 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -288,11 +288,11 @@ def require_prebuilt_dist(func): @wraps(func) def wrapper_func(self, args): ctx = self.ctx + ctx.set_archs(self.archs) ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir, user_ndk_dir=self.ndk_dir, user_android_api=self.android_api, user_ndk_ver=self.ndk_version) - ctx.set_archs(self.archs) dist = self._dist if dist.needs_build: info_notify('No dist exists that meets your requirements, ' @@ -973,6 +973,15 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, warning('Android NDK version could not be found, exiting.') self.ndk_ver = ndk_ver + # AND: need to change if supporting multiple archs at once + arch = self.archs[0] + if arch.arch[:3] == 'arm': + compiler_dir = 'arch-arm' + elif arch.arch == 'x86': + compiler_dir = 'arch-x86' + else: + warning('Don\'t know what NDK compiler dir to look in. Exiting.') + exit(1) self.ndk_platform = join( self.ndk_dir, 'platforms', From 475e5f743d99c99aec2e2cca841fd13c2eac53ff Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 01:51:40 +0000 Subject: [PATCH 18/29] Terrible hacks to load x86 gcc if necessary --- pythonforandroid/toolchain.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index e530cb4f25..ead2a6fd75 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -486,6 +486,9 @@ def get_env(self): env['TOOLCHAIN_PREFIX'] = toolchain_prefix env['TOOLCHAIN_VERSION'] = toolchain_version + if toolchain_prefix == 'x86': + toolchain_prefix = 'i686-linux-android' + print('path is', environ['PATH']) cc = find_executable('{toolchain_prefix}-gcc'.format( toolchain_prefix=toolchain_prefix), path=environ['PATH']) if cc is None: @@ -986,7 +989,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, self.ndk_dir, 'platforms', 'android-{}'.format(self.android_api), - 'arch-arm') + compiler_dir) if not exists(self.ndk_platform): warning('ndk_platform doesn\'t exist') ok = False @@ -1022,15 +1025,18 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, py_platform = sys.platform if py_platform in ['linux2', 'linux3']: py_platform = 'linux' - if self.ndk_ver == 'r5b': - toolchain_prefix = 'arm-eabi' - elif self.ndk_ver[:2] in ('r7', 'r8', 'r9'): - toolchain_prefix = 'arm-linux-androideabi' - elif self.ndk_ver[:3] == 'r10': - toolchain_prefix = 'arm-linux-androideabi' + if arch.arch[:3] == 'arm': + if self.ndk_ver == 'r5b': + toolchain_prefix = 'arm-eabi' + elif self.ndk_ver[:2] in ('r7', 'r8', 'r9'): + toolchain_prefix = 'arm-linux-androideabi' + elif self.ndk_ver[:3] == 'r10': + toolchain_prefix = 'arm-linux-androideabi' + else: + warning('Error: NDK not supported by these tools?') + exit(1) else: - warning('Error: NDK not supported by these tools?') - exit(1) + toolchain_prefix = 'x86' toolchain_versions = [] toolchain_path = join(self.ndk_dir, 'toolchains') @@ -1042,9 +1048,11 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, os.path.join(toolchain_path, toolchain_content)): toolchain_version = toolchain_content[ len(toolchain_prefix)+1:] - debug('Found toolchain version: {}'.format( - toolchain_version)) - toolchain_versions.append(toolchain_version) + # AND: This is terrible! + if toolchain_version[0] in map(str, range(10)) and 'clang' not in toolchain_version and toolchain_version[:2] != '64': + debug('Found toolchain version: {}'.format( + toolchain_version)) + toolchain_versions.append(toolchain_version) else: warning('Could not find toolchain subdirectory!') ok = False From 2be55f73e18b515e3adc7594bc2a8bcf43874c03 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 01:53:45 +0000 Subject: [PATCH 19/29] Updated README about multiarch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e530bb4e1..c20715c5b2 100644 --- a/README.md +++ b/README.md @@ -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 From a9c22fd79b6022e035ba8c6bd843eec0415a3121 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 16:03:44 +0000 Subject: [PATCH 20/29] Moved toolchain path info to Arch classes --- pythonforandroid/toolchain.py | 80 ++++++++++++++++------------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index ead2a6fd75..79cc0782a6 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -11,7 +11,7 @@ import sys from sys import stdout, stderr, platform from os.path import (join, dirname, realpath, exists, isdir, basename, - expanduser, splitext) + expanduser, splitext, split) from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk, uname import os import zipfile @@ -444,6 +444,13 @@ def sync(self): class Arch(object): + + toolchain_prefix = None + '''The prefix for the toolchain dir in the NDK.''' + + command_prefix = None + '''The prefix for NDK commands such as gcc.''' + def __init__(self, ctx): super(Arch, self).__init__() self.ctx = ctx @@ -534,6 +541,9 @@ def get_env(self): class ArchARM(Arch): arch = "armeabi" + toolchain_prefix = 'arm-linux-androideabi' + command_prefix = 'arm-linux-androideabi' + platform_dir = 'arch-arm' class ArchARMv7_a(ArchARM): arch = 'armeabi-v7a' @@ -546,6 +556,9 @@ def get_env(self): class Archx86(Arch): arch = 'x86' + toolchain_prefix = 'x86' + command_prefix = 'i686-linux-android' + platform_dir = 'arch-x86' def get_env(self): env = super(Archx86, self).get_env() @@ -555,6 +568,9 @@ def get_env(self): class Archx86_64(Arch): arch = 'x86_64' + toolchain_prefix = 'x86' + command_prefix = 'x86_64-linux-android' + platform_dir = 'arch-x86' def get_env(self): env = super(Archx86_64, self).get_env() @@ -976,24 +992,6 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, warning('Android NDK version could not be found, exiting.') self.ndk_ver = ndk_ver - # AND: need to change if supporting multiple archs at once - arch = self.archs[0] - if arch.arch[:3] == 'arm': - compiler_dir = 'arch-arm' - elif arch.arch == 'x86': - compiler_dir = 'arch-x86' - else: - warning('Don\'t know what NDK compiler dir to look in. Exiting.') - exit(1) - self.ndk_platform = join( - self.ndk_dir, - 'platforms', - 'android-{}'.format(self.android_api), - compiler_dir) - if not exists(self.ndk_platform): - warning('ndk_platform doesn\'t exist') - ok = False - virtualenv = None if virtualenv is None: virtualenv = sh.which('virtualenv2') @@ -1021,38 +1019,31 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, ok = False warning("Missing requirement: cython is not installed") - # Modify the path so that sh finds modules appropriately + # AND: need to change if supporting multiple archs at once + arch = self.archs[0] + platform_dir = arch.platform_dir + toolchain_prefix = arch.toolchain_prefix + command_prefix = arch.command_prefix + self.ndk_platform = join( + self.ndk_dir, + 'platforms', + 'android-{}'.format(self.android_api), + platform_dir) + if not exists(self.ndk_platform): + warning('ndk_platform doesn\'t exist') + ok = False + py_platform = sys.platform if py_platform in ['linux2', 'linux3']: py_platform = 'linux' - if arch.arch[:3] == 'arm': - if self.ndk_ver == 'r5b': - toolchain_prefix = 'arm-eabi' - elif self.ndk_ver[:2] in ('r7', 'r8', 'r9'): - toolchain_prefix = 'arm-linux-androideabi' - elif self.ndk_ver[:3] == 'r10': - toolchain_prefix = 'arm-linux-androideabi' - else: - warning('Error: NDK not supported by these tools?') - exit(1) - else: - toolchain_prefix = 'x86' toolchain_versions = [] toolchain_path = join(self.ndk_dir, 'toolchains') if os.path.isdir(toolchain_path): - toolchain_contents = os.listdir(toolchain_path) - for toolchain_content in toolchain_contents: - if toolchain_content.startswith(toolchain_prefix) and \ - os.path.isdir( - os.path.join(toolchain_path, toolchain_content)): - toolchain_version = toolchain_content[ - len(toolchain_prefix)+1:] - # AND: This is terrible! - if toolchain_version[0] in map(str, range(10)) and 'clang' not in toolchain_version and toolchain_version[:2] != '64': - debug('Found toolchain version: {}'.format( - toolchain_version)) - toolchain_versions.append(toolchain_version) + toolchain_contents = glob.glob('{}/{}-*'.format(toolchain_path, + toolchain_prefix)) + toolchain_versions = [split(path)[-1][len(toolchain_prefix) + 1:] + for path in toolchain_contents] else: warning('Could not find toolchain subdirectory!') ok = False @@ -1077,6 +1068,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, self.toolchain_prefix = toolchain_prefix self.toolchain_version = toolchain_version + # Modify the path so that sh finds modules appropriately environ['PATH'] = ( '{ndk_dir}/toolchains/{toolchain_prefix}-{toolchain_version}/' 'prebuilt/{py_platform}-x86/bin/:{ndk_dir}/toolchains/' From 91b6e07055a49d6c9eb4f24d4588f8e0fd8f23fe Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 17:48:27 +0000 Subject: [PATCH 21/29] Added arch argument to should_build --- pythonforandroid/bootstraps/sdl2/__init__.py | 1 - pythonforandroid/recipes/freetype/__init__.py | 4 ++-- pythonforandroid/recipes/harfbuzz/__init__.py | 4 ++-- pythonforandroid/recipes/hostpython2/__init__.py | 7 +------ pythonforandroid/recipes/openssl/__init__.py | 4 ++-- pythonforandroid/toolchain.py | 6 +++--- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index ff9c9eac96..33871a2d10 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -20,7 +20,6 @@ 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 = self.ctx.archs[0] if len(self.ctx.archs) > 1: raise ValueError('built for more than one arch, but bootstrap cannot handle that yet') diff --git a/pythonforandroid/recipes/freetype/__init__.py b/pythonforandroid/recipes/freetype/__init__.py index 90cd312a1c..22f829b2a2 100644 --- a/pythonforandroid/recipes/freetype/__init__.py +++ b/pythonforandroid/recipes/freetype/__init__.py @@ -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 diff --git a/pythonforandroid/recipes/harfbuzz/__init__.py b/pythonforandroid/recipes/harfbuzz/__init__.py index e6a77a60ef..7c872ed2b9 100644 --- a/pythonforandroid/recipes/harfbuzz/__init__.py +++ b/pythonforandroid/recipes/harfbuzz/__init__.py @@ -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 diff --git a/pythonforandroid/recipes/hostpython2/__init__.py b/pythonforandroid/recipes/hostpython2/__init__.py index 5b775f2850..6305e832c1 100644 --- a/pythonforandroid/recipes/hostpython2/__init__.py +++ b/pythonforandroid/recipes/hostpython2/__init__.py @@ -23,14 +23,9 @@ def get_build_dir(self, arch=None): 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')) + join(self.get_build_dir(), 'Modules', 'Setup')) def build_arch(self, arch): - # AND: Should use an i386 recipe system - warning('Running hostpython build. Arch is armeabi! ' - 'This is naughty, need to fix the Arch system!') - - # AND: Fix armeabi again with current_directory(self.get_build_dir()): if exists('hostpython'): diff --git a/pythonforandroid/recipes/openssl/__init__.py b/pythonforandroid/recipes/openssl/__init__.py index 4a0afd0b88..77fc82cf56 100644 --- a/pythonforandroid/recipes/openssl/__init__.py +++ b/pythonforandroid/recipes/openssl/__init__.py @@ -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) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 79cc0782a6..ad767044b2 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -2042,7 +2042,7 @@ def prebuild_arch(self, arch): else: info('{} has no {}, skipping'.format(self.name, prebuild)) - def should_build(self): + def should_build(self, arch): '''Should perform any necessary test and return True only if it needs building again. @@ -2211,7 +2211,7 @@ def hostpython_location(self): 'hostpython') return self.ctx.hostpython - def should_build(self): + def should_build(self, arch): # AND: This should be different for each arch and use some # kind of data store to know what has been built in a given # python env @@ -2417,7 +2417,7 @@ def build_recipes(build_order, python_modules, ctx): info_main('# Building recipes') for recipe in recipes: info_main('Building {} for {}'.format(recipe.name, arch.arch)) - if recipe.should_build(): + if recipe.should_build(arch): recipe.build_arch(arch) else: info('{} said it is already built, skipping' From 6beaaf35d1d7963eeead3879d6fa41f314c5dd55 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 17:53:46 +0000 Subject: [PATCH 22/29] Cleaned comments and unused content from toolchain --- pythonforandroid/toolchain.py | 98 ++--------------------------------- 1 file changed, 4 insertions(+), 94 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index ad767044b2..9ba68f2b53 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -522,21 +522,14 @@ def get_env(self): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) # AND: This hardcodes python version 2.7, needs fixing - # AND: This also hardcodes armeabi, which isn't even correct, - # don't forget to fix! env['BUILDLIB_PATH'] = join( hostpython_recipe.get_build_dir(self.arch), 'build', 'lib.linux-{}-2.7'.format(uname()[-1])) env['PATH'] = environ['PATH'] - # AND: This stuff is set elsewhere in distribute.sh. Does that matter? env['ARCH'] = self.arch - # env['LIBLINK_PATH'] = join( - # self.ctx.build_dir, 'other_builds', 'objects') - # ensure_dir(env['LIBLINK_PATH']) # AND: This should be elsewhere - return env class ArchARM(Arch): @@ -917,8 +910,6 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, 'it with the SDK android tool.').format(android_api)) warning('Exiting.') exit(1) - # AND: If the android api target doesn't exist, we should - # offer to install it here # Find the Android NDK # Could also use ANDROID_NDK, but doesn't look like many tools use this @@ -1080,8 +1071,6 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir, toolchain_version=toolchain_version, py_platform=py_platform, path=environ.get('PATH')) - # AND: Are these necessary? Where to check for and and ndk-build? - # check the basic tools for executable in ("pkg-config", "autoconf", "automake", "libtoolize", "tar", "bzip2", "unzip", "make", "gcc", "g++"): if not sh.which(executable): @@ -1165,7 +1154,6 @@ def get_site_packages_dir(self, arch=None): def get_libs_dir(self, arch): '''The libs dir for a given arch.''' ensure_dir(join(self.libs_dir, arch)) - # AND: See warning: return join(self.libs_dir, arch) @@ -1341,10 +1329,7 @@ def get_distributions(cls, ctx, extra_dist_dirs=[]): with open(join(folder, 'dist_info.json')) as fileh: dist_info = json.load(fileh) dist = cls(ctx) - dist.name = folder.split('/')[-1] # AND: also equal to - # # dist_info['dist_name'] - # # ... Which one should we - # # use? + dist.name = folder.split('/')[-1] dist.dist_dir = folder dist.needs_build = False dist.recipes = dist_info['recipes'] @@ -1456,11 +1441,6 @@ def run_distribute(self): 'recipes': self.ctx.recipe_build_order}, fileh) - # AND: This method must be replaced by manual dir setting, in - # order to allow for user dirs - # def get_bootstrap_dir(self): - # return(dirname(__file__)) - @classmethod def list_bootstraps(cls): '''Find all the available bootstraps and return them.''' @@ -1932,7 +1912,6 @@ def unpack(self, arch): filename = shprint( sh.basename, self.versioned_url).stdout[:-1].decode('utf-8') - # AND: TODO: Use tito's better unpacking method with current_directory(build_dir): directory_name = self.get_build_dir(arch) @@ -1992,46 +1971,6 @@ def get_recipe_env(self, arch=None): arch = self.filtered_archs[0] return arch.get_env() - # @property - # def archive_root(self): - # key = "{}.archive_root".format(self.name) - # value = self.ctx.state.get(key) - # if not key: - # value = self.get_archive_rootdir(self.archive_fn) - # self.ctx.state[key] = value - # return value - - # def execute(self): - # if self.custom_dir: - # self.ctx.state.remove_all(self.name) - # self.download() - # self.extract() - # self.build_all() - - # AND: Will need to change how this works - # @property - # def custom_dir(self): - # """Check if there is a variable name to specify a custom version / - # directory to use instead of the current url. - # """ - # d = environ.get("P4A_{}_DIR".format(self.name.lower())) - # if not d: - # return - # if not exists(d): - # return - # return d - - # def prebuild(self): - # self.prebuild_arch(self.ctx.archs[0]) # AND: Need to change - # # this to support - # # multiple archs - - # def build(self): - # self.build_arch(self.ctx.archs[0]) # Same here! - - # def postbuild(self): - # self.postbuild_arch(self.ctx.archs[0]) - def prebuild_arch(self, arch): '''Run any pre-build tasks for the Recipe. By default, this checks if any prebuild_archname methods exist for the archname of the current @@ -2047,7 +1986,6 @@ def should_build(self, arch): building again. ''' - # AND: This should take arch as an argument! return True def build_arch(self, arch): @@ -2212,9 +2150,6 @@ def hostpython_location(self): return self.ctx.hostpython def should_build(self, arch): - # AND: This should be different for each arch and use some - # kind of data store to know what has been built in a given - # python env print('name is', self.site_packages_name, type(self)) name = self.site_packages_name if name is None: @@ -2273,12 +2208,7 @@ def build_arch(self, arch): '''Build any cython components, then install the Python module by calling setup.py install with the target Python dir. ''' - Recipe.build_arch(self, arch) # AND: Having to directly call the - # # method like this is nasty...could - # # use tito's method of having an - # # install method that always runs - # # after everything else but isn't - # # used by a normal recipe. + Recipe.build_arch(self, arch) self.build_compiled_components(arch) self.install_python_package(arch) @@ -2302,17 +2232,11 @@ def build_arch(self, arch): '''Build any cython components, then install the Python module by calling setup.py install with the target Python dir. ''' - Recipe.build_arch(self, arch) # AND: Having to directly call the - # # method like this is nasty...could - # # use tito's method of having an - # # install method that always runs - # # after everything else but isn't - # # used by a normal recipe. + Recipe.build_arch(self, arch) self.build_cython_components(arch) self.install_python_package(arch) def build_cython_components(self, arch): - # AND: Should we use tito's cythonize methods? How do they work? info('Cythonizing anything necessary in {}'.format(self.name)) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): @@ -2424,7 +2348,7 @@ def build_recipes(build_order, python_modules, ctx): .format(recipe.name)) # 4) biglink everything - # AND: Should make this optional (could use + # AND: Should make this optional info_main('# Biglinking object files') biglink(ctx, arch) @@ -2492,8 +2416,6 @@ def biglink(ctx, arch): files.append(obj_dir) shprint(sh.cp, '-r', *files) - # AND: Shouldn't hardcode Arch! In reality need separate - # build dirs for each arch env = arch.get_env() env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( join(ctx.bootstrap.build_dir, 'obj', 'local', arch.arch)) @@ -3039,18 +2961,6 @@ def clean_download_cache(self, args): if exists(ctx.packages_path): shutil.rmtree(ctx.packages_path) - # def status(self, args): - # parser = argparse.ArgumentParser( - # description="Give a status of the build") - # args = parser.parse_args(args) - # ctx = Context() - # # AND: TODO - - # print('This isn\'t implemented yet, but should list all ' - # 'currently existing distributions, the modules they ' - # 'include, and all the build caches.') - # exit(1) - @require_prebuilt_dist def export_dist(self, args): '''Copies a created dist to an output dir. From 28e0527622937394170013feae3e179415885247 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 21:01:55 +0000 Subject: [PATCH 23/29] Deleted more unnecessary comments --- pythonforandroid/toolchain.py | 83 ----------------------------------- 1 file changed, 83 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 9ba68f2b53..3a3dd830c5 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -571,37 +571,6 @@ def get_env(self): env['CXXFLAGS'] = env['CFLAGS'] return env -# class ArchSimulator(Arch): -# sdk = "iphonesimulator" -# arch = "i386" -# triple = "i386-apple-darwin11" -# version_min = "-miphoneos-version-min=6.0.0" -# sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip() - - -# class Arch64Simulator(Arch): -# sdk = "iphonesimulator" -# arch = "x86_64" -# triple = "x86_64-apple-darwin13" -# version_min = "-miphoneos-version-min=7.0" -# sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip() - - -# class ArchIOS(Arch): -# sdk = "iphoneos" -# arch = "armv7" -# triple = "arm-apple-darwin11" -# version_min = "-miphoneos-version-min=6.0.0" -# sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip() - - -# class Arch64IOS(Arch): -# sdk = "iphoneos" -# arch = "arm64" -# triple = "aarch64-apple-darwin13" -# version_min = "-miphoneos-version-min=7.0" -# sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip() - class Graph(object): # Taken from the old python-for-android/depsort @@ -2107,20 +2076,6 @@ def get_build_dir(self, arch): def get_jni_dir(self): return join(self.ctx.bootstrap.build_dir, 'jni') - # def download_if_necessary(self): - # info_main('Downloading {}'.format(self.name)) - # info('{} is an NDK recipe, it is alread included in the ' - # 'bootstrap (for now), so skipping'.format(self.name)) - # # Do nothing; in the future an NDKRecipe can copy its - # # contents to the bootstrap build dir, but for now each - # # bootstrap already includes available recipes (as was - # # already the case in p4a) - - # def prepare_build_dir(self, arch): - # info_main('Unpacking {} for {}'.format(self.name, arch)) - # info('{} is included in the bootstrap, unpacking currently ' - # 'unnecessary, so skipping'.format(self.name)) - class PythonRecipe(Recipe): site_packages_name = None @@ -2165,10 +2120,6 @@ def build_arch(self, arch): the target Python dir.''' super(PythonRecipe, self).build_arch(arch) self.install_python_package(arch) - # @cache_execution - # def install(self): - # self.install_python_package() - # self.reduce_python_package() def install_python_package(self, arch, name=None, env=None, is_dir=True): '''Automate the installation of a Python package (or a cython @@ -2279,15 +2230,6 @@ def build_cython_components(self, arch): # for filename in fnmatch.filter(filenames, "*.pyx"): # self.cythonize_file(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) - def get_recipe_env(self, arch): env = super(CythonRecipe, self).get_recipe_env(arch) env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( @@ -2474,21 +2416,11 @@ def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None): if link not in unique_args: unique_args.append(link) - # print('Biglink create %s library' % soname) - # print('Biglink arguments:') - # for arg in unique_args: - # print(' %s' % arg) - cc_name = env['CC'] cc = sh.Command(cc_name.split()[0]) cc = cc.bake(*cc_name.split()[1:]) shprint(cc, '-shared', '-O3', '-o', soname, *unique_args, _env=env) - # args = os.environ['CC'].split() + \ - # ['-shared', '-O3', '-o', soname] + \ - # unique_args - - # sys.exit(subprocess.call(args)) def ensure_dir(filename): @@ -2803,21 +2735,6 @@ def __init__(self): exit(1) getattr(self, args.command)(unknown) - # def build(self): - # parser = argparse.ArgumentParser( - # description="Build the toolchain") - # parser.add_argument("recipe", nargs="+", help="Recipe to compile") - # parser.add_argument("--arch", - # help="Restrict compilation to this arch") - # args = parser.parse_args(sys.argv[2:]) - - # ctx = Context() - # # if args.arch: - # # archs = args.arch.split() - # # ctx.archs = [arch for arch in ctx.archs if arch.arch in archs] - # # print("Architectures restricted to: {}".format(archs)) - # build_recipes(args.recipe, ctx) - def _read_configuration(self): # search for a .p4a configuration file in the current directory if not exists(".p4a"): From 385e0db036a02783aa3f9ebc21637cfca40f72c1 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 21:08:12 +0000 Subject: [PATCH 24/29] pep8 fixes --- pythonforandroid/toolchain.py | 40 +++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 3a3dd830c5..166154fa14 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -12,7 +12,7 @@ from sys import stdout, stderr, platform from os.path import (join, dirname, realpath, exists, isdir, basename, expanduser, splitext, split) -from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk, uname +from os import listdir, unlink, makedirs, environ, chdir, getcwd, uname import os import zipfile import tarfile @@ -56,7 +56,7 @@ def __init__(self): def __getattr__(self, key): return self._dict[key] - + Null_Style = Null_Fore = colorama_shim() if stdout.isatty(): @@ -148,14 +148,19 @@ def pretty_log_dists(dists, log_func=info): for line in infos: log_func('\t' + line) + def shorten_string(string, max_width): ''' make limited length string in form: "the string is very lo...(and 15 more)" - ''' + ''' string_len = len(string) - if string_len <= max_width: return string - visible = max_width - 16 - int(log10(string_len)) #expected suffix len "...(and XXXXX more)" - return ''.join((string[:visible], '...(and ', str(string_len - visible), ' more)')) + if string_len <= max_width: + return string + visible = max_width - 16 - int(log10(string_len)) + # expected suffix len "...(and XXXXX more)" + return ''.join((string[:visible], '...(and ', str(string_len - visible), + ' more)')) + def shprint(command, *args, **kwargs): '''Runs the command (which should be an sh.Command instance), while @@ -351,17 +356,19 @@ def current_directory(new_dir): Err_Fore.RESET))) chdir(cur_dir) + @contextlib.contextmanager def temp_directory(): temp_dir = mkdtemp() try: - logger.debug(''.join((Err_Fore.CYAN, ' + temp directory used ', temp_dir, - Err_Fore.RESET))) + logger.debug(''.join((Err_Fore.CYAN, ' + temp directory used ', + temp_dir, Err_Fore.RESET))) yield temp_dir finally: shutil.rmtree(temp_dir) - logger.debug(''.join((Err_Fore.CYAN, ' - temp directory deleted ', temp_dir, - Err_Fore.RESET))) + logger.debug(''.join((Err_Fore.CYAN, ' - temp directory deleted ', + temp_dir, Err_Fore.RESET))) + def cache_execution(f): def _cache_execution(self, *args, **kwargs): @@ -532,21 +539,25 @@ def get_env(self): return env + class ArchARM(Arch): arch = "armeabi" toolchain_prefix = 'arm-linux-androideabi' command_prefix = 'arm-linux-androideabi' platform_dir = 'arch-arm' + class ArchARMv7_a(ArchARM): arch = 'armeabi-v7a' def get_env(self): env = super(ArchARMv7_a, self).get_env() - env['CFLAGS'] = env['CFLAGS'] + ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb' + env['CFLAGS'] = (env['CFLAGS'] + + ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb') env['CXXFLAGS'] = env['CFLAGS'] return env + class Archx86(Arch): arch = 'x86' toolchain_prefix = 'x86' @@ -555,10 +566,12 @@ class Archx86(Arch): def get_env(self): env = super(Archx86, self).get_env() - env['CFLAGS'] = env['CFLAGS'] + ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32' + env['CFLAGS'] = (env['CFLAGS'] + + ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32') env['CXXFLAGS'] = env['CFLAGS'] return env + class Archx86_64(Arch): arch = 'x86_64' toolchain_prefix = 'x86' @@ -567,7 +580,8 @@ class Archx86_64(Arch): def get_env(self): env = super(Archx86_64, self).get_env() - env['CFLAGS'] = env['CFLAGS'] + ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel' + env['CFLAGS'] = (env['CFLAGS'] + + ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel') env['CXXFLAGS'] = env['CFLAGS'] return env From 2391ff0ccf46928e919e8104de600aa46187ea27 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 21:36:26 +0000 Subject: [PATCH 25/29] Added archs command to list available archs --- pythonforandroid/toolchain.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 166154fa14..0aa8bd499a 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -293,7 +293,7 @@ def require_prebuilt_dist(func): @wraps(func) def wrapper_func(self, args): ctx = self.ctx - ctx.set_archs(self.archs) + ctx.set_archs(self._archs) ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir, user_ndk_dir=self.ndk_dir, user_android_api=self.android_api, @@ -2727,7 +2727,7 @@ def __init__(self): self.android_api = args.android_api self.ndk_version = args.ndk_version - self.archs = split_argument_list(args.arch) + self._archs = split_argument_list(args.arch) # AND: Fail nicely if the args aren't handled yet if args.extra_dist_dirs: @@ -3016,6 +3016,13 @@ def print_context_info(self, args): 'ndk_platform', 'ndk_ver', 'android_api'): print('{} is {}'.format(attribute, getattr(ctx, attribute))) + def archs(self, args): + '''List the target architectures available to be built for.''' + print('{Style.BRIGHT}Available target architectures are:' + '{Style.RESET_ALL}'.format(Style=Out_Style)) + for arch in self.ctx.archs: + print(' {}'.format(arch.arch)) + def dists(self, args): '''The same as :meth:`distributions`.''' self.distributions(args) From ee5dc2bbe43fb085baed0dedb68a047a67d20a28 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 21:38:00 +0000 Subject: [PATCH 26/29] Documented --arch --- doc/source/commands.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/source/commands.rst b/doc/source/commands.rst index 684591002f..57d11994b1 100644 --- a/doc/source/commands.rst +++ b/doc/source/commands.rst @@ -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. From 3fcb9d047eda35dc37cc925fc02983d6d1fb4b5d Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 21:39:38 +0000 Subject: [PATCH 27/29] Reworded .p4a section of doc --- doc/source/quickstart.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/source/quickstart.rst b/doc/source/quickstart.rst index 8f890b8acb..a0ccc66bb2 100644 --- a/doc/source/quickstart.rst +++ b/doc/source/quickstart.rst @@ -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 From 42dcb397824a3d2e08e0260d1e151d7a18d62086 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 22:03:45 +0000 Subject: [PATCH 28/29] Added arch to dist_info --- pythonforandroid/toolchain.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 0aa8bd499a..aafacfb893 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -141,8 +141,10 @@ def pretty_log_dists(dists, log_func=info): for dist in dists: infos.append('{Fore.GREEN}{Style.BRIGHT}{name}{Style.RESET_ALL}: ' 'includes recipes ({Fore.GREEN}{recipes}' - '{Style.RESET_ALL})'.format( + '{Style.RESET_ALL}), built for archs ({Fore.BLUE}' + '{archs}{Style.RESET_ALL})'.format( name=dist.name, recipes=', '.join(dist.recipes), + archs=', '.join(dist.archs) if dist.archs else 'UNKNOWN', Fore=Err_Fore, Style=Err_Style)) for line in infos: @@ -1155,6 +1157,9 @@ class Distribution(object): url = None dist_dir = None # Where the dist dir ultimately is. Should not be None. + archs = [] + '''The arch targets that the dist is built for.''' + recipes = [] description = '' # A long description @@ -1316,6 +1321,8 @@ def get_distributions(cls, ctx, extra_dist_dirs=[]): dist.dist_dir = folder dist.needs_build = False dist.recipes = dist_info['recipes'] + if 'archs' in dist_info: + dist.archs = dist_info['archs'] dists.append(dist) return dists @@ -1327,6 +1334,7 @@ def save_info(self): info('Saving distribution info') with open('dist_info.json', 'w') as fileh: json.dump({'dist_name': self.name, + 'archs': [arch.arch for arch in self.ctx.archs], 'recipes': self.ctx.recipe_build_order}, fileh) From aad5b4958467f64e0dc5b902053a9352394db84d Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 5 Dec 2015 22:38:04 +0000 Subject: [PATCH 29/29] Added arch save in dist_info.json --- pythonforandroid/toolchain.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index aafacfb893..1afe76bd5e 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -1429,6 +1429,7 @@ def run_distribute(self): with open('dist_info.json', 'w') as fileh: json.dump({'dist_name': self.ctx.dist_name, 'bootstrap': self.ctx.bootstrap.name, + 'archs': [arch.arch for arch in self.ctx.archs], 'recipes': self.ctx.recipe_build_order}, fileh)