@ -3,22 +3,21 @@ package("mysql")
set_homepage ( " https://dev.mysql.com/doc/refman/5.7/en/ " )
set_description ( " Open source relational database management system. " )
if is_plat ( " windows " ) then
add_configs ( " vs_runtime " , { description = " Set vs compiler runtime. " , default = " MD " , readonly = true } )
if is_arch ( " x86 " ) then
set_urls ( " https://downloads.mysql.com/archives/get/p/19/file/mysql-connector-c-$(version)-win32.zip " )
add_versions ( " 6.1.11 " , " a32487407bc0c4e217d8839892333fb0cb39153194d2788f226e9c5b9abdd928 " )
elseif is_arch ( " x64 " ) then
set_urls ( " https://downloads.mysql.com/archives/get/p/19/file/mysql-connector-c-$(version)-winx64.zip " )
add_versions ( " 6.1.11 " , " 3555641cea2da60435ab7f1681a94d1aa97341f1a0f52193adc82a83734818ca " )
end
else
if is_plat ( " macosx " , " linux " ) then
set_urls ( " https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-$(version).tar.gz " ,
" https://github.com/xmake-mirror/mysql-boost/releases/download/$(version)/mysql-boost-$(version).tar.gz " )
add_versions ( " 5.7.29 " , " 00f514124de2bad1ba7b380cbbd46e316cae7fc7bc3a5621456cabf352f27978 " )
end
if is_plat ( " macosx " , " linux " ) then
if is_plat ( " windows " ) then
set_urls ( " https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-$(version).tar.gz " )
add_versions ( " 8.0.31 " , " 67bb8cba75b28e95c7f7948563f01fb84528fcbb1a35dba839d4ce44fe019baa " )
add_configs ( " shared " , { description = " Download shared binaries. " , default = false , type = " boolean " } )
add_configs ( " vs_runtime " , { description = " Set vs compiler runtime. " , default = " MT " } )
end
if is_plat ( " macosx " , " linux " , " windows " ) then
add_deps ( " cmake " , " openssl " )
if is_plat ( " linux " ) then
add_deps ( " ncurses " )
@ -27,24 +26,80 @@ package("mysql")
add_includedirs ( " include " , " include/mysql " )
on_load ( " windows " , function ( package )
if package : version ( ) : ge ( " 8.0.0 " ) then
package : add ( " deps " , " boost " )
package : add ( " deps " , " openssl 1.1.1-t " )
package : add ( " deps " , " zlib v1.2.13 " )
package : add ( " deps " , " zstd " )
package : add ( " deps " , " lz4 " )
end
end )
on_install ( " windows " , function ( package )
io.gsub ( " CMakeLists.txt " , " ADD_SUBDIRECTORY%(storage/ndb%) " , " " )
local configs = { " -DCOMPILATION_COMMENT=XMake " ,
" -DDEFAULT_CHARSET=utf8 " ,
" -DDEFAULT_COLLATION=utf8_general_ci " ,
" -DINSTALL_DOCDIR=share/doc/#{name} " ,
" -DINSTALL_INCLUDEDIR=include/mysql " ,
" -DINSTALL_INFODIR=share/info " ,
" -DINSTALL_MANDIR=share/man " ,
" -DINSTALL_MYSQLSHAREDIR=share/mysql " ,
" -DWITH_EDITLINE= " .. ( is_plat ( " macosx " ) and " system " or " bundled " ) ,
" -DWITH_UNIT_TESTS=OFF " ,
" -DDISABLE_SHARED= " .. ( package : config ( " shared " ) and " OFF " or " ON " ) ,
" -DWITH_LZ4='system' " ,
" -DWITH_ZSTD='system' " ,
" -DWITH_ZLIB='system' " ,
" -DWINDOWS_RUNTIME_MD= " .. ( package : config ( " vs_runtime " ) : startswith ( " MD " ) and " ON " or " OFF " ) ,
" -DWITHOUT_SERVER=ON " }
io.replace ( " cmake/ssl.cmake " , " IF(NOT OPENSSL_APPLINK_C) " , " IF(FALSE AND NOT OPENSSL_APPLINK_C) " , { plain = true } )
for _ , removelib in ipairs ( { " icu " , " libevent " , " re2 " , " rapidjson " , " protobuf " , " libedit " } ) do
io.replace ( " CMakeLists.txt " , " MYSQL_CHECK_ " .. string.upper ( removelib ) .. " () \n " , " " , { plain = true } )
io.replace ( " CMakeLists.txt " , " INCLUDE( " .. removelib .. " ) \n " , " " , { plain = true } )
io.replace ( " CMakeLists.txt " , " WARN_MISSING_SYSTEM_ " .. string.upper ( removelib ) .. " ( " .. string.upper ( removelib ) .. " _WARN_GIVEN) " , " # WARN_MISSING_SYSTEM_ " .. string.upper ( removelib ) .. " ( " .. string.upper ( removelib ) .. " _WARN_GIVEN) " , { plain = true } )
io.replace ( " CMakeLists.txt " , " SET( " .. string.upper ( removelib ) .. " _WARN_GIVEN) " , " # SET( " .. string.upper ( removelib ) .. " _WARN_GIVEN) " , { plain = true } )
end
os.rmdir ( " extra " )
for _ , folder in ipairs ( { " client " , " man " , " mysql-test " , " libbinlogstandalone " } ) do
os.rmdir ( folder )
io.replace ( " CMakeLists.txt " , " ADD_SUBDIRECTORY( " .. folder .. " ) \n " , " " , { plain = true } )
end
os.rmdir ( " storage/ndb " )
for _ , line in ipairs ( { " INCLUDE(cmake/boost.cmake) \n " , " MYSQL_CHECK_EDITLINE() \n " } ) do
io.replace ( " CMakeLists.txt " , line , " " , { plain = true } )
end
io.replace ( " libbinlogevents/CMakeLists.txt " , " INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libbinlogevents/include) " , " MY_INCLUDE_SYSTEM_DIRECTORIES(LZ4) \n INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libbinlogevents/include) " , { plain = true } )
io.replace ( " cmake/install_macros.cmake " , " INSTALL_DEBUG_SYMBOLS( " , " # INSTALL_DEBUG_SYMBOLS( " , { plain = true } )
import ( " package.tools.cmake " ) . install ( package , configs )
if package : config ( " shared " ) then
os.rm ( package : installdir ( " lib/mysqlclient.lib " ) )
os.cp ( package : installdir ( " lib/libmysql.dll " ) , package : installdir ( " bin " ) )
else
os.rm ( package : installdir ( " lib/libmysql.lib " ) )
os.rm ( package : installdir ( " bin/libmysql.dll " ) )
end
end )
on_install ( " macosx " , " linux " , function ( package )
-- https://bugs.mysql.com/bug.php?id=87348
-- Fixes: "ADD_SUBDIRECTORY given source
-- 'storage/ndb' which is not an existing"
io.gsub ( " CMakeLists.txt " , " ADD_SUBDIRECTORY%(storage/ndb%) " , " " )
local configs = { " -DCOMPILATION_COMMENT=XMake " ,
" -DDEFAULT_CHARSET=utf8 " ,
" -DDEFAULT_COLLATION=utf8_general_ci " ,
" -DINSTALL_DOCDIR=share/doc/#{name} " ,
" -DINSTALL_INCLUDEDIR=include/mysql " ,
" -DINSTALL_INFODIR=share/info " ,
" -DINSTALL_MANDIR=share/man " ,
" -DINSTALL_MYSQLSHAREDIR=share/mysql " ,
" -DWITH_BOOST=../boost " ,
" -DWITH_EDITLINE= " .. ( is_plat ( " macosx " ) and " system " or " bundled " ) ,
" -DWITH_SSL=yes " ,
" -DWITH_UNIT_TESTS=OFF " ,
" -DWITHOUT_SERVER=ON " }
local configs = { " -DCOMPILATION_COMMENT=XMake " ,
" -DDEFAULT_CHARSET=utf8 " ,
" -DDEFAULT_COLLATION=utf8_general_ci " ,
" -DINSTALL_DOCDIR=share/doc/#{name} " ,
" -DINSTALL_INCLUDEDIR=include/mysql " ,
" -DINSTALL_INFODIR=share/info " ,
" -DINSTALL_MANDIR=share/man " ,
" -DINSTALL_MYSQLSHAREDIR=share/mysql " ,
" -DWITH_BOOST=../boost " ,
" -DWITH_EDITLINE= " .. ( is_plat ( " macosx " ) and " system " or " bundled " ) ,
" -DWITH_SSL=yes " ,
" -DWITH_UNIT_TESTS=OFF " ,
" -DWITHOUT_SERVER=ON " }
if package : is_plat ( " linux " ) then
local curses = package : dep ( " ncurses " ) : fetch ( )
if curses then
@ -57,18 +112,6 @@ package("mysql")
import ( " package.tools.cmake " ) . install ( package , configs )
end )
on_install ( " windows " , function ( package )
os.cp ( " include/* " , package : installdir ( " include/mysql " ) )
if package : config ( " shared " ) then
os.cp ( " lib/libmysql.lib " , package : installdir ( " lib " ) )
os.cp ( " lib/libmysql.dll " , package : installdir ( " bin " ) )
else
package : add ( " syslinks " , " advapi32 " )
package : add ( " syslinks " , " msvcrt " )
os.cp ( " lib/vs14/mysqlclient.lib " , package : installdir ( " lib " ) )
end
end )
on_test ( function ( package )
assert ( package : has_cfuncs ( " mysql_init " , { includes = " mysql.h " } ) )
end )