mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
Add support for compiling mysql with dynlibs thanks to mysql_config
This commit is contained in:
parent
5c1ce6c601
commit
e163f9f8ea
24
bam.lua
24
bam.lua
|
@ -7,6 +7,7 @@ Import("other/curl/curl.lua")
|
||||||
Import("other/opus/opusfile.lua")
|
Import("other/opus/opusfile.lua")
|
||||||
Import("other/opus/opus.lua")
|
Import("other/opus/opus.lua")
|
||||||
Import("other/opus/ogg.lua")
|
Import("other/opus/ogg.lua")
|
||||||
|
Import("other/mysql/mysql.lua")
|
||||||
|
|
||||||
--- Setup Config -------
|
--- Setup Config -------
|
||||||
config = NewConfig()
|
config = NewConfig()
|
||||||
|
@ -21,6 +22,7 @@ config:Add(Curl.OptFind("curl", true))
|
||||||
config:Add(Opusfile.OptFind("opusfile", true))
|
config:Add(Opusfile.OptFind("opusfile", true))
|
||||||
config:Add(Opus.OptFind("opus", true))
|
config:Add(Opus.OptFind("opus", true))
|
||||||
config:Add(Ogg.OptFind("ogg", true))
|
config:Add(Ogg.OptFind("ogg", true))
|
||||||
|
config:Add(Mysql.OptFind("mysql", true))
|
||||||
config:Add(OptString("websockets", false))
|
config:Add(OptString("websockets", false))
|
||||||
config:Finalize("config.lua")
|
config:Finalize("config.lua")
|
||||||
|
|
||||||
|
@ -220,7 +222,6 @@ function build(settings)
|
||||||
|
|
||||||
settings.cc.includes:Add("src")
|
settings.cc.includes:Add("src")
|
||||||
settings.cc.includes:Add("src/engine/external")
|
settings.cc.includes:Add("src/engine/external")
|
||||||
settings.cc.includes:Add("other/mysql/include")
|
|
||||||
|
|
||||||
-- set some platform specific settings
|
-- set some platform specific settings
|
||||||
if family == "unix" then
|
if family == "unix" then
|
||||||
|
@ -277,10 +278,7 @@ function build(settings)
|
||||||
|
|
||||||
if family == "unix" then
|
if family == "unix" then
|
||||||
if string.find(settings.config_name, "sql") then
|
if string.find(settings.config_name, "sql") then
|
||||||
server_settings.link.libs:Add("mysqlcppconn-static")
|
config.mysql:Apply(server_settings)
|
||||||
server_settings.link.libs:Add("mysqlclient")
|
|
||||||
server_settings.link.libs:Add("dl")
|
|
||||||
server_settings.link.libs:Add("rt")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if platform == "macosx" then
|
if platform == "macosx" then
|
||||||
|
@ -289,27 +287,11 @@ function build(settings)
|
||||||
client_settings.link.frameworks:Add("Carbon")
|
client_settings.link.frameworks:Add("Carbon")
|
||||||
client_settings.link.frameworks:Add("Cocoa")
|
client_settings.link.frameworks:Add("Cocoa")
|
||||||
launcher_settings.link.frameworks:Add("Cocoa")
|
launcher_settings.link.frameworks:Add("Cocoa")
|
||||||
|
|
||||||
if string.find(settings.config_name, "sql") then
|
|
||||||
if arch == "amd64" then
|
|
||||||
server_settings.link.libpath:Add("other/mysql/mac/lib64")
|
|
||||||
else
|
|
||||||
server_settings.link.libpath:Add("other/mysql/mac/lib32")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
client_settings.link.libs:Add("X11")
|
client_settings.link.libs:Add("X11")
|
||||||
client_settings.link.libs:Add("GL")
|
client_settings.link.libs:Add("GL")
|
||||||
client_settings.link.libs:Add("GLU")
|
client_settings.link.libs:Add("GLU")
|
||||||
client_settings.link.libs:Add("dl")
|
client_settings.link.libs:Add("dl")
|
||||||
|
|
||||||
if string.find(settings.config_name, "sql") then
|
|
||||||
if arch == "amd64" then
|
|
||||||
server_settings.link.libpath:Add("other/mysql/linux/lib64")
|
|
||||||
else
|
|
||||||
server_settings.link.libpath:Add("other/mysql/linux/lib32")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif family == "windows" then
|
elseif family == "windows" then
|
||||||
|
|
93
other/mysql/mysql.lua
Normal file
93
other/mysql/mysql.lua
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
Mysql = {
|
||||||
|
basepath = PathDir(ModuleFilename()),
|
||||||
|
|
||||||
|
OptFind = function (name, required)
|
||||||
|
local check = function(option, settings)
|
||||||
|
option.value = false
|
||||||
|
option.lib_path = nil
|
||||||
|
|
||||||
|
if IsNegativeTerm(ScriptArgs[name .. ".use_mysqlconfig"]) then
|
||||||
|
option.use_mysqlconfig = false
|
||||||
|
elseif IsPositiveTerm(ScriptArgs[name .. ".use_mysqlconfig"]) then
|
||||||
|
option.use_mysqlconfig = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ExecuteSilent("mysql_config --version") == 0 then
|
||||||
|
option.value = true
|
||||||
|
if option.use_mysqlconfig == nil then
|
||||||
|
option.use_mysqlconfig = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if option.use_mysqlconfig == nil then
|
||||||
|
option.use_mysqlconfig = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if platform == "win32" then
|
||||||
|
option.value = true
|
||||||
|
elseif platform == "win64" then
|
||||||
|
option.value = true
|
||||||
|
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||||
|
option.value = true
|
||||||
|
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||||
|
option.value = true
|
||||||
|
elseif platform == "linux" and arch == "x86" then
|
||||||
|
option.value = true
|
||||||
|
elseif platform == "linux" and arch == "amd64" then
|
||||||
|
option.value = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local apply = function(option, settings)
|
||||||
|
if option.use_mysqlconfig == true then
|
||||||
|
settings.cc.flags:Add("`mysql_config --cflags`")
|
||||||
|
settings.link.flags:Add("`mysql_config --libs`")
|
||||||
|
settings.link.libs:Add("mysqlcppconn")
|
||||||
|
else
|
||||||
|
settings.cc.includes:Add(Mysql.basepath .. "/include")
|
||||||
|
|
||||||
|
if family ~= "windows" then
|
||||||
|
settings.link.libs:Add("mysqlcppconn-static")
|
||||||
|
settings.link.libs:Add("mysqlclient")
|
||||||
|
settings.link.libs:Add("dl")
|
||||||
|
settings.link.libs:Add("rt")
|
||||||
|
end
|
||||||
|
|
||||||
|
if platform == "macosx" and string.find(settings.config_name, "32") then
|
||||||
|
settings.link.libpath:Add("other/mysql/mac/lib32")
|
||||||
|
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||||
|
settings.link.libpath:Add("other/mysql/mac/lib64")
|
||||||
|
elseif platform == "linux" and arch == "x86" then
|
||||||
|
settings.link.libpath:Add("other/mysql/linux/lib32")
|
||||||
|
elseif platform == "linux" and arch == "amd64" then
|
||||||
|
settings.link.libpath:Add("other/mysql/linux/lib64")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local save = function(option, output)
|
||||||
|
output:option(option, "value")
|
||||||
|
output:option(option, "use_mysqlconfig")
|
||||||
|
end
|
||||||
|
|
||||||
|
local display = function(option)
|
||||||
|
if option.value == true then
|
||||||
|
if option.use_mysqlconfig == true then return "using mysql_config" end
|
||||||
|
return "using bundled libs"
|
||||||
|
else
|
||||||
|
if option.required then
|
||||||
|
return "not found (required)"
|
||||||
|
else
|
||||||
|
return "not found (optional)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local o = MakeOption(name, 0, check, save, display)
|
||||||
|
o.Apply = apply
|
||||||
|
o.include_path = nil
|
||||||
|
o.lib_path = nil
|
||||||
|
o.required = required
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
}
|
Loading…
Reference in a new issue