Skip to content

Commit df71736

Browse files
committed
Merge branch 'master' of github.com:kivy/python-for-android
2 parents ac0b79e + fc56c99 commit df71736

19 files changed

+468
-7
lines changed

pythonforandroid/build.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,12 @@ def run_pymodules_install(ctx, modules):
585585
info('Creating a requirements.txt file for the Python modules')
586586
with open('requirements.txt', 'w') as fileh:
587587
for module in modules:
588-
fileh.write('{}\n'.format(module))
588+
key = 'VERSION_' + module
589+
if key in environ:
590+
line = '{}=={}\n'.format(module, environ[key])
591+
else:
592+
line = '{}\n'.format(module)
593+
fileh.write(line)
589594

590595
info('Installing Python modules with pip')
591596
info('If this fails with a message about /bin/false, this '

pythonforandroid/recipe.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import importlib
33
import zipfile
44
import glob
5-
from six import PY2
5+
from six import PY2, with_metaclass
66

77
import sh
88
import shutil
@@ -37,8 +37,19 @@ def import_recipe(module, filename):
3737
return SourceFileLoader(module, filename).load_module()
3838

3939

40-
class Recipe(object):
41-
url = None
40+
class RecipeMeta(type):
41+
def __new__(cls, name, bases, dct):
42+
if name != 'Recipe':
43+
if 'url' in dct:
44+
dct['_url'] = dct.pop('url')
45+
if 'version' in dct:
46+
dct['_version'] = dct.pop('version')
47+
48+
return super(RecipeMeta, cls).__new__(cls, name, bases, dct)
49+
50+
51+
class Recipe(with_metaclass(RecipeMeta)):
52+
_url = None
4253
'''The address from which the recipe may be downloaded. This is not
4354
essential, it may be omitted if the source is available some other
4455
way, such as via the :class:`IncludedFilesBehaviour` mixin.
@@ -52,7 +63,7 @@ class Recipe(object):
5263
if you want.
5364
'''
5465

55-
version = None
66+
_version = None
5667
'''A string giving the version of the software the recipe describes,
5768
e.g. ``2.0.3`` or ``master``.'''
5869

@@ -88,6 +99,16 @@ class Recipe(object):
8899

89100
archs = ['armeabi'] # Not currently implemented properly
90101

102+
@property
103+
def version(self):
104+
key = 'VERSION_' + self.name
105+
return environ.get(key, self._version)
106+
107+
@property
108+
def url(self):
109+
key = 'URL_' + self.name
110+
return environ.get(key, self._url)
111+
91112
@property
92113
def versioned_url(self):
93114
'''A property returning the url of the recipe with ``{version}``
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
APP_OPTIM := release
2+
APP_ABI := all # or armeabi
3+
APP_MODULES := libjpeg
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from pythonforandroid.recipe import NDKRecipe
2+
from pythonforandroid.logger import shprint
3+
from os.path import join, exists
4+
import sh
5+
6+
7+
class JpegRecipe(NDKRecipe):
8+
name = 'jpeg'
9+
version = 'linaro-android'
10+
url = 'git://git.linaro.org/people/tomgall/libjpeg-turbo/libjpeg-turbo.git'
11+
12+
patches = ['build-static.patch']
13+
14+
generated_libraries = ['libjpeg.a']
15+
16+
def prebuild_arch(self, arch):
17+
super(JpegRecipe, self).prebuild_arch(arch)
18+
19+
build_dir = self.get_build_dir(arch.arch)
20+
app_mk = join(build_dir, 'Application.mk')
21+
if not exists(app_mk):
22+
shprint(sh.cp, join(self.get_recipe_dir(), 'Application.mk'), app_mk)
23+
jni_ln = join(build_dir, 'jni')
24+
if not exists(jni_ln):
25+
shprint(sh.ln, '-s', build_dir, jni_ln)
26+
27+
28+
recipe = JpegRecipe()
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
diff -Naur jpeg/Android.mk b/Android.mk
2+
--- jpeg/Android.mk 2015-12-14 11:37:25.900190235 -0600
3+
+++ b/Android.mk 2015-12-14 11:41:27.532182210 -0600
4+
@@ -54,8 +54,7 @@
5+
6+
LOCAL_SRC_FILES:= $(libjpeg_SOURCES_DIST)
7+
8+
-LOCAL_SHARED_LIBRARIES := libcutils
9+
-LOCAL_STATIC_LIBRARIES := libsimd
10+
+LOCAL_STATIC_LIBRARIES := libsimd libcutils
11+
12+
LOCAL_C_INCLUDES := $(LOCAL_PATH)
13+
14+
@@ -68,7 +67,7 @@
15+
16+
LOCAL_MODULE := libjpeg
17+
18+
-include $(BUILD_SHARED_LIBRARY)
19+
+include $(BUILD_STATIC_LIBRARY)
20+
21+
######################################################
22+
### cjpeg ###
23+
@@ -82,7 +81,7 @@
24+
25+
LOCAL_SRC_FILES:= $(cjpeg_SOURCES)
26+
27+
-LOCAL_SHARED_LIBRARIES := libjpeg
28+
+LOCAL_STATIC_LIBRARIES := libjpeg
29+
30+
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
31+
$(LOCAL_PATH)/android
32+
@@ -110,7 +109,7 @@
33+
34+
LOCAL_SRC_FILES:= $(djpeg_SOURCES)
35+
36+
-LOCAL_SHARED_LIBRARIES := libjpeg
37+
+LOCAL_STATIC_LIBRARIES := libjpeg
38+
39+
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
40+
$(LOCAL_PATH)/android
41+
@@ -137,7 +136,7 @@
42+
43+
LOCAL_SRC_FILES:= $(jpegtran_SOURCES)
44+
45+
-LOCAL_SHARED_LIBRARIES := libjpeg
46+
+LOCAL_STATIC_LIBRARIES := libjpeg
47+
48+
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
49+
$(LOCAL_PATH)/android
50+
@@ -163,7 +162,7 @@
51+
52+
LOCAL_SRC_FILES:= $(tjunittest_SOURCES)
53+
54+
-LOCAL_SHARED_LIBRARIES := libjpeg
55+
+LOCAL_STATIC_LIBRARIES := libjpeg
56+
57+
LOCAL_C_INCLUDES := $(LOCAL_PATH)
58+
59+
@@ -189,7 +188,7 @@
60+
61+
LOCAL_SRC_FILES:= $(tjbench_SOURCES)
62+
63+
-LOCAL_SHARED_LIBRARIES := libjpeg
64+
+LOCAL_STATIC_LIBRARIES := libjpeg
65+
66+
LOCAL_C_INCLUDES := $(LOCAL_PATH)
67+
68+
@@ -215,7 +214,7 @@
69+
70+
LOCAL_SRC_FILES:= $(rdjpgcom_SOURCES)
71+
72+
-LOCAL_SHARED_LIBRARIES := libjpeg
73+
+LOCAL_STATIC_LIBRARIES := libjpeg
74+
75+
LOCAL_C_INCLUDES := $(LOCAL_PATH)
76+
77+
@@ -240,7 +239,7 @@
78+
79+
LOCAL_SRC_FILES:= $(wrjpgcom_SOURCES)
80+
81+
-LOCAL_SHARED_LIBRARIES := libjpeg
82+
+LOCAL_STATIC_LIBRARIES := libjpeg
83+
84+
LOCAL_C_INCLUDES := $(LOCAL_PATH)
85+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
asdgasdgasdg
2+
asdg
3+
asdg
4+
include(${CMAKE_ROOT}/Modules/Platform/Linux.cmake)
5+
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from pythonforandroid.logger import shprint
2+
from pythonforandroid.recipe import Recipe
3+
from pythonforandroid.util import current_directory
4+
import sh
5+
from os.path import join
6+
7+
8+
class LibmysqlclientRecipe(Recipe):
9+
name = 'libmysqlclient'
10+
version = 'master'
11+
url = 'https://github.com/0x-ff/libmysql-android/archive/{version}.zip'
12+
# version = '5.5.47'
13+
# url = 'http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-{version}.tar.gz'
14+
#
15+
# depends = ['ncurses']
16+
#
17+
18+
# patches = ['add-custom-platform.patch']
19+
20+
patches = ['disable-soversion.patch']
21+
22+
def should_build(self, arch):
23+
return not self.has_libs(arch, 'libmysql.so')
24+
25+
def build_arch(self, arch):
26+
env = self.get_recipe_env(arch)
27+
with current_directory(join(self.get_build_dir(arch.arch), 'libmysqlclient')):
28+
shprint(sh.cp, '-t', '.', join(self.get_recipe_dir(), 'p4a.cmake'))
29+
# shprint(sh.mkdir, 'Platform')
30+
# shprint(sh.cp, '-t', 'Platform', join(self.get_recipe_dir(), 'Linux.cmake'))
31+
shprint(sh.rm, '-f', 'CMakeCache.txt')
32+
shprint(sh.cmake, '-G', 'Unix Makefiles',
33+
# '-DCMAKE_MODULE_PATH=' + join(self.get_build_dir(arch.arch), 'libmysqlclient'),
34+
'-DCMAKE_INSTALL_PREFIX=./install',
35+
'-DCMAKE_TOOLCHAIN_FILE=p4a.cmake', _env=env)
36+
shprint(sh.make, _env=env)
37+
38+
self.install_libs(arch, join('libmysql', 'libmysql.so'))
39+
40+
# def get_recipe_env(self, arch=None):
41+
# env = super(LibmysqlclientRecipe, self).get_recipe_env(arch)
42+
# env['WITHOUT_SERVER'] = 'ON'
43+
# ncurses = self.get_recipe('ncurses', self)
44+
# # env['CFLAGS'] += ' -I' + join(ncurses.get_build_dir(arch.arch),
45+
# # 'include')
46+
# env['CURSES_LIBRARY'] = join(self.ctx.get_libs_dir(arch.arch), 'libncurses.so')
47+
# env['CURSES_INCLUDE_PATH'] = join(ncurses.get_build_dir(arch.arch),
48+
# 'include')
49+
# return env
50+
#
51+
# def build_arch(self, arch):
52+
# env = self.get_recipe_env(arch)
53+
# with current_directory(self.get_build_dir(arch.arch)):
54+
# # configure = sh.Command('./configure')
55+
# # TODO: should add openssl as an optional dep and compile support
56+
# # shprint(configure, '--enable-shared', '--enable-assembler',
57+
# # '--enable-thread-safe-client', '--with-innodb',
58+
# # '--without-server', _env=env)
59+
# # shprint(sh.make, _env=env)
60+
# shprint(sh.cmake, '.', '-DCURSES_LIBRARY=' + env['CURSES_LIBRARY'],
61+
# '-DCURSES_INCLUDE_PATH=' + env['CURSES_INCLUDE_PATH'], _env=env)
62+
# shprint(sh.make, _env=env)
63+
#
64+
# self.install_libs(arch, 'libmysqlclient.so')
65+
66+
67+
recipe = LibmysqlclientRecipe()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--- libmysqlclient/libmysqlclient/libmysql/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
2+
+++ b/libmysqlclient/libmysql/CMakeLists.txt 2016-01-11 13:28:51.142356988 -0600
3+
@@ -152,3 +152,5 @@
4+
${CMAKE_SOURCE_DIR}/libmysql/libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}
5+
DESTINATION "lib")
6+
ENDIF(WIN32)
7+
+
8+
+LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_PREFIX}")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- libmysqlclient/libmysqlclient/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
2+
+++ b/libmysqlclient/CMakeLists.txt 2016-01-11 13:48:41.672323738 -0600
3+
@@ -24,6 +24,8 @@
4+
SET(CMAKE_BUILD_TYPE "Release")
5+
ENDIF(NOT CMAKE_BUILD_TYPE)
6+
7+
+SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")
8+
+
9+
# This reads user configuration, generated by configure.js.
10+
IF(WIN32 AND EXISTS ${CMAKE_SOURCE_DIR}/win/configure.data)
11+
INCLUDE(${CMAKE_SOURCE_DIR}/win/configure.data)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- libmysqlclient/libmysqlclient/libmysql/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
2+
+++ b/libmysqlclient/libmysql/CMakeLists.txt 2016-01-11 14:00:26.729332913 -0600
3+
@@ -97,9 +97,6 @@
4+
ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} libmysql.def)
5+
TARGET_LINK_LIBRARIES(libmysql ${CMAKE_THREAD_LIBS_INIT})
6+
STRING(REGEX REPLACE "\\..+" "" LIBMYSQL_SOVERSION ${SHARED_LIB_VERSION})
7+
-SET_TARGET_PROPERTIES(libmysql
8+
- PROPERTIES VERSION ${SHARED_LIB_VERSION}
9+
- SOVERSION ${LIBMYSQL_SOVERSION})
10+
IF(OPENSSL_LIBRARIES)
11+
TARGET_LINK_LIBRARIES(libmysql ${OPENSSL_LIBRARIES} ${OPENSSL_LIBCRYPTO})
12+
ENDIF(OPENSSL_LIBRARIES)

0 commit comments

Comments
 (0)