Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pythonforandroid/recipes/libmysqlclient/Linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
asdgasdgasdg
asdg
asdg
include(${CMAKE_ROOT}/Modules/Platform/Linux.cmake)
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")
67 changes: 67 additions & 0 deletions pythonforandroid/recipes/libmysqlclient/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from pythonforandroid.logger import shprint
from pythonforandroid.recipe import Recipe
from pythonforandroid.util import current_directory
import sh
from os.path import join


class LibmysqlclientRecipe(Recipe):
name = 'libmysqlclient'
version = 'master'
url = 'https://github.com/0x-ff/libmysql-android/archive/{version}.zip'
# version = '5.5.47'
# url = 'http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-{version}.tar.gz'
#
# depends = ['ncurses']
#

# patches = ['add-custom-platform.patch']

patches = ['disable-soversion.patch']

def should_build(self, arch):
return not self.has_libs(arch, 'libmysql.so')

def build_arch(self, arch):
env = self.get_recipe_env(arch)
with current_directory(join(self.get_build_dir(arch.arch), 'libmysqlclient')):
shprint(sh.cp, '-t', '.', join(self.get_recipe_dir(), 'p4a.cmake'))
# shprint(sh.mkdir, 'Platform')
# shprint(sh.cp, '-t', 'Platform', join(self.get_recipe_dir(), 'Linux.cmake'))
shprint(sh.rm, '-f', 'CMakeCache.txt')
shprint(sh.cmake, '-G', 'Unix Makefiles',
# '-DCMAKE_MODULE_PATH=' + join(self.get_build_dir(arch.arch), 'libmysqlclient'),
'-DCMAKE_INSTALL_PREFIX=./install',
'-DCMAKE_TOOLCHAIN_FILE=p4a.cmake', _env=env)
shprint(sh.make, _env=env)

self.install_libs(arch, join('libmysql', 'libmysql.so'))

# def get_recipe_env(self, arch=None):
# env = super(LibmysqlclientRecipe, self).get_recipe_env(arch)
# env['WITHOUT_SERVER'] = 'ON'
# ncurses = self.get_recipe('ncurses', self)
# # env['CFLAGS'] += ' -I' + join(ncurses.get_build_dir(arch.arch),
# # 'include')
# env['CURSES_LIBRARY'] = join(self.ctx.get_libs_dir(arch.arch), 'libncurses.so')
# env['CURSES_INCLUDE_PATH'] = join(ncurses.get_build_dir(arch.arch),
# 'include')
# return env
#
# def build_arch(self, arch):
# env = self.get_recipe_env(arch)
# with current_directory(self.get_build_dir(arch.arch)):
# # configure = sh.Command('./configure')
# # TODO: should add openssl as an optional dep and compile support
# # shprint(configure, '--enable-shared', '--enable-assembler',
# # '--enable-thread-safe-client', '--with-innodb',
# # '--without-server', _env=env)
# # shprint(sh.make, _env=env)
# shprint(sh.cmake, '.', '-DCURSES_LIBRARY=' + env['CURSES_LIBRARY'],
# '-DCURSES_INCLUDE_PATH=' + env['CURSES_INCLUDE_PATH'], _env=env)
# shprint(sh.make, _env=env)
#
# self.install_libs(arch, 'libmysqlclient.so')


recipe = LibmysqlclientRecipe()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- libmysqlclient/libmysqlclient/libmysql/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
+++ b/libmysqlclient/libmysql/CMakeLists.txt 2016-01-11 13:28:51.142356988 -0600
@@ -152,3 +152,5 @@
${CMAKE_SOURCE_DIR}/libmysql/libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION "lib")
ENDIF(WIN32)
+
+LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_PREFIX}")
11 changes: 11 additions & 0 deletions pythonforandroid/recipes/libmysqlclient/disable-soname.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- libmysqlclient/libmysqlclient/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
+++ b/libmysqlclient/CMakeLists.txt 2016-01-11 13:48:41.672323738 -0600
@@ -24,6 +24,8 @@
SET(CMAKE_BUILD_TYPE "Release")
ENDIF(NOT CMAKE_BUILD_TYPE)

+SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")
+
# This reads user configuration, generated by configure.js.
IF(WIN32 AND EXISTS ${CMAKE_SOURCE_DIR}/win/configure.data)
INCLUDE(${CMAKE_SOURCE_DIR}/win/configure.data)
12 changes: 12 additions & 0 deletions pythonforandroid/recipes/libmysqlclient/disable-soversion.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- libmysqlclient/libmysqlclient/libmysql/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
+++ b/libmysqlclient/libmysql/CMakeLists.txt 2016-01-11 14:00:26.729332913 -0600
@@ -97,9 +97,6 @@
ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} libmysql.def)
TARGET_LINK_LIBRARIES(libmysql ${CMAKE_THREAD_LIBS_INIT})
STRING(REGEX REPLACE "\\..+" "" LIBMYSQL_SOVERSION ${SHARED_LIB_VERSION})
-SET_TARGET_PROPERTIES(libmysql
- PROPERTIES VERSION ${SHARED_LIB_VERSION}
- SOVERSION ${LIBMYSQL_SOVERSION})
IF(OPENSSL_LIBRARIES)
TARGET_LINK_LIBRARIES(libmysql ${OPENSSL_LIBRARIES} ${OPENSSL_LIBCRYPTO})
ENDIF(OPENSSL_LIBRARIES)
3 changes: 3 additions & 0 deletions pythonforandroid/recipes/libmysqlclient/p4a.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
39 changes: 39 additions & 0 deletions pythonforandroid/recipes/mysqldb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
from os.path import join


class MysqldbRecipe(CompiledComponentsPythonRecipe):
name = 'mysqldb'
version = '1.2.5'
url = 'https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-{version}.zip'
site_packages_name = 'MySQLdb'

depends = ['python2', 'setuptools', 'libmysqlclient']

patches = ['override-mysql-config.patch',
'disable-zip.patch']

# call_hostpython_via_targetpython = False

def get_recipe_env(self, arch=None):
env = super(MysqldbRecipe, self).get_recipe_env(arch)

hostpython = self.get_recipe('hostpython2', self.ctx)
# TODO: fix hardcoded path
env['PYTHONPATH'] = (join(hostpython.get_build_dir(arch.arch),
'build', 'lib.linux-x86_64-2.7') +
':' + env.get('PYTHONPATH', ''))

libmysql = self.get_recipe('libmysqlclient', self.ctx)
mydir = join(libmysql.get_build_dir(arch.arch), 'libmysqlclient')
# env['CFLAGS'] += ' -I' + join(mydir, 'include')
# env['LDFLAGS'] += ' -L' + join(mydir)
libdir = self.ctx.get_libs_dir(arch.arch)
env['MYSQL_libs'] = env['MYSQL_libs_r'] = '-L' + libdir + ' -lmysql'
env['MYSQL_cflags'] = env['MYSQL_include'] = '-I' + join(mydir,
'include')

return env


recipe = MysqldbRecipe()
8 changes: 8 additions & 0 deletions pythonforandroid/recipes/mysqldb/disable-zip.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- mysqldb/setup.py 2014-01-02 13:52:50.000000000 -0600
+++ b/setup.py 2016-01-11 15:25:09.375114016 -0600
@@ -18,4 +18,5 @@
metadata['ext_modules'] = [
setuptools.Extension(sources=['_mysql.c'], **options)]
metadata['long_description'] = metadata['long_description'].replace(r'\n', '')
+metadata['zip_safe'] = False
setuptools.setup(**metadata)
21 changes: 21 additions & 0 deletions pythonforandroid/recipes/mysqldb/override-mysql-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- mysqldb/setup_posix.py 2014-01-02 13:52:50.000000000 -0600
+++ b/setup_posix.py 2016-01-11 14:38:33.603528571 -0600
@@ -13,17 +13,7 @@
return "-%s" % f

def mysql_config(what):
- from os import popen
-
- f = popen("%s --%s" % (mysql_config.path, what))
- data = f.read().strip().split()
- ret = f.close()
- if ret:
- if ret/256:
- data = []
- if ret/256 > 1:
- raise EnvironmentError("%s not found" % (mysql_config.path,))
- return data
+ return os.environ['MYSQL_' + what.replace('-', '_')].strip().split()
mysql_config.path = "mysql_config"

def get_config():