From fbab0f2163c1cc3ccd0f042952a731f4fec0042b Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Mon, 21 Apr 2014 14:17:13 +0200 Subject: [PATCH] add support for copying libraries for armeabi, armeabi-v7a, x86, mips. closes #63 --- buildozer/__init__.py | 10 ++++++++++ buildozer/default.spec | 3 +++ buildozer/targets/android.py | 29 ++++++++++++++++------------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/buildozer/__init__.py b/buildozer/__init__.py index 3c74903..d641124 100644 --- a/buildozer/__init__.py +++ b/buildozer/__init__.py @@ -535,6 +535,16 @@ class Buildozer(object): self.debug('Remove directory and subdirectory {}'.format(dn)) rmtree(dn) + def file_matches(self, patterns): + from glob import glob + result = [] + for pattern in patterns: + matches = glob(expanduser(pattern.strip())) + if not matches: + return + result.extend(matches) + return result + def file_exists(self, *args): return exists(join(*args)) diff --git a/buildozer/default.spec b/buildozer/default.spec index e21a1cc..981fc86 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -113,6 +113,9 @@ fullscreen = 1 # (list) Android additionnal libraries to copy into libs/armeabi #android.add_libs_armeabi = libs/android/*.so +#android.add_libs_armeabi_v7a = libs/android-v7/*.so +#android.add_libs_x86 = libs/android-x86/*.so +#android.add_libs_mips = libs/android-mips/*.so # (bool) Indicate whether the screen should stay on # Don't forget to add the WAKE_LOCK permission if you set this to True diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index af9a860..fb58427 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -450,19 +450,22 @@ class TargetAndroid(Target): version = self.buildozer.get_version() # add extra libs/armeabi files in dist/default/libs/armeabi - # XXX to the same for x86 and v7a - add_libs_armeabi = config.getlist('app', 'android.add_libs_armeabi', []) - for pattern in add_libs_armeabi: - matches = glob(expanduser(pattern.strip())) - if matches: - for fn in matches: - self.buildozer.file_copy( - join(self.buildozer.root_dir, fn), - join(dist_dir, 'libs', 'armeabi', basename(fn))) - else: - raise SystemError( - 'Failed to find libs_armeabi files: {}'.format( - pattern)) + # (same for armeabi-v7a, x86, mips) + for config_key, lib_dir in ( + ('android.add_libs_armeabi', 'armeabi'), + ('android.add_libs_armeabi_v7a', 'armeabi-v7a'), + ('android.add_libs_x86', 'x86'), + ('android.add_libs_mips', 'mips')): + + patterns = config.getlist('app', config_key, []) + if not patterns: + continue + + self.debug('Search and copy libs for {}'.format(lib_dir)) + for fn in self.buildozer.file_matches(patterns): + self.buildozer.file_copy( + join(self.buildozer.root_dir, fn), + join(dist_dir, 'libs', lib_dir, basename(fn))) # update the project.properties libraries references self._update_libraries_references(dist_dir)