From 836327c7ec9c70a6954e687aab236630d62a61ef Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 14 Oct 2015 15:50:18 +0300 Subject: [PATCH 01/25] added .aar bundle (binary distribution of an Android Library Project) support in recepies --- .../bootstraps/pygame/__init__.py | 33 ++++++++++++++++++- pythonforandroid/bootstraps/sdl2/__init__.py | 31 +++++++++++++++++ .../bootstraps/sdl2python3/__init__.py | 31 +++++++++++++++++ pythonforandroid/toolchain.py | 7 ++++ 4 files changed, 101 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 446d157e17..227ece6f76 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -1,8 +1,10 @@ from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which -from os.path import join, exists +from os.path import join, exists, basename, splitext from os import walk import glob import sh +from tempfile import mkdtemp +from shutil import rmtree class PygameBootstrap(Bootstrap): @@ -44,6 +46,35 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') + info('Unpacking aars') + for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): + temp_dir = mkdtemp() + name = splitext(basename(aar))[0] + jar_name = name + '.jar' + info("unpack {} jar".format(name)) + info(" from {}".format(aar)) + info(" to {}".format(temp_dir)) + shprint(sh.unzip, '-o', aar, '-d', temp_dir) + + jar_src = join(temp_dir, 'classes.jar') + jar_tgt = join('libs', jar_name) + info("cp {} jar".format(name)) + info(" from {}".format(jar_src)) + info(" to {}".format(jar_tgt)) + shprint(sh.cp, '-a',jar_src, jar_tgt) + + so_src_dir = join(temp_dir, 'jni', 'armeabi') + so_tgt_dir = join('libs', 'armeabi') + info("cp {} .so".format(name)) + info(" from {}".format(so_src_dir)) + info(" to {}".format(so_tgt_dir)) + shprint(sh.mkdir, '-p', so_tgt_dir) + so_files = glob.glob(join(so_src_dir, '*.so')) + for f in so_files: + shprint(sh.cp, '-a', f, so_tgt_dir) + + rmtree(temp_dir) + info('Copying libs') # AND: Hardcoding armeabi - naughty! shprint(sh.mkdir, '-p', join('libs', 'armeabi')) diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index 1a4d1c1bbf..d0ec17dac7 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -3,6 +3,8 @@ from os import walk import glob import sh +from tempfile import mkdtemp +from shutil import rmtree class SDL2Bootstrap(Bootstrap): name = 'sdl2' @@ -35,6 +37,35 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') + info('Unpacking aars') + for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): + temp_dir = mkdtemp() + name = splitext(basename(aar))[0] + jar_name = name + '.jar' + info("unpack {} jar".format(name)) + info(" from {}".format(aar)) + info(" to {}".format(temp_dir)) + shprint(sh.unzip, '-o', aar, '-d', temp_dir) + + jar_src = join(temp_dir, 'classes.jar') + jar_tgt = join('libs', jar_name) + info("cp {} jar".format(name)) + info(" from {}".format(jar_src)) + info(" to {}".format(jar_tgt)) + shprint(sh.cp, '-a',jar_src, jar_tgt) + + so_src_dir = join(temp_dir, 'jni', 'armeabi') + so_tgt_dir = join('libs', 'armeabi') + info("cp {} .so".format(name)) + info(" from {}".format(so_src_dir)) + info(" to {}".format(so_tgt_dir)) + shprint(sh.mkdir, '-p', so_tgt_dir) + so_files = glob.glob(join(so_src_dir, '*.so')) + for f in so_files: + shprint(sh.cp, '-a', f, so_tgt_dir) + + rmtree(temp_dir) + info('Copying libs') # AND: Hardcoding armeabi - naughty! shprint(sh.mkdir, '-p', join('libs', 'armeabi')) diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index f5df900b9b..9e3edbccc7 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -3,6 +3,8 @@ from os import walk import glob import sh +from tempfile import mkdtemp +from shutil import rmtree class SDL2Bootstrap(Bootstrap): name = 'sdl2python3' @@ -37,6 +39,35 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', join(self.ctx.build_dir, 'python-install'), '.') + info('Unpacking aars') + for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): + temp_dir = mkdtemp() + name = splitext(basename(aar))[0] + jar_name = name + '.jar' + info("unpack {} jar".format(name)) + info(" from {}".format(aar)) + info(" to {}".format(temp_dir)) + shprint(sh.unzip, '-o', aar, '-d', temp_dir) + + jar_src = join(temp_dir, 'classes.jar') + jar_tgt = join('libs', jar_name) + info("cp {} jar".format(name)) + info(" from {}".format(jar_src)) + info(" to {}".format(jar_tgt)) + shprint(sh.cp, '-a',jar_src, jar_tgt) + + so_src_dir = join(temp_dir, 'jni', 'armeabi') + so_tgt_dir = join('libs', 'armeabi') + info("cp {} .so".format(name)) + info(" from {}".format(so_src_dir)) + info(" to {}".format(so_tgt_dir)) + shprint(sh.mkdir, '-p', so_tgt_dir) + so_files = glob.glob(join(so_src_dir, '*.so')) + for f in so_files: + shprint(sh.cp, '-a', f, so_tgt_dir) + + rmtree(temp_dir) + info('Copying libs') # AND: Hardcoding armeabi - naughty! shprint(sh.mkdir, '-p', join('libs', 'armeabi')) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index c6e1e7dd96..0fd14156e7 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -531,6 +531,7 @@ class Context(object): dist_dir = None # the Android project folder where everything ends up libs_dir = None # where Android libs are cached after build but # before being placed in dists + aars_dir = None javaclass_dir = None ccache = None # whether to use ccache cython = None # the cython interpreter name @@ -566,6 +567,12 @@ def javaclass_dir(self): ensure_dir(dir) return dir + @property + def aars_dir(self): + dir = join(self.build_dir, 'aars', self.bootstrap.distribution.name) + ensure_dir(dir) + return dir + @property def python_installs_dir(self): dir = join(self.build_dir, 'python-installs') From f3668e082f098d5e8194845a10fdccc861221e5d Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 14 Oct 2015 16:19:13 +0300 Subject: [PATCH 02/25] fixed aar support for recipes --- pythonforandroid/bootstraps/pygame/__init__.py | 1 + pythonforandroid/bootstraps/sdl2/__init__.py | 1 + pythonforandroid/bootstraps/sdl2python3/__init__.py | 1 + 3 files changed, 3 insertions(+) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 227ece6f76..f3f1941546 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -61,6 +61,7 @@ def run_distribute(self): info("cp {} jar".format(name)) info(" from {}".format(jar_src)) info(" to {}".format(jar_tgt)) + shprint(sh.mkdir, '-p', 'libs') shprint(sh.cp, '-a',jar_src, jar_tgt) so_src_dir = join(temp_dir, 'jni', 'armeabi') diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index d0ec17dac7..e55671298e 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -52,6 +52,7 @@ def run_distribute(self): info("cp {} jar".format(name)) info(" from {}".format(jar_src)) info(" to {}".format(jar_tgt)) + shprint(sh.mkdir, '-p', 'libs') shprint(sh.cp, '-a',jar_src, jar_tgt) so_src_dir = join(temp_dir, 'jni', 'armeabi') diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index 9e3edbccc7..5def7d417b 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -54,6 +54,7 @@ def run_distribute(self): info("cp {} jar".format(name)) info(" from {}".format(jar_src)) info(" to {}".format(jar_tgt)) + shprint(sh.mkdir, '-p', 'libs') shprint(sh.cp, '-a',jar_src, jar_tgt) so_src_dir = join(temp_dir, 'jni', 'armeabi') From 03691581babb0ed381dfd8308ee450b341e3f6b9 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 14 Oct 2015 15:50:18 +0300 Subject: [PATCH 03/25] added .aar bundle (binary distribution of an Android Library Project) support in recepies --- .../bootstraps/pygame/__init__.py | 33 ++++++++++++++++++- pythonforandroid/bootstraps/sdl2/__init__.py | 31 +++++++++++++++++ .../bootstraps/sdl2python3/__init__.py | 31 +++++++++++++++++ pythonforandroid/toolchain.py | 7 ++++ 4 files changed, 101 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 446d157e17..227ece6f76 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -1,8 +1,10 @@ from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which -from os.path import join, exists +from os.path import join, exists, basename, splitext from os import walk import glob import sh +from tempfile import mkdtemp +from shutil import rmtree class PygameBootstrap(Bootstrap): @@ -44,6 +46,35 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') + info('Unpacking aars') + for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): + temp_dir = mkdtemp() + name = splitext(basename(aar))[0] + jar_name = name + '.jar' + info("unpack {} jar".format(name)) + info(" from {}".format(aar)) + info(" to {}".format(temp_dir)) + shprint(sh.unzip, '-o', aar, '-d', temp_dir) + + jar_src = join(temp_dir, 'classes.jar') + jar_tgt = join('libs', jar_name) + info("cp {} jar".format(name)) + info(" from {}".format(jar_src)) + info(" to {}".format(jar_tgt)) + shprint(sh.cp, '-a',jar_src, jar_tgt) + + so_src_dir = join(temp_dir, 'jni', 'armeabi') + so_tgt_dir = join('libs', 'armeabi') + info("cp {} .so".format(name)) + info(" from {}".format(so_src_dir)) + info(" to {}".format(so_tgt_dir)) + shprint(sh.mkdir, '-p', so_tgt_dir) + so_files = glob.glob(join(so_src_dir, '*.so')) + for f in so_files: + shprint(sh.cp, '-a', f, so_tgt_dir) + + rmtree(temp_dir) + info('Copying libs') # AND: Hardcoding armeabi - naughty! shprint(sh.mkdir, '-p', join('libs', 'armeabi')) diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index 1a4d1c1bbf..d0ec17dac7 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -3,6 +3,8 @@ from os import walk import glob import sh +from tempfile import mkdtemp +from shutil import rmtree class SDL2Bootstrap(Bootstrap): name = 'sdl2' @@ -35,6 +37,35 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') + info('Unpacking aars') + for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): + temp_dir = mkdtemp() + name = splitext(basename(aar))[0] + jar_name = name + '.jar' + info("unpack {} jar".format(name)) + info(" from {}".format(aar)) + info(" to {}".format(temp_dir)) + shprint(sh.unzip, '-o', aar, '-d', temp_dir) + + jar_src = join(temp_dir, 'classes.jar') + jar_tgt = join('libs', jar_name) + info("cp {} jar".format(name)) + info(" from {}".format(jar_src)) + info(" to {}".format(jar_tgt)) + shprint(sh.cp, '-a',jar_src, jar_tgt) + + so_src_dir = join(temp_dir, 'jni', 'armeabi') + so_tgt_dir = join('libs', 'armeabi') + info("cp {} .so".format(name)) + info(" from {}".format(so_src_dir)) + info(" to {}".format(so_tgt_dir)) + shprint(sh.mkdir, '-p', so_tgt_dir) + so_files = glob.glob(join(so_src_dir, '*.so')) + for f in so_files: + shprint(sh.cp, '-a', f, so_tgt_dir) + + rmtree(temp_dir) + info('Copying libs') # AND: Hardcoding armeabi - naughty! shprint(sh.mkdir, '-p', join('libs', 'armeabi')) diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index f5df900b9b..9e3edbccc7 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -3,6 +3,8 @@ from os import walk import glob import sh +from tempfile import mkdtemp +from shutil import rmtree class SDL2Bootstrap(Bootstrap): name = 'sdl2python3' @@ -37,6 +39,35 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', join(self.ctx.build_dir, 'python-install'), '.') + info('Unpacking aars') + for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): + temp_dir = mkdtemp() + name = splitext(basename(aar))[0] + jar_name = name + '.jar' + info("unpack {} jar".format(name)) + info(" from {}".format(aar)) + info(" to {}".format(temp_dir)) + shprint(sh.unzip, '-o', aar, '-d', temp_dir) + + jar_src = join(temp_dir, 'classes.jar') + jar_tgt = join('libs', jar_name) + info("cp {} jar".format(name)) + info(" from {}".format(jar_src)) + info(" to {}".format(jar_tgt)) + shprint(sh.cp, '-a',jar_src, jar_tgt) + + so_src_dir = join(temp_dir, 'jni', 'armeabi') + so_tgt_dir = join('libs', 'armeabi') + info("cp {} .so".format(name)) + info(" from {}".format(so_src_dir)) + info(" to {}".format(so_tgt_dir)) + shprint(sh.mkdir, '-p', so_tgt_dir) + so_files = glob.glob(join(so_src_dir, '*.so')) + for f in so_files: + shprint(sh.cp, '-a', f, so_tgt_dir) + + rmtree(temp_dir) + info('Copying libs') # AND: Hardcoding armeabi - naughty! shprint(sh.mkdir, '-p', join('libs', 'armeabi')) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 81147e9fb7..a3984aa5f1 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -531,6 +531,7 @@ class Context(object): dist_dir = None # the Android project folder where everything ends up libs_dir = None # where Android libs are cached after build but # before being placed in dists + aars_dir = None javaclass_dir = None ccache = None # whether to use ccache cython = None # the cython interpreter name @@ -566,6 +567,12 @@ def javaclass_dir(self): ensure_dir(dir) return dir + @property + def aars_dir(self): + dir = join(self.build_dir, 'aars', self.bootstrap.distribution.name) + ensure_dir(dir) + return dir + @property def python_installs_dir(self): dir = join(self.build_dir, 'python-installs') From 05d1aea9e403d1f1f237342790cc5632004515b5 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 14 Oct 2015 16:19:13 +0300 Subject: [PATCH 04/25] fixed aar support for recipes --- pythonforandroid/bootstraps/pygame/__init__.py | 1 + pythonforandroid/bootstraps/sdl2/__init__.py | 1 + pythonforandroid/bootstraps/sdl2python3/__init__.py | 1 + 3 files changed, 3 insertions(+) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 227ece6f76..f3f1941546 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -61,6 +61,7 @@ def run_distribute(self): info("cp {} jar".format(name)) info(" from {}".format(jar_src)) info(" to {}".format(jar_tgt)) + shprint(sh.mkdir, '-p', 'libs') shprint(sh.cp, '-a',jar_src, jar_tgt) so_src_dir = join(temp_dir, 'jni', 'armeabi') diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index d0ec17dac7..e55671298e 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -52,6 +52,7 @@ def run_distribute(self): info("cp {} jar".format(name)) info(" from {}".format(jar_src)) info(" to {}".format(jar_tgt)) + shprint(sh.mkdir, '-p', 'libs') shprint(sh.cp, '-a',jar_src, jar_tgt) so_src_dir = join(temp_dir, 'jni', 'armeabi') diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index 9e3edbccc7..5def7d417b 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -54,6 +54,7 @@ def run_distribute(self): info("cp {} jar".format(name)) info(" from {}".format(jar_src)) info(" to {}".format(jar_tgt)) + shprint(sh.mkdir, '-p', 'libs') shprint(sh.cp, '-a',jar_src, jar_tgt) so_src_dir = join(temp_dir, 'jni', 'armeabi') From 28bb26cd176333f5ddcbc2a81ff0f376a1f7c6ff Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 14 Oct 2015 19:23:33 +0300 Subject: [PATCH 05/25] cosmetic pygame log spam removed --- pythonforandroid/recipes/pygame/__init__.py | 1 + .../pygame/patches/fix-sdl-spam-log.patch | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 pythonforandroid/recipes/pygame/patches/fix-sdl-spam-log.patch diff --git a/pythonforandroid/recipes/pygame/__init__.py b/pythonforandroid/recipes/pygame/__init__.py index ea8e1e8880..f720b3c830 100644 --- a/pythonforandroid/recipes/pygame/__init__.py +++ b/pythonforandroid/recipes/pygame/__init__.py @@ -34,6 +34,7 @@ def prebuild_armeabi(self): join(self.get_build_dir('armeabi'), 'Setup')) self.apply_patch(join('patches', 'fix-surface-access.patch')) self.apply_patch(join('patches', 'fix-array-surface.patch')) + self.apply_patch(join('patches', 'fix-sdl-spam-log.patch')) shprint(sh.touch, join(self.get_build_container_dir('armeabi'), '.patched')) def build_armeabi(self): diff --git a/pythonforandroid/recipes/pygame/patches/fix-sdl-spam-log.patch b/pythonforandroid/recipes/pygame/patches/fix-sdl-spam-log.patch new file mode 100644 index 0000000000..d78b5b5a7e --- /dev/null +++ b/pythonforandroid/recipes/pygame/patches/fix-sdl-spam-log.patch @@ -0,0 +1,47 @@ +--- pygame-1.9.1release/src/joystick.c.orig ++++ pygame-1.9.1release/src/joystick.c +@@ -201,7 +201,7 @@ joy_get_axis (PyObject* self, PyObject* args) + } + + value = SDL_JoystickGetAxis (joy, axis); +- printf("SDL_JoystickGetAxis value:%d:\n", value); ++/* printf("SDL_JoystickGetAxis value:%d:\n", value); */ + + + return PyFloat_FromDouble (value / 32768.0); +@@ -241,7 +241,7 @@ joy_get_button (PyObject* self, PyObject* args) + } + + value = SDL_JoystickGetButton (joy, _index); +- printf("SDL_JoystickGetButton value:%d:\n", value); ++/* printf("SDL_JoystickGetButton value:%d:\n", value); */ + + return PyInt_FromLong (value); + } +@@ -277,7 +277,7 @@ joy_get_ball (PyObject* self, PyObject* args) + return RAISE (PyExc_SDLError, "Joystick not initialized"); + } + value = SDL_JoystickNumBalls (joy); +- printf("SDL_JoystickNumBalls value:%d:\n", value); ++/* printf("SDL_JoystickNumBalls value:%d:\n", value); */ + + if (_index < 0 || _index >= value) { + return RAISE (PyExc_SDLError, "Invalid joystick trackball"); +@@ -300,7 +300,7 @@ joy_get_numhats (PyObject* self) + } + + value = SDL_JoystickNumHats (joy); +- printf("SDL_JoystickNumHats value:%d:\n", value); ++/* printf("SDL_JoystickNumHats value:%d:\n", value); */ + + return PyInt_FromLong (value); + } +@@ -327,7 +327,7 @@ joy_get_hat (PyObject* self, PyObject* args) + + px = py = 0; + value = SDL_JoystickGetHat (joy, _index); +- printf("SDL_JoystickGetHat value:%d:\n", value); ++/* printf("SDL_JoystickGetHat value:%d:\n", value); */ + + if (value & SDL_HAT_UP) { + py = 1; From 60acd886d020c6143fd29798293436eba863f7ca Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 14 Oct 2015 19:32:44 +0300 Subject: [PATCH 06/25] experimental recipe for VLC mediapleyer support --- pythonforandroid/recipes/vlc/__init__.py | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 pythonforandroid/recipes/vlc/__init__.py diff --git a/pythonforandroid/recipes/vlc/__init__.py b/pythonforandroid/recipes/vlc/__init__.py new file mode 100644 index 0000000000..f274f1cfa7 --- /dev/null +++ b/pythonforandroid/recipes/vlc/__init__.py @@ -0,0 +1,61 @@ +from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning +from os.path import exists, join, expanduser, basename +from os import environ +import sh +import glob + +class VlcRecipe(Recipe): + version = '3.0.0' + url = None + name = 'vlc' + + depends = ['pyjnius', 'android', 'kivy'] + + port_git = 'http://git.videolan.org/git/vlc-ports/android.git' + vlc_git = 'http://git.videolan.org/git/vlc.git' + + def prebuild_arch(self, arch): + super(VlcRecipe, self).prebuild_arch(arch) + build_dir = self.get_build_dir(arch.arch) + port_dir = join(build_dir, 'vlc-port-android') + aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') + aar = environ.get('LIBVLC_AAR', + join(aar_path, 'libvlc-{}.aar'.format(self.version))) + jar = join(build_dir, 'libvlc.jar') + if not exists(aar): + if not environ.has_key('LIBVLC_AAR'): + warning("set path to ready libvlc-.aar bundle in LIBVLC_AAR environment!") + info("libvlc-.aar for android not found!") + info("should build sources at {}".format(port_dir)) + if not exists(join(port_dir, 'compile.sh')): + info("clone vlc port for android sources from {}".format(self.port_git)) + shprint(sh.git, 'clone', self.port_git, port_dir) + vlc_dir = join(port_dir, 'vlc') + if not exists(join(vlc_dir, 'Makefile.am')): + info("clone vlc sources from {}".format(self.vlc_git)) + shprint(sh.git, 'clone', self.vlc_git, vlc_dir) + + def build_arch(self, arch): + super(VlcRecipe, self).build_arch(arch) + build_dir = self.get_build_dir(arch.arch) + port_dir = join(build_dir, 'vlc-port-android') + aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') + aar = environ.get('LIBVLC_AAR', + join(aar_path, 'libvlc-{}.aar'.format(self.version))) + jar = join(build_dir, 'libvlc.jar') + if not exists(aar): + with current_directory(port_dir): + env = dict(environ) + env.update({ + 'ANDROID_ABI': arch.arch, + 'ANDROID_NDK': self.ctx.ndk_dir, + 'ANDROID_SDK': self.ctx.sdk_dir, + }) + info("compile vlc from sources") + info("environment: {}".format(env)) + if not exists(join(port_dir, 'bin', 'VLC-debug.apk')): + shprint(sh.Command('./compile.sh'), _env=env) + shprint(sh.Command('./compile-libvlc.sh'), _env=env) + shprint(sh.cp, '-a', aar, self.ctx.aars_dir) + +recipe = VlcRecipe() From ab8bf582c8d991f313dc7f7a0f8eed8981d4466a Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 19 Oct 2015 12:34:48 +0300 Subject: [PATCH 07/25] recipes code cosmetic --- .../bootstraps/pygame/__init__.py | 67 ++-------------- pythonforandroid/bootstraps/sdl2/__init__.py | 61 ++------------ .../bootstraps/sdl2python3/__init__.py | 60 ++------------ pythonforandroid/recipes/vlc/__init__.py | 47 +++++++---- pythonforandroid/toolchain.py | 80 ++++++++++++++++++- 5 files changed, 132 insertions(+), 183 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index f3f1941546..36bdb98813 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -1,10 +1,8 @@ from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which -from os.path import join, exists, basename, splitext +from os.path import join, exists, basename from os import walk import glob import sh -from tempfile import mkdtemp -from shutil import rmtree class PygameBootstrap(Bootstrap): @@ -21,6 +19,9 @@ def run_distribute(self): # self.name) src_path = join(self.bootstrap_dir, 'build') + # AND: Hardcoding armeabi - naughty! + arch = ArchAndroid(self.ctx) + with current_directory(self.dist_dir): info('Creating initial layout') @@ -46,47 +47,9 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') - info('Unpacking aars') - for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): - temp_dir = mkdtemp() - name = splitext(basename(aar))[0] - jar_name = name + '.jar' - info("unpack {} jar".format(name)) - info(" from {}".format(aar)) - info(" to {}".format(temp_dir)) - shprint(sh.unzip, '-o', aar, '-d', temp_dir) - - jar_src = join(temp_dir, 'classes.jar') - jar_tgt = join('libs', jar_name) - info("cp {} jar".format(name)) - info(" from {}".format(jar_src)) - info(" to {}".format(jar_tgt)) - shprint(sh.mkdir, '-p', 'libs') - shprint(sh.cp, '-a',jar_src, jar_tgt) - - so_src_dir = join(temp_dir, 'jni', 'armeabi') - so_tgt_dir = join('libs', 'armeabi') - info("cp {} .so".format(name)) - info(" from {}".format(so_src_dir)) - info(" to {}".format(so_tgt_dir)) - shprint(sh.mkdir, '-p', so_tgt_dir) - so_files = glob.glob(join(so_src_dir, '*.so')) - for f in so_files: - shprint(sh.cp, '-a', f, so_tgt_dir) - - rmtree(temp_dir) - - info('Copying libs') - # AND: Hardcoding armeabi - naughty! - shprint(sh.mkdir, '-p', join('libs', 'armeabi')) - for lib in glob.glob(join(self.build_dir, 'libs', 'armeabi', '*')): - shprint(sh.cp, '-a', lib, join('libs', 'armeabi')) - for lib in glob.glob(join(self.ctx.get_libs_dir('armeabi'), '*')): - shprint(sh.cp, '-a', lib, join('libs', 'armeabi')) - - info('Copying java files') - for filename in glob.glob(self.ctx.javaclass_dir): - shprint(sh.cp, '-a', filename, 'src') + self.distribute_libs(arch, [join(self.build_dir, 'libs', arch.arch), self.ctx.get_libs_dir(arch.arch)]); + self.distribute_aars(arch) + self.distribute_javaclasses(self.ctx.javaclass_dir) info('Filling private directory') if not exists(join('private', 'lib')): @@ -123,21 +86,7 @@ def run_distribute(self): shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so') - info('Stripping libraries') - env = ArchAndroid(self.ctx).get_env() - strip = which('arm-linux-androideabi-strip', env['PATH']) - if strip is None: - warning('Can\'t find strip in PATH...') - strip = sh.Command(strip) - filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'), - '-iname', '*.so', _env=env).stdout.decode('utf-8') - logger.info('Stripping libraries in private dir') - for filen in filens.split('\n'): - try: - strip(filen, _env=env) - except sh.ErrorReturnCode_1: - logger.debug('Failed to strip ' + 'filen') - + self.strip_libraries(arch) super(PygameBootstrap, self).run_distribute() bootstrap = PygameBootstrap() diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index e55671298e..20a47c4c1c 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -22,6 +22,9 @@ def run_distribute(self): with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) + # AND: Hardcoding armeabi - naughty! + arch = ArchAndroid(self.ctx) + with current_directory(self.dist_dir): info('Copying python distribution') @@ -37,45 +40,9 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') - info('Unpacking aars') - for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): - temp_dir = mkdtemp() - name = splitext(basename(aar))[0] - jar_name = name + '.jar' - info("unpack {} jar".format(name)) - info(" from {}".format(aar)) - info(" to {}".format(temp_dir)) - shprint(sh.unzip, '-o', aar, '-d', temp_dir) - - jar_src = join(temp_dir, 'classes.jar') - jar_tgt = join('libs', jar_name) - info("cp {} jar".format(name)) - info(" from {}".format(jar_src)) - info(" to {}".format(jar_tgt)) - shprint(sh.mkdir, '-p', 'libs') - shprint(sh.cp, '-a',jar_src, jar_tgt) - - so_src_dir = join(temp_dir, 'jni', 'armeabi') - so_tgt_dir = join('libs', 'armeabi') - info("cp {} .so".format(name)) - info(" from {}".format(so_src_dir)) - info(" to {}".format(so_tgt_dir)) - shprint(sh.mkdir, '-p', so_tgt_dir) - so_files = glob.glob(join(so_src_dir, '*.so')) - for f in so_files: - shprint(sh.cp, '-a', f, so_tgt_dir) - - rmtree(temp_dir) - - info('Copying libs') - # AND: Hardcoding armeabi - naughty! - shprint(sh.mkdir, '-p', join('libs', 'armeabi')) - for lib in glob.glob(join(self.ctx.get_libs_dir('armeabi'), '*')): - shprint(sh.cp, '-a', lib, join('libs', 'armeabi')) - - info('Copying java files') - for filename in glob.glob(self.ctx.javaclass_dir): - shprint(sh.cp, '-a', filename, 'src') + self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) + self.distribute_aars(arch) + self.distribute_javaclasses(self.ctx.javaclass_dir) info('Filling private directory') if not exists(join('private', 'lib')): @@ -113,21 +80,7 @@ def run_distribute(self): # shprint(sh.rm, '-rf', 'lib-dynload/_ctypes_test.so') # shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so') - - info('Stripping libraries') - env = ArchAndroid(self.ctx).get_env() - strip = which('arm-linux-androideabi-strip', env['PATH']) - if strip is None: - warning('Can\'t find strip in PATH...') - strip = sh.Command(strip) - filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'), - '-iname', '*.so', _env=env).stdout.decode('utf-8') - logger.info('Stripping libraries in private dir') - for filen in filens.split('\n'): - try: - strip(filen, _env=env) - except sh.ErrorReturnCode_1: - logger.debug('Failed to strip ' + 'filen') + self.strip_libraries(arch) super(SDL2Bootstrap, self).run_distribute() bootstrap = SDL2Bootstrap() diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index 5def7d417b..37825a4913 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -24,6 +24,9 @@ def run_distribute(self): with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) + # AND: Hardcoding armeabi - naughty! + arch = ArchAndroid(self.ctx) + with current_directory(self.dist_dir): info('Copying python distribution') @@ -39,45 +42,9 @@ def run_distribute(self): if not exists('python-install'): shprint(sh.cp, '-a', join(self.ctx.build_dir, 'python-install'), '.') - info('Unpacking aars') - for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): - temp_dir = mkdtemp() - name = splitext(basename(aar))[0] - jar_name = name + '.jar' - info("unpack {} jar".format(name)) - info(" from {}".format(aar)) - info(" to {}".format(temp_dir)) - shprint(sh.unzip, '-o', aar, '-d', temp_dir) - - jar_src = join(temp_dir, 'classes.jar') - jar_tgt = join('libs', jar_name) - info("cp {} jar".format(name)) - info(" from {}".format(jar_src)) - info(" to {}".format(jar_tgt)) - shprint(sh.mkdir, '-p', 'libs') - shprint(sh.cp, '-a',jar_src, jar_tgt) - - so_src_dir = join(temp_dir, 'jni', 'armeabi') - so_tgt_dir = join('libs', 'armeabi') - info("cp {} .so".format(name)) - info(" from {}".format(so_src_dir)) - info(" to {}".format(so_tgt_dir)) - shprint(sh.mkdir, '-p', so_tgt_dir) - so_files = glob.glob(join(so_src_dir, '*.so')) - for f in so_files: - shprint(sh.cp, '-a', f, so_tgt_dir) - - rmtree(temp_dir) - - info('Copying libs') - # AND: Hardcoding armeabi - naughty! - shprint(sh.mkdir, '-p', join('libs', 'armeabi')) - for lib in glob.glob(join(self.ctx.libs_dir, '*')): - shprint(sh.cp, '-a', lib, join('libs', 'armeabi')) - - info('Copying java files') - for filename in glob.glob(join(self.ctx.build_dir, 'java', '*')): - shprint(sh.cp, '-a', filename, 'src') + self.distribute_libs(arch, [self.ctx.libs_dir]) + self.distribute_aars(arch) + self.distribute_javaclasses(join(self.ctx.build_dir, 'java')) info('Filling private directory') if not exists(join('private', 'lib')): @@ -117,20 +84,7 @@ def run_distribute(self): # shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so') - info('Stripping libraries') - env = ArchAndroid(self.ctx).get_env() - strip = which('arm-linux-androideabi-strip', env['PATH']) - if strip is None: - warning('Can\'t find strip in PATH...') - strip = sh.Command(strip) - filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'), - '-iname', '*.so', _env=env).stdout.decode('utf-8') - logger.info('Stripping libraries in private dir') - for filen in filens.split('\n'): - try: - strip(filen, _env=env) - except sh.ErrorReturnCode_1: - logger.debug('Failed to strip ' + 'filen') + self.strip_libraries(arch) super(SDL2Bootstrap, self).run_distribute() bootstrap = SDL2Bootstrap() diff --git a/pythonforandroid/recipes/vlc/__init__.py b/pythonforandroid/recipes/vlc/__init__.py index f274f1cfa7..377b14255d 100644 --- a/pythonforandroid/recipes/vlc/__init__.py +++ b/pythonforandroid/recipes/vlc/__init__.py @@ -1,32 +1,35 @@ -from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning -from os.path import exists, join, expanduser, basename +from pythonforandroid.toolchain import Recipe, shprint, current_directory, warning, info, debug +from os.path import exists, join from os import environ import sh -import glob +from colorama import Fore, Style class VlcRecipe(Recipe): version = '3.0.0' url = None name = 'vlc' - depends = ['pyjnius', 'android', 'kivy'] + depends = [] port_git = 'http://git.videolan.org/git/vlc-ports/android.git' vlc_git = 'http://git.videolan.org/git/vlc.git' + ENV_LIBVLC_AAR = 'LIBVLC_AAR' def prebuild_arch(self, arch): super(VlcRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) port_dir = join(build_dir, 'vlc-port-android') aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') - aar = environ.get('LIBVLC_AAR', + aar = environ.get(self.ENV_LIBVLC_AAR, join(aar_path, 'libvlc-{}.aar'.format(self.version))) - jar = join(build_dir, 'libvlc.jar') if not exists(aar): - if not environ.has_key('LIBVLC_AAR'): - warning("set path to ready libvlc-.aar bundle in LIBVLC_AAR environment!") + if environ.has_key(''): + warning("Error: libvlc-.aar bundle not found in {}".format(aar)) + info("check {} environment!".format(self.ENV_LIBVLC_AAR)) + raise Exception("vlc .aar bundle not found by path specified in {}".format(self.ENV_LIBVLC_AAR)) + warning("set path to precompiled libvlc-.aar bundle in {} environment!".format(self.ENV_LIBVLC_AAR)) info("libvlc-.aar for android not found!") - info("should build sources at {}".format(port_dir)) + info("should build from sources at {}".format(port_dir)) if not exists(join(port_dir, 'compile.sh')): info("clone vlc port for android sources from {}".format(self.port_git)) shprint(sh.git, 'clone', self.port_git, port_dir) @@ -40,9 +43,8 @@ def build_arch(self, arch): build_dir = self.get_build_dir(arch.arch) port_dir = join(build_dir, 'vlc-port-android') aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') - aar = environ.get('LIBVLC_AAR', + aar = environ.get(self.ENV_LIBVLC_AAR, join(aar_path, 'libvlc-{}.aar'.format(self.version))) - jar = join(build_dir, 'libvlc.jar') if not exists(aar): with current_directory(port_dir): env = dict(environ) @@ -51,11 +53,24 @@ def build_arch(self, arch): 'ANDROID_NDK': self.ctx.ndk_dir, 'ANDROID_SDK': self.ctx.sdk_dir, }) - info("compile vlc from sources") - info("environment: {}".format(env)) - if not exists(join(port_dir, 'bin', 'VLC-debug.apk')): - shprint(sh.Command('./compile.sh'), _env=env) - shprint(sh.Command('./compile-libvlc.sh'), _env=env) + info("compiling vlc from sources") + debug("environment: {}".format(env)) + try: + if not exists(join(port_dir, 'bin', 'VLC-debug.apk')): + shprint(sh.Command('./compile.sh'), _env=env) + shprint(sh.Command('./compile-libvlc.sh'), _env=env) + except sh.ErrorReturnCode_1, err: + warning("Error: vlc compilation failed") + lines = err.stdout.splitlines() + N = 20 + if len(lines) <= N: + info('STDOUT:\n{}\t{}{}'.format(Fore.YELLOW, '\t\n'.join(lines), Fore.RESET)) + else: + info('STDOUT (last {} lines of {}):\n{}\t{}{}'.format(N, len(lines), Fore.YELLOW, '\t\n'.join(lines[-N:]), Fore.RESET)) + lines = err.stderr.splitlines() + if len(lines): + warning('STDERR:\n{}\t{}{}'.format(Fore.RED, '\t\n'.join(lines), Fore.RESET)) + raise Exception("vlc compilation failed") shprint(sh.cp, '-a', aar, self.ctx.aars_dir) recipe = VlcRecipe() diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index a3984aa5f1..63d0a6a249 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -11,7 +11,7 @@ import sys from sys import stdout, platform from os.path import (join, dirname, realpath, exists, isdir, basename, - expanduser) + expanduser, splitext) from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk, uname import os import zipfile @@ -29,6 +29,7 @@ from functools import wraps from datetime import datetime from distutils.spawn import find_executable +from tempfile import mkdtemp try: from urllib.request import FancyURLopener except ImportError: @@ -143,6 +144,7 @@ def shprint(command, *args, **kwargs): logger.debug(''.join(['\t', line.rstrip()])) if logger.level > logging.DEBUG and need_closing_newline: print() + return output # shprint(sh.ls, '-lah') @@ -220,6 +222,17 @@ def current_directory(new_dir): Fore.RESET))) chdir(cur_dir) +@contextlib.contextmanager +def temp_directory(): + temp_dir = mkdtemp() + try: + logger.debug(''.join((Fore.CYAN, ' + temp directory used ', temp_dir, + Fore.RESET))) + yield temp_dir + finally: + shutil.rmtree(temp_dir) + logger.debug(''.join((Fore.CYAN, ' - temp directory deleted ', temp_dir, + Fore.RESET))) def cache_execution(f): @@ -1321,6 +1334,71 @@ def get_bootstrap(cls, name, ctx): bootstrap.ctx = ctx return bootstrap + def distribute_libs(self, arch, src_dirs, wildcard='*'): + '''Copy existing arch libs from build dirs to current dist dir.''' + info('Copying libs') + tgt_dir = join('libs', arch.arch) + ensure_dir(tgt_dir) + for src_dir in src_dirs: + for lib in glob.glob(join(src_dir, wildcard)): + shprint(sh.cp, '-a', lib, tgt_dir) + + def distribute_javaclasses(self, javaclass_dir): + '''Copy existing javaclasses from build dir to current dist dir.''' + info('Copying java files') + for filename in glob.glob(javaclass_dir): + shprint(sh.cp, '-a', filename, 'src') + + def distribute_aars(self, arch): + '''Process existing .aar bundles and copy to current dist dir.''' + info('Unpacking aars') + for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')): + self._unpack_aar(aar, arch) + + def _unpack_aar(self, aar, arch): + '''Unpack content of .aar bundle and copy to current dist dir.''' + with temp_directory() as temp_dir: + name = splitext(basename(aar))[0] + jar_name = name + '.jar' + info("unpack {} aar".format(name)) + debug(" from {}".format(aar)) + debug(" to {}".format(temp_dir)) + shprint(sh.unzip, '-o', aar, '-d', temp_dir) + + jar_src = join(temp_dir, 'classes.jar') + jar_tgt = join('libs', jar_name) + debug("copy {} jar".format(name)) + debug(" from {}".format(jar_src)) + debug(" to {}".format(jar_tgt)) + ensure_dir('libs') + shprint(sh.cp, '-a', jar_src, jar_tgt) + + so_src_dir = join(temp_dir, 'jni', arch.arch) + so_tgt_dir = join('libs', arch.arch) + debug("copy {} .so".format(name)) + debug(" from {}".format(so_src_dir)) + debug(" to {}".format(so_tgt_dir)) + ensure_dir(so_tgt_dir) + so_files = glob.glob(join(so_src_dir, '*.so')) + for f in so_files: + shprint(sh.cp, '-a', f, so_tgt_dir) + + def strip_libraries(self, arch): + info('Stripping libraries') + env = arch.get_env() + strip = which('arm-linux-androideabi-strip', env['PATH']) + if strip is None: + warning('Can\'t find strip in PATH...') + return + strip = sh.Command(strip) + filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'), + '-iname', '*.so', _env=env).stdout.decode('utf-8') + logger.info('Stripping libraries in private dir') + for filen in filens.split('\n'): + try: + strip(filen, _env=env) + except sh.ErrorReturnCode_1: + logger.debug('Failed to strip ' + filen) class Recipe(object): url = None From ce4ea62717dcf8748f92648f935055a8deeae50c Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 19 Oct 2015 14:20:02 +0300 Subject: [PATCH 08/25] code cosmetic --- pythonforandroid/bootstraps/pygame/__init__.py | 4 ++-- pythonforandroid/bootstraps/sdl2/__init__.py | 4 +--- pythonforandroid/bootstraps/sdl2python3/__init__.py | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 36bdb98813..5b07a0865e 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -1,5 +1,5 @@ -from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which -from os.path import join, exists, basename +from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main +from os.path import join, exists from os import walk import glob import sh diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index 20a47c4c1c..fcc1b20fe0 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -1,10 +1,8 @@ -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, ArchAndroid, info_main from os.path import join, exists from os import walk import glob import sh -from tempfile import mkdtemp -from shutil import rmtree class SDL2Bootstrap(Bootstrap): name = 'sdl2' diff --git a/pythonforandroid/bootstraps/sdl2python3/__init__.py b/pythonforandroid/bootstraps/sdl2python3/__init__.py index 37825a4913..4218e827be 100644 --- a/pythonforandroid/bootstraps/sdl2python3/__init__.py +++ b/pythonforandroid/bootstraps/sdl2python3/__init__.py @@ -1,10 +1,8 @@ -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, ArchAndroid, info_main from os.path import join, exists from os import walk import glob import sh -from tempfile import mkdtemp -from shutil import rmtree class SDL2Bootstrap(Bootstrap): name = 'sdl2python3' From cc50d62505a8dd426e52ac0059d5925aaf9ef2cd Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 27 Oct 2015 12:08:16 +0200 Subject: [PATCH 09/25] cosmetic fixed minor logging in pygame bootstrap --- .../recipes/pygame_bootstrap_components/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py b/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py index 4ba1cb0b82..149cce167d 100644 --- a/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py +++ b/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py @@ -14,7 +14,7 @@ def prebuild_arch(self, arch): info('Unpacking pygame bootstrap JNI dir components') with current_directory(self.get_build_container_dir(arch)): if exists('sdl'): - info('sdl dir exists, so it looks like the JNI components', + info('sdl dir exists, so it looks like the JNI components' + 'are already unpacked. Skipping.') return for dirn in glob.glob(join(self.get_build_dir(arch), From fdcf5e7c28d1a525756fe89371ee04b8e195f002 Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 27 Oct 2015 12:09:31 +0200 Subject: [PATCH 10/25] added sdl2 bootstrap meta and presplash --- .../bootstraps/sdl2/build/build.py | 12 ++++++ .../src/org/kivy/android/PythonActivity.java | 38 +++++++++++++++++++ .../build/templates/AndroidManifest.xml.tmpl | 5 +++ 3 files changed, 55 insertions(+) diff --git a/pythonforandroid/bootstraps/sdl2/build/build.py b/pythonforandroid/bootstraps/sdl2/build/build.py index 175931bec5..2d598ef3b6 100755 --- a/pythonforandroid/bootstraps/sdl2/build/build.py +++ b/pythonforandroid/bootstraps/sdl2/build/build.py @@ -249,6 +249,10 @@ def make_package(args): default_icon = 'templates/kivy-icon.png' shutil.copy(args.icon or default_icon, 'res/drawable/icon.png') + default_presplash = 'templates/kivy-presplash.jpg' + shutil.copy(args.presplash or default_presplash, + 'res/drawable/presplash.jpg') + versioned_name = (args.name.replace(' ', '').replace('\'', '') + '-' + args.version) @@ -324,6 +328,11 @@ def parse_args(args=None): help='A png file to use as the icon for the application.') ap.add_argument('--permission', dest='permissions', action='append', help='The permissions to give this app.') + ap.add_argument('--meta-data', dest='meta_data', action='append', + help='Custom key=value to add in application metadata') + ap.add_argument('--presplash', dest='presplash', + help=('A jpeg file to use as a screen while the ' + 'application is loading.')) if args is None: args = sys.argv[1:] @@ -333,6 +342,9 @@ def parse_args(args=None): if args.permissions is None: args.permissions = [] + if args.meta_data is None: + args.meta_data = [] + make_package(args) if __name__ == "__main__": diff --git a/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java b/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java index abe5b158d5..de8649c72a 100644 --- a/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java +++ b/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java @@ -7,22 +7,35 @@ import java.io.FileWriter; import java.io.File; +import android.view.ViewGroup; +import android.view.SurfaceView; import android.app.Activity; import android.util.Log; import android.widget.Toast; import android.os.Bundle; +import android.os.PowerManager; +import android.graphics.PixelFormat; +import android.view.SurfaceHolder; +import android.content.Context; +import android.content.pm.PackageManager; +import android.content.pm.ApplicationInfo; import org.libsdl.app.SDLActivity; import org.renpy.android.ResourceManager; import org.renpy.android.AssetExtract; + public class PythonActivity extends SDLActivity { private static final String TAG = "PythonActivity"; public static PythonActivity mActivity = null; private ResourceManager resourceManager; + + // Access to our meta-data + private ApplicationInfo ai; + private PowerManager.WakeLock wakeLock; @Override protected void onCreate(Bundle savedInstanceState) { @@ -48,6 +61,24 @@ protected void onCreate(Bundle savedInstanceState) { // nativeSetEnv("ANDROID_ARGUMENT", getFilesDir()); + + try { + ai = act.getPackageManager().getApplicationInfo( + act.getPackageName(), PackageManager.GET_META_DATA); + PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE); + wakeLock = null; + if ( (Integer)ai.metaData.get("wakelock") == 1 ) { + wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On"); + } + if ( ai.metaData.getInt("surface.transparent") != 0 ) { + Log.v(TAG, "Surface will be transparent."); + mSurface.setZOrderOnTop(true); + mSurface.getHolder().setFormat(PixelFormat.TRANSPARENT); + } else { + Log.i(TAG, "Surface will NOT be transparent"); + } + } catch (PackageManager.NameNotFoundException e) { + } } // This is just overrides the normal SDLActivity, which just loads @@ -169,6 +200,13 @@ public void unpackData(final String resource, File target) { Log.w("python", e); } } + } + + public static ViewGroup getLayout() { + return mLayout; + } + public static SurfaceView getSurface() { + return mSurface; } } diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.xml.tmpl b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.xml.tmpl index 75e3d62fa8..4ce2fe373a 100644 --- a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.xml.tmpl +++ b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.xml.tmpl @@ -38,6 +38,11 @@ android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:hardwareAccelerated="true" > + + {% for m in args.meta_data %} + {% endfor %} + + Date: Tue, 27 Oct 2015 13:20:09 +0200 Subject: [PATCH 11/25] sdl2 bootstrap default presplash image added --- .../sdl2/build/templates/kivy-presplash.jpg | Bin 0 -> 38458 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pythonforandroid/bootstraps/sdl2/build/templates/kivy-presplash.jpg diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/kivy-presplash.jpg b/pythonforandroid/bootstraps/sdl2/build/templates/kivy-presplash.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6f11335167a08e21422d28115e724e66a5d7c349 GIT binary patch literal 38458 zcmeFa2UL?ww=f(;K}AGGP(X=DlP+CqRHQ1>yMUC?A(RA=7KI}yRX{*MK$h!X??9R-n-oB@#nUnIaEh=d+=8e4hgUZ9sZs+6?lIJZlFYBuHW7_%weX`OR82dILyTg z=6Fd)M;cMbTVn8Yoi1Zc7w{i&t5a`vR-}65N zdPVyCH!=Hzi;RTyJB?&N*Mo%dk9v@>{ag=#C*SEM;XU*t?_-qT^ZOI+gumkDGU&uX zos4CaL5Bz!(8+@k$owIY0|{Xm^c(2J(W6I?9X)aE*oo5=$0<(JP@OnIMRT5-nuePC z{OJ=1*Z0@Az<+#_P*PA(o}@f=^5m(rCr_R{OMIL>`z^`o|4s&kx1iHUL8<`1NG^j8 zohBhYO+pw2s(qZ$NCE+fDV!V9(f8xa+rkl z(BVTz$jOc#Aw3}oM4l!+%yfqT$PG0U>dQ`#1jx>Yzb?AT%tE7HZz?F{?As|r&KjZd zb$r##MVL0Z*pKa2q^7y-yA-&{xh|~<=vv8d4c&;zbvgFusgFye8hfTT(#o28r#H1N zT>Ycd%is6SY>CS2Sh@woWT2Y+XSYv-4jlrhJ$yhDIoT260}`0{&m0CQaJo!=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J4UJ`+3$nI-1O z&i>roY@<8f{I30#1IGstc*buwtv9bSrJ=}He9!W$8OQpP1?`gC9690RsA<3x!{G&% z{c`LMvvG@7F~1?@g>Y{r1=v+Zl0$5sOI6iG$d`IGzz56(m3voZN4i~JED0ZL$Anx= zB5-PRn!G%(p|QhM$*=h$JGsZ<+jgHW!I3u)>%bE7Bki2(`Olu^nz2_eHyZn`0Q5U} z{5j74tFQQfIVJ3S$vA(4rN6_#_x4!-9rj>1w3_62_rI^@dwacpH}ogV|Bna0x4{4R z+>{?s+WJ4KH~2ko>qljbe^}n+4?p*R=okEvxtl+t)qiL~KjOAOJW}|c&-O Date: Tue, 27 Oct 2015 14:48:02 +0200 Subject: [PATCH 12/25] fix for android native in sdl2 bootstrap transparent surface --- .../src/org/kivy/android/PythonActivity.java | 27 +++++++++---------- .../src/org/renpy/android/AssetExtract.java | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java b/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java index de8649c72a..77979da1d7 100644 --- a/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java +++ b/pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java @@ -31,12 +31,10 @@ public class PythonActivity extends SDLActivity { public static PythonActivity mActivity = null; - private ResourceManager resourceManager; + private ResourceManager resourceManager = null; + private Bundle mMetaData = null; + private PowerManager.WakeLock mWakeLock = null; - // Access to our meta-data - private ApplicationInfo ai; - private PowerManager.WakeLock wakeLock; - @Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "My oncreate running"); @@ -63,17 +61,18 @@ protected void onCreate(Bundle savedInstanceState) { // nativeSetEnv("ANDROID_ARGUMENT", getFilesDir()); try { - ai = act.getPackageManager().getApplicationInfo( - act.getPackageName(), PackageManager.GET_META_DATA); - PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE); - wakeLock = null; - if ( (Integer)ai.metaData.get("wakelock") == 1 ) { - wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On"); + Log.v(TAG, "Access to our meta-data..."); + this.mMetaData = this.mActivity.getPackageManager().getApplicationInfo( + this.mActivity.getPackageName(), PackageManager.GET_META_DATA).metaData; + + PowerManager pm = (PowerManager) this.mActivity.getSystemService(Context.POWER_SERVICE); + if ( this.mMetaData.getInt("wakelock") == 1 ) { + this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On"); } - if ( ai.metaData.getInt("surface.transparent") != 0 ) { + if ( this.mMetaData.getInt("surface.transparent") != 0 ) { Log.v(TAG, "Surface will be transparent."); - mSurface.setZOrderOnTop(true); - mSurface.getHolder().setFormat(PixelFormat.TRANSPARENT); + getSurface().setZOrderOnTop(true); + getSurface().getHolder().setFormat(PixelFormat.TRANSPARENT); } else { Log.i(TAG, "Surface will NOT be transparent"); } diff --git a/pythonforandroid/bootstraps/sdl2/build/src/org/renpy/android/AssetExtract.java b/pythonforandroid/bootstraps/sdl2/build/src/org/renpy/android/AssetExtract.java index f1f077d7a1..52d6424e09 100644 --- a/pythonforandroid/bootstraps/sdl2/build/src/org/renpy/android/AssetExtract.java +++ b/pythonforandroid/bootstraps/sdl2/build/src/org/renpy/android/AssetExtract.java @@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) { break; } - Log.i("python", "extracting " + entry.getName()); + Log.v("python", "extracting " + entry.getName()); if (entry.isDirectory()) { From f891bdcf0c577b5d3f791d8662350ba450b738bf Mon Sep 17 00:00:00 2001 From: ibobalo Date: Tue, 27 Oct 2015 15:08:05 +0200 Subject: [PATCH 13/25] cosmetic toolchain logging outputs --- pythonforandroid/recipes/vlc/__init__.py | 19 ++------- pythonforandroid/toolchain.py | 53 ++++++++++++++++-------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/pythonforandroid/recipes/vlc/__init__.py b/pythonforandroid/recipes/vlc/__init__.py index 377b14255d..fbd9097822 100644 --- a/pythonforandroid/recipes/vlc/__init__.py +++ b/pythonforandroid/recipes/vlc/__init__.py @@ -55,22 +55,9 @@ def build_arch(self, arch): }) info("compiling vlc from sources") debug("environment: {}".format(env)) - try: - if not exists(join(port_dir, 'bin', 'VLC-debug.apk')): - shprint(sh.Command('./compile.sh'), _env=env) - shprint(sh.Command('./compile-libvlc.sh'), _env=env) - except sh.ErrorReturnCode_1, err: - warning("Error: vlc compilation failed") - lines = err.stdout.splitlines() - N = 20 - if len(lines) <= N: - info('STDOUT:\n{}\t{}{}'.format(Fore.YELLOW, '\t\n'.join(lines), Fore.RESET)) - else: - info('STDOUT (last {} lines of {}):\n{}\t{}{}'.format(N, len(lines), Fore.YELLOW, '\t\n'.join(lines[-N:]), Fore.RESET)) - lines = err.stderr.splitlines() - if len(lines): - warning('STDERR:\n{}\t{}{}'.format(Fore.RED, '\t\n'.join(lines), Fore.RESET)) - raise Exception("vlc compilation failed") + if not exists(join(port_dir, 'bin', 'VLC-debug.apk')): + shprint(sh.Command('./compile.sh'), _env=env, _tail=50, _critical=True) + shprint(sh.Command('./compile-libvlc.sh'), _env=env, _tail=50, _critical=True) shprint(sh.cp, '-a', aar, self.ctx.aars_dir) recipe = VlcRecipe() diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 63d0a6a249..505575cac4 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -127,24 +127,41 @@ def shprint(command, *args, **kwargs): else: logger.debug(string + Style.RESET_ALL) - output = command(*args, **kwargs) - need_closing_newline = False - for line in output: - if logger.level > logging.DEBUG: - string = ''.join([Style.RESET_ALL, '\r', ' '*11, 'working ... ', - line[:100].replace('\n', '').rstrip(), ' ...']) - if len(string) < 20: - continue - if len(string) < 120: - string = string + ' '*(120 - len(string)) - sys.stdout.write(string) - sys.stdout.flush() - need_closing_newline = True + try: + output = command(*args, **kwargs) + need_closing_newline = False + for line in output: + if logger.level > logging.DEBUG: + string = ''.join([Style.RESET_ALL, '\r', ' '*11, 'working ... ', + line[:100].replace('\n', '').rstrip(), ' ...']) + if len(string) < 20: + continue + if len(string) < 120: + string = string + ' '*(120 - len(string)) + sys.stdout.write(string) + sys.stdout.flush() + need_closing_newline = True + else: + logger.debug(''.join(['\t', line.rstrip()])) + if logger.level > logging.DEBUG and need_closing_newline: + print() + except sh.ErrorReturnCode_1, err: + N = kwargs.get('_tail', 0) + if N: + warning("Error: {} failed".format(command)) + lines = err.stdout.splitlines() + if len(lines) <= N: + info('STDOUT:\n{}\t{}{}'.format(Fore.YELLOW, '\t\n'.join(lines), Fore.RESET)) + else: + info('STDOUT (last {} lines of {}):\n{}\t{}{}'.format(N, len(lines), Fore.YELLOW, '\t\n'.join(lines[-N:]), Fore.RESET)) + lines = err.stderr.splitlines() + if len(lines): + warning('STDERR:\n{}\t{}{}'.format(Fore.RED, '\t\n'.join(lines), Fore.RESET)) + if kwargs.get('_critical', False): + exit(1) else: - logger.debug(''.join(['\t', line.rstrip()])) - if logger.level > logging.DEBUG and need_closing_newline: - print() - + raise + return output # shprint(sh.ls, '-lah') @@ -2849,7 +2866,7 @@ def apk(self, args): build = imp.load_source('build', join(dist.dist_dir, 'build.py')) with current_directory(dist.dist_dir): build.parse_args(args) - shprint(sh.ant, 'debug') + shprint(sh.ant, 'debug', _tail=20, _critical=True) # AND: This is very crude, needs improving. Also only works # for debug for now. From 02845114a03fa965684164179e1294c2e115cb02 Mon Sep 17 00:00:00 2001 From: ibobalo Date: Tue, 27 Oct 2015 16:59:53 +0200 Subject: [PATCH 14/25] cosmetic toolchain log output beautification --- .../bootstraps/sdl2/build/build.py | 2 +- pythonforandroid/toolchain.py | 44 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/pythonforandroid/bootstraps/sdl2/build/build.py b/pythonforandroid/bootstraps/sdl2/build/build.py index 2d598ef3b6..6803a428a0 100755 --- a/pythonforandroid/bootstraps/sdl2/build/build.py +++ b/pythonforandroid/bootstraps/sdl2/build/build.py @@ -166,7 +166,7 @@ def select(fn): tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT) dirs = [] for fn, afn in files: - print('%s: %s' % (tfn, fn)) +# print('%s: %s' % (tfn, fn)) dn = dirname(afn) if dn not in dirs: # create every dirs first if not exist yet diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 505575cac4..64dd97cb42 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -112,8 +112,14 @@ def shprint(command, *args, **kwargs): kwargs["_out_bufsize"] = 1 kwargs["_err_to_out"] = True kwargs["_bg"] = True + is_critical = kwargs.pop('_critical', False) + tail_n = kwargs.pop('_tail', 0) if len(logger.handlers) > 1: logger.removeHandler(logger.handlers[1]) + try: + columns = max(25, int(os.popen('stty size', 'r').read().split()[1])) + except: + columns = 100 command_path = str(command).split('/') command_string = command_path[-1] string = ' '.join(['running', command_string] + list(args)) @@ -121,43 +127,41 @@ def shprint(command, *args, **kwargs): # If logging is not in DEBUG mode, trim the command if necessary if logger.level > logging.DEBUG: short_string = string - if len(string) > 100: - short_string = string[:100] + '... (and {} more)'.format(len(string) - 100) + if len(string) > columns: + short_string = '{}...(and {} more)'.format(string[:(columns - 20)], len(string) - (columns - 20)) logger.info(short_string + Style.RESET_ALL) else: logger.debug(string + Style.RESET_ALL) + need_closing_newline = False try: + msg_hdr = ' working: ' + msg_width = columns - len(msg_hdr) - 1 output = command(*args, **kwargs) - need_closing_newline = False for line in output: if logger.level > logging.DEBUG: - string = ''.join([Style.RESET_ALL, '\r', ' '*11, 'working ... ', - line[:100].replace('\n', '').rstrip(), ' ...']) - if len(string) < 20: - continue - if len(string) < 120: - string = string + ' '*(120 - len(string)) - sys.stdout.write(string) - sys.stdout.flush() - need_closing_newline = True + msg = line.replace('\n', ' ').rstrip() + if msg: +# if len(msg) > msg_width: msg = msg[:(msg_width - 3)] + '...' + sys.stdout.write('{}\r{}{:<{width}.{width}}'.format(Style.RESET_ALL, msg_hdr, msg, width=msg_width)) + sys.stdout.flush() + need_closing_newline = True else: logger.debug(''.join(['\t', line.rstrip()])) - if logger.level > logging.DEBUG and need_closing_newline: - print() + if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1))) except sh.ErrorReturnCode_1, err: - N = kwargs.get('_tail', 0) - if N: - warning("Error: {} failed".format(command)) + if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1))) + if tail_n: lines = err.stdout.splitlines() - if len(lines) <= N: + if len(lines) <= tail_n: info('STDOUT:\n{}\t{}{}'.format(Fore.YELLOW, '\t\n'.join(lines), Fore.RESET)) else: - info('STDOUT (last {} lines of {}):\n{}\t{}{}'.format(N, len(lines), Fore.YELLOW, '\t\n'.join(lines[-N:]), Fore.RESET)) + info('STDOUT (last {} lines of {}):\n{}\t{}{}'.format(tail_n, len(lines), Fore.YELLOW, '\t\n'.join(lines[-tail_n:]), Fore.RESET)) lines = err.stderr.splitlines() if len(lines): warning('STDERR:\n{}\t{}{}'.format(Fore.RED, '\t\n'.join(lines), Fore.RESET)) - if kwargs.get('_critical', False): + if is_critical: + warning("{}ERROR: {} failed!{}".format(Fore.RED, command, Fore.RESET)) exit(1) else: raise From 9a036bb80aa5f197f86b5007520087a8685c6da6 Mon Sep 17 00:00:00 2001 From: ibobalo Date: Wed, 28 Oct 2015 10:49:30 +0200 Subject: [PATCH 15/25] added wakelock option for sdl2 bootstrap --- pythonforandroid/bootstraps/sdl2/build/build.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pythonforandroid/bootstraps/sdl2/build/build.py b/pythonforandroid/bootstraps/sdl2/build/build.py index 6803a428a0..8192606565 100755 --- a/pythonforandroid/bootstraps/sdl2/build/build.py +++ b/pythonforandroid/bootstraps/sdl2/build/build.py @@ -333,6 +333,9 @@ def parse_args(args=None): ap.add_argument('--presplash', dest='presplash', help=('A jpeg file to use as a screen while the ' 'application is loading.')) + ap.add_argument('--wakelock', dest='wakelock', action='store_true', + help=('Indicate if the application needs the device ' + 'to stay on')) if args is None: args = sys.argv[1:] From 1a36bc0a8d9c313f4ec8ea7b9a8281f8376a7334 Mon Sep 17 00:00:00 2001 From: ibobalo Date: Wed, 28 Oct 2015 11:22:17 +0200 Subject: [PATCH 16/25] toolchain log output cosmetic --- pythonforandroid/toolchain.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 694b6b7b49..ee96bd3c77 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -105,6 +105,12 @@ def pretty_log_dists(dists, log_func=info): for line in infos: log_func('\t' + line) +def shorten_string(string, width): + if len(string) <= width: + return string + visible = width - 20 #expected suffix len + return '{:<{width}}...(and {} more)'.format(string, len(string) - visible, width = visible) + def shprint(command, *args, **kwargs): '''Runs the command (which should be an sh.Command instance), while logging the output.''' @@ -117,21 +123,18 @@ def shprint(command, *args, **kwargs): if len(logger.handlers) > 1: logger.removeHandler(logger.handlers[1]) try: - columns = max(25, int(os.popen('stty size', 'r').read().split()[1])) + columns = max(25, int(os.popen('stty size', 'r').read().split()[1])) except: - columns = 100 + columns = 100 command_path = str(command).split('/') command_string = command_path[-1] string = ' '.join(['running', command_string] + list(args)) # If logging is not in DEBUG mode, trim the command if necessary if logger.level > logging.DEBUG: - short_string = string - if len(string) > columns: - short_string = '{}...(and {} more)'.format(string[:(columns - 20)], len(string) - (columns - 20)) - logger.info(short_string + Style.RESET_ALL) + logger.info('{}{}'.format(shorten_string(string, columns - 12), Style.RESET_ALL)) else: - logger.debug(string + Style.RESET_ALL) + logger.debug('{}{}'.format(string, Style.RESET_ALL)) need_closing_newline = False try: @@ -140,7 +143,7 @@ def shprint(command, *args, **kwargs): output = command(*args, **kwargs) for line in output: if logger.level > logging.DEBUG: - msg = line.replace('\n', ' ').rstrip() + msg = line.replace('\n', ' ').replace('\t', ' ').rstrip() if msg: # if len(msg) > msg_width: msg = msg[:(msg_width - 3)] + '...' sys.stdout.write('{}\r{}{:<{width}.{width}}'.format(Style.RESET_ALL, msg_hdr, msg, width=msg_width)) From 427595507bd139de6b4011d9375cb58c8ebee1f2 Mon Sep 17 00:00:00 2001 From: ibobalo Date: Wed, 28 Oct 2015 11:49:56 +0200 Subject: [PATCH 17/25] toolchain log output cosmetic --- pythonforandroid/toolchain.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index ee96bd3c77..0cfc8dae0f 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -30,6 +30,7 @@ from datetime import datetime from distutils.spawn import find_executable from tempfile import mkdtemp +from math import log10 try: from urllib.request import FancyURLopener except ImportError: @@ -105,11 +106,15 @@ def pretty_log_dists(dists, log_func=info): for line in infos: log_func('\t' + line) -def shorten_string(string, width): - if len(string) <= width: +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 = width - 20 #expected suffix len - return '{:<{width}}...(and {} more)'.format(string, len(string) - visible, width = visible) + visible = max_width - 16 - int(log10(string_len)) #expected suffix len "...(and XXXXX more)" + return ''.join(string[:visible], '...(and ', string_len - visible, ' more)') def shprint(command, *args, **kwargs): '''Runs the command (which should be an sh.Command instance), while @@ -146,7 +151,7 @@ def shprint(command, *args, **kwargs): msg = line.replace('\n', ' ').replace('\t', ' ').rstrip() if msg: # if len(msg) > msg_width: msg = msg[:(msg_width - 3)] + '...' - sys.stdout.write('{}\r{}{:<{width}.{width}}'.format(Style.RESET_ALL, msg_hdr, msg, width=msg_width)) + sys.stdout.write('{}\r{}{:<{width}}'.format(Style.RESET_ALL, msg_hdr, shorten_string(msg, msg_width), width=msg_width)) sys.stdout.flush() need_closing_newline = True else: From f9b39763316bc83e73df970d23f50b8f1e1f8c1c Mon Sep 17 00:00:00 2001 From: ibobalo Date: Wed, 28 Oct 2015 12:01:40 +0200 Subject: [PATCH 18/25] toolchain log output cosmetic --- pythonforandroid/toolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 0cfc8dae0f..d3d22a27dc 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -114,7 +114,7 @@ def shorten_string(string, max_width): 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 ', string_len - visible, ' 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 From d1f165481f00e372aeb71ad44bf956888f8f49aa Mon Sep 17 00:00:00 2001 From: ibobalo Date: Thu, 29 Oct 2015 11:29:06 +0200 Subject: [PATCH 19/25] vlc recipe procompiled aar bundle handling improved --- pythonforandroid/recipes/vlc/__init__.py | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/pythonforandroid/recipes/vlc/__init__.py b/pythonforandroid/recipes/vlc/__init__.py index fbd9097822..a10d9eb03c 100644 --- a/pythonforandroid/recipes/vlc/__init__.py +++ b/pythonforandroid/recipes/vlc/__init__.py @@ -14,37 +14,42 @@ class VlcRecipe(Recipe): port_git = 'http://git.videolan.org/git/vlc-ports/android.git' vlc_git = 'http://git.videolan.org/git/vlc.git' ENV_LIBVLC_AAR = 'LIBVLC_AAR' + aars = {} # for future use of multiple arch def prebuild_arch(self, arch): super(VlcRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) port_dir = join(build_dir, 'vlc-port-android') - aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') - aar = environ.get(self.ENV_LIBVLC_AAR, - join(aar_path, 'libvlc-{}.aar'.format(self.version))) - if not exists(aar): - if environ.has_key(''): - warning("Error: libvlc-.aar bundle not found in {}".format(aar)) + if self.ENV_LIBVLC_AAR in environ: + self.aars[arch] = aar = environ.get(self.ENV_LIBVLC_AAR) + if not exists(aar): + warning("Error: libvlc-.aar bundle " \ + "not found in {}".format(aar)) info("check {} environment!".format(self.ENV_LIBVLC_AAR)) - raise Exception("vlc .aar bundle not found by path specified in {}".format(self.ENV_LIBVLC_AAR)) - warning("set path to precompiled libvlc-.aar bundle in {} environment!".format(self.ENV_LIBVLC_AAR)) - info("libvlc-.aar for android not found!") - info("should build from sources at {}".format(port_dir)) + exit(1) + else: + aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') + self.aars[arch] = aar = join(aar_path, 'libvlc-{}.aar'.format(self.version)) + warning("HINT: set path to precompiled libvlc-.aar bundle " \ + "in {} environment!".format(self.ENV_LIBVLC_AAR)) + info("libvlc-.aar should build " \ + "from sources at {}".format(port_dir)) if not exists(join(port_dir, 'compile.sh')): - info("clone vlc port for android sources from {}".format(self.port_git)) - shprint(sh.git, 'clone', self.port_git, port_dir) + info("clone vlc port for android sources from {}".format( + self.port_git)) + shprint(sh.git, 'clone', self.port_git, port_dir, + _tail=20, _critical=True) vlc_dir = join(port_dir, 'vlc') if not exists(join(vlc_dir, 'Makefile.am')): info("clone vlc sources from {}".format(self.vlc_git)) - shprint(sh.git, 'clone', self.vlc_git, vlc_dir) + shprint(sh.git, 'clone', self.vlc_git, vlc_dir, + _tail=20, _critical=True) def build_arch(self, arch): super(VlcRecipe, self).build_arch(arch) build_dir = self.get_build_dir(arch.arch) port_dir = join(build_dir, 'vlc-port-android') - aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') - aar = environ.get(self.ENV_LIBVLC_AAR, - join(aar_path, 'libvlc-{}.aar'.format(self.version))) + aar = self.aars[arch] if not exists(aar): with current_directory(port_dir): env = dict(environ) @@ -55,9 +60,11 @@ def build_arch(self, arch): }) info("compiling vlc from sources") debug("environment: {}".format(env)) - if not exists(join(port_dir, 'bin', 'VLC-debug.apk')): - shprint(sh.Command('./compile.sh'), _env=env, _tail=50, _critical=True) - shprint(sh.Command('./compile-libvlc.sh'), _env=env, _tail=50, _critical=True) + if not exists(join('bin', 'VLC-debug.apk')): + shprint(sh.Command('./compile.sh'), _env=env, + _tail=50, _critical=True) + shprint(sh.Command('./compile-libvlc.sh'), _env=env, + _tail=50, _critical=True) shprint(sh.cp, '-a', aar, self.ctx.aars_dir) recipe = VlcRecipe() From e80090801a49a909c41317b69efbfe5123ac4fae Mon Sep 17 00:00:00 2001 From: ibobalo Date: Thu, 29 Oct 2015 13:31:09 +0200 Subject: [PATCH 20/25] toolchain log output cosmetic --- pythonforandroid/bootstraps/pygame/build/build.py | 2 +- .../pygame/build/src/org/renpy/android/AssetExtract.java | 2 +- pythonforandroid/toolchain.py | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/build/build.py b/pythonforandroid/bootstraps/pygame/build/build.py index 462dd29998..95f80a0444 100755 --- a/pythonforandroid/bootstraps/pygame/build/build.py +++ b/pythonforandroid/bootstraps/pygame/build/build.py @@ -183,7 +183,7 @@ def select(fn): tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT) dirs = [] for fn, afn in files: - print('%s: %s' % (tfn, fn)) +# print('%s: %s' % (tfn, fn)) dn = dirname(afn) if dn not in dirs: # create every dirs first if not exist yet diff --git a/pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/AssetExtract.java b/pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/AssetExtract.java index e1d810798a..dd4ec48fc3 100644 --- a/pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/AssetExtract.java +++ b/pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/AssetExtract.java @@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) { break; } - Log.i("python", "extracting " + entry.getName()); + Log.v("python", "extracting " + entry.getName()); if (entry.isDirectory()) { diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index d3d22a27dc..87c74ce6b8 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -111,8 +111,7 @@ def shorten_string(string, max_width): "the string is very lo...(and 15 more)" ''' string_len = len(string) - if string_len <= max_width: - return 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)')) @@ -148,7 +147,7 @@ def shprint(command, *args, **kwargs): output = command(*args, **kwargs) for line in output: if logger.level > logging.DEBUG: - msg = line.replace('\n', ' ').replace('\t', ' ').rstrip() + msg = line.replace('\n', ' ').replace('\t', ' ').replace('\b', ' ').rstrip() if msg: # if len(msg) > msg_width: msg = msg[:(msg_width - 3)] + '...' sys.stdout.write('{}\r{}{:<{width}}'.format(Style.RESET_ALL, msg_hdr, shorten_string(msg, msg_width), width=msg_width)) @@ -157,7 +156,7 @@ def shprint(command, *args, **kwargs): else: logger.debug(''.join(['\t', line.rstrip()])) if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1))) - except sh.ErrorReturnCode_1, err: + except sh.ErrorReturnCode, err: if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1))) if tail_n: lines = err.stdout.splitlines() From 07b61c575f047c4bcb19fd5bb6ae1a5bacf7a67f Mon Sep 17 00:00:00 2001 From: ibobalo Date: Fri, 30 Oct 2015 18:38:53 +0200 Subject: [PATCH 21/25] toolchain: improved functions to apply recipe patches --- pythonforandroid/toolchain.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 87c74ce6b8..fc0f1e6961 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -1564,15 +1564,30 @@ def extract_source(self, source, cwd): # print("Unrecognized extension for {}".format(filename)) # raise Exception() - def apply_patch(self, filename): + def apply_patch(self, filename, arch='armeabi'): """ Apply a patch from the current recipe directory into the current build directory. """ info("Applying patch {}".format(filename)) filename = join(self.recipe_dir, filename) - # AND: get_build_dir shouldn't need to hardcode armeabi - sh.patch("-t", "-d", self.get_build_dir('armeabi'), "-p1", "-i", filename) + shprint(sh.patch, "-t", "-d", self.get_build_dir(arch), "-p1", + "-i", filename, _tail=10) + + def apply_all_patches(self, wildcard=join('patches','*.patch'), arch='armeabi'): + patches = glob.glob(join(self.recipe_dir, wildcard)) + if not patches: + warning('requested patches {} not found for {}'.format(wildcard, self.name)) + for filename in sorted(patches): + name = splitext(basename(filename))[0] + patched_flag = join(self.get_build_container_dir(arch), name + '.patched') + if exists(patched_flag): + info('patch {} already applied to {}, skipping'.format(name, self.name)) + else: + self.apply_patch(filename, arch=arch) + sh.touch(patched_flag) + return len(patches) + def copy_file(self, filename, dest): info("Copy {} to {}".format(filename, dest)) From e3f0f2e5699c712272b9be9a49e853ae31e468d5 Mon Sep 17 00:00:00 2001 From: ibobalo Date: Wed, 4 Nov 2015 10:21:40 +0200 Subject: [PATCH 22/25] toolchain log output cosmetic --- pythonforandroid/toolchain.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index fc0f1e6961..233721c163 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -2168,7 +2168,8 @@ def build_cython_components(self, arch): self.ctx.cython, '{}', ';', _env=env) info('ran cython') - shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env) + shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env, + _tail=20, _critical=True) print('stripping') build_lib = glob.glob('./build/lib*') From 8ae6758dbc3f9610b3d39a0ed743e33f812497f6 Mon Sep 17 00:00:00 2001 From: ibobalo Date: Wed, 4 Nov 2015 13:15:45 +0200 Subject: [PATCH 23/25] cosmetic logs --- .../sdl2python3/build/src/org/renpy/android/AssetExtract.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/bootstraps/sdl2python3/build/src/org/renpy/android/AssetExtract.java b/pythonforandroid/bootstraps/sdl2python3/build/src/org/renpy/android/AssetExtract.java index f1f077d7a1..52d6424e09 100644 --- a/pythonforandroid/bootstraps/sdl2python3/build/src/org/renpy/android/AssetExtract.java +++ b/pythonforandroid/bootstraps/sdl2python3/build/src/org/renpy/android/AssetExtract.java @@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) { break; } - Log.i("python", "extracting " + entry.getName()); + Log.v("python", "extracting " + entry.getName()); if (entry.isDirectory()) { From 5bdaf52850fbc50fcbaab2b183bb58d6b9681722 Mon Sep 17 00:00:00 2001 From: ibobalo Date: Mon, 9 Nov 2015 14:19:37 +0200 Subject: [PATCH 24/25] toolchain log output cosmetic --- pythonforandroid/bootstraps/pygame/__init__.py | 3 ++- pythonforandroid/recipes/pygame/__init__.py | 3 ++- pythonforandroid/recipes/sdl/__init__.py | 2 +- pythonforandroid/toolchain.py | 16 ++++++++-------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 5b07a0865e..362a5a5272 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -43,7 +43,8 @@ def run_distribute(self): info('Copying python distribution') 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()) + shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(), + _tail=10, _critical=True) if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') diff --git a/pythonforandroid/recipes/pygame/__init__.py b/pythonforandroid/recipes/pygame/__init__.py index f720b3c830..6fcf33b500 100644 --- a/pythonforandroid/recipes/pygame/__init__.py +++ b/pythonforandroid/recipes/pygame/__init__.py @@ -60,7 +60,8 @@ def build_armeabi(self): with current_directory(self.get_build_dir('armeabi')): info('hostpython is ' + self.ctx.hostpython) hostpython = sh.Command(self.ctx.hostpython) - shprint(hostpython, 'setup.py', 'install', '-O2', _env=env) + shprint(hostpython, 'setup.py', 'install', '-O2', _env=env, + _tail=10, _critical=True) info('strip is ' + env['STRIP']) build_lib = glob.glob('./build/lib*') diff --git a/pythonforandroid/recipes/sdl/__init__.py b/pythonforandroid/recipes/sdl/__init__.py index 9f46d465f4..1da3999d26 100644 --- a/pythonforandroid/recipes/sdl/__init__.py +++ b/pythonforandroid/recipes/sdl/__init__.py @@ -18,7 +18,7 @@ def build_armeabi(self): env = ArchAndroid(self.ctx).get_env() with current_directory(self.get_jni_dir()): - shprint(sh.ndk_build, 'V=1', _env=env) + shprint(sh.ndk_build, 'V=1', _env=env, _tail=20, _critical=True) libs_dir = join(self.ctx.bootstrap.build_dir, 'libs', 'armeabi') import os diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 233721c163..90b8bd35a2 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -159,14 +159,14 @@ def shprint(command, *args, **kwargs): except sh.ErrorReturnCode, err: if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1))) if tail_n: - lines = err.stdout.splitlines() - if len(lines) <= tail_n: - info('STDOUT:\n{}\t{}{}'.format(Fore.YELLOW, '\t\n'.join(lines), Fore.RESET)) - else: - info('STDOUT (last {} lines of {}):\n{}\t{}{}'.format(tail_n, len(lines), Fore.YELLOW, '\t\n'.join(lines[-tail_n:]), Fore.RESET)) - lines = err.stderr.splitlines() - if len(lines): - warning('STDERR:\n{}\t{}{}'.format(Fore.RED, '\t\n'.join(lines), Fore.RESET)) + def printtail(name, forecolor, tail_n, out): + lines = out.splitlines() + if tail_n == 0 or len(lines) <= tail_n: + info('{}:\n{}\t{}{}'.format(name, forecolor, '\t\n'.join(lines), Fore.RESET)) + else: + info('{} (last {} lines of {}):\n{}\t{}{}'.format(name, tail_n, len(lines), forecolor, '\t\n'.join(lines[-tail_n:]), Fore.RESET)) + printtail('STDOUT', Fore.YELLOW, tail_n, err.stdout) + printtail('STDERR', Fore.RED, 0, err.stderr) if is_critical: warning("{}ERROR: {} failed!{}".format(Fore.RED, command, Fore.RESET)) exit(1) From 4407cfa423ff4c7df72f86773aed2ac865dd8f6a Mon Sep 17 00:00:00 2001 From: ibobalo Date: Wed, 11 Nov 2015 17:17:20 +0200 Subject: [PATCH 25/25] toolchain log output cosmetic --- pythonforandroid/bootstraps/pygame/__init__.py | 2 +- pythonforandroid/bootstraps/sdl2/__init__.py | 3 ++- pythonforandroid/toolchain.py | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index 362a5a5272..a0ddaac626 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -44,7 +44,7 @@ def run_distribute(self): 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, _critical=True) + _tail=10, _filterout="^Listing", _critical=True) if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index fcc1b20fe0..10c9e0f118 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -34,7 +34,8 @@ def run_distribute(self): 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()) + self.ctx.get_python_install_dir(), + _tail=10, _filterout="^Listing", _critical=True) if not exists('python-install'): shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install') diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 08c0528357..a18a37a7a8 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -127,6 +127,8 @@ def shprint(command, *args, **kwargs): kwargs["_bg"] = True is_critical = kwargs.pop('_critical', False) tail_n = kwargs.pop('_tail', 0) + filter_in = kwargs.pop('_filter', None) + filter_out = kwargs.pop('_filterout', None) if len(logger.handlers) > 1: logger.removeHandler(logger.handlers[1]) try: @@ -161,16 +163,24 @@ def shprint(command, *args, **kwargs): if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1))) except sh.ErrorReturnCode, err: if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1))) - if tail_n: - def printtail(name, forecolor, tail_n, out): + if tail_n or filter_in or filter_out: + def printtail(out, name, forecolor, tail_n = 0, re_filter_in = None, re_filter_out = None): lines = out.splitlines() + if re_filter_in is not None: lines = [l for l in lines if re_filter_in.search(l)] + if re_filter_out is not None: lines = [l for l in lines if not re_filter_out.search(l)] if tail_n == 0 or len(lines) <= tail_n: info('{}:\n{}\t{}{}'.format(name, forecolor, '\t\n'.join(lines), Fore.RESET)) else: info('{} (last {} lines of {}):\n{}\t{}{}'.format(name, tail_n, len(lines), forecolor, '\t\n'.join(lines[-tail_n:]), Fore.RESET)) - printtail('STDOUT', Fore.YELLOW, tail_n, err.stdout) - printtail('STDERR', Fore.RED, 0, err.stderr) + printtail(err.stdout, 'STDOUT', Fore.YELLOW, tail_n, + re.compile(filter_in) if filter_in else None, + re.compile(filter_out) if filter_out else None) + printtail(err.stderr, 'STDERR', Fore.RED) if is_critical: + env = kwargs.get("env") + if env is not None: + info("{}ENV:{}\n{}\n".format(Fore.YELLOW, Fore.RESET, "\n".join("set {}={}".format(n,v) for n,v in env.items()))) + info("{}COMMAND:{}\ncd {} && {} {}\n".format(Fore.YELLOW, Fore.RESET, getcwd(), command, ' '.join(args))) warning("{}ERROR: {} failed!{}".format(Fore.RED, command, Fore.RESET)) exit(1) else: