mirror of https://github.com/tqfx/liba.git
sty: stylua .
This commit is contained in:
parent
0a48d1cf8b
commit
4669e0c53b
|
@ -4,10 +4,10 @@ package.path = arg[0]:sub(0, -arg[0]:match("([^/\\]*)$"):len() - 1) .. "?.lua;"
|
|||
local test = require("test")
|
||||
local a = require("liba")
|
||||
for i, v in pairs(arg) do
|
||||
if i == 1 then
|
||||
io.output(v)
|
||||
break
|
||||
end
|
||||
if i == 1 then
|
||||
io.output(v)
|
||||
break
|
||||
end
|
||||
end
|
||||
test:p(a:rsqrt(1, 2, 4))
|
||||
test:r(a)
|
||||
|
|
|
@ -11,15 +11,15 @@ local PS = 1
|
|||
local PM = 2
|
||||
local PL = 3
|
||||
local me = {
|
||||
-- LuaFormatter off
|
||||
{ a.mf.TRI, NL, NL, NM },
|
||||
{ a.mf.TRI, NL, NM, NS },
|
||||
{ a.mf.TRI, NM, NS, ZO },
|
||||
{ a.mf.TRI, NS, ZO, PS },
|
||||
{ a.mf.TRI, ZO, PS, PM },
|
||||
{ a.mf.TRI, PS, PM, PL },
|
||||
{ a.mf.TRI, PM, PL, PL },
|
||||
-- LuaFormatter on
|
||||
-- LuaFormatter off
|
||||
{ a.mf.TRI, NL, NL, NM },
|
||||
{ a.mf.TRI, NL, NM, NS },
|
||||
{ a.mf.TRI, NM, NS, ZO },
|
||||
{ a.mf.TRI, NS, ZO, PS },
|
||||
{ a.mf.TRI, ZO, PS, PM },
|
||||
{ a.mf.TRI, PS, PM, PL },
|
||||
{ a.mf.TRI, PM, PL, PL },
|
||||
-- LuaFormatter on
|
||||
}
|
||||
local NL = -6
|
||||
local NM = -4
|
||||
|
@ -29,15 +29,15 @@ local PS = 2
|
|||
local PM = 4
|
||||
local PL = 6
|
||||
local mec = {
|
||||
-- LuaFormatter off
|
||||
{ a.mf.TRI, NL, NL, NM },
|
||||
{ a.mf.TRI, NL, NM, NS },
|
||||
{ a.mf.TRI, NM, NS, ZO },
|
||||
{ a.mf.TRI, NS, ZO, PS },
|
||||
{ a.mf.TRI, ZO, PS, PM },
|
||||
{ a.mf.TRI, PS, PM, PL },
|
||||
{ a.mf.TRI, PM, PL, PL },
|
||||
-- LuaFormatter on
|
||||
-- LuaFormatter off
|
||||
{ a.mf.TRI, NL, NL, NM },
|
||||
{ a.mf.TRI, NL, NM, NS },
|
||||
{ a.mf.TRI, NM, NS, ZO },
|
||||
{ a.mf.TRI, NS, ZO, PS },
|
||||
{ a.mf.TRI, ZO, PS, PM },
|
||||
{ a.mf.TRI, PS, PM, PL },
|
||||
{ a.mf.TRI, PM, PL, PL },
|
||||
-- LuaFormatter on
|
||||
}
|
||||
local NL = -15
|
||||
local NM = -10
|
||||
|
@ -47,15 +47,15 @@ local PS = 5
|
|||
local PM = 10
|
||||
local PL = 15
|
||||
local mkp = {
|
||||
-- LuaFormatter off
|
||||
{ NL, NL, NM, NM, NS, ZO, ZO },
|
||||
{ NL, NL, NM, NS, NS, ZO, PS },
|
||||
{ NM, NM, NM, NS, ZO, PS, PS },
|
||||
{ NM, NM, NS, ZO, PS, PM, PM },
|
||||
{ NS, NS, ZO, PS, PS, PM, PM },
|
||||
{ NS, ZO, PS, PM, PM, PM, PL },
|
||||
{ ZO, ZO, PM, PM, PM, PL, PL },
|
||||
-- LuaFormatter on
|
||||
-- LuaFormatter off
|
||||
{ NL, NL, NM, NM, NS, ZO, ZO },
|
||||
{ NL, NL, NM, NS, NS, ZO, PS },
|
||||
{ NM, NM, NM, NS, ZO, PS, PS },
|
||||
{ NM, NM, NS, ZO, PS, PM, PM },
|
||||
{ NS, NS, ZO, PS, PS, PM, PM },
|
||||
{ NS, ZO, PS, PM, PM, PM, PL },
|
||||
{ ZO, ZO, PM, PM, PM, PL, PL },
|
||||
-- LuaFormatter on
|
||||
}
|
||||
local NL = -3
|
||||
local NM = -2
|
||||
|
@ -65,26 +65,26 @@ local PS = 1
|
|||
local PM = 2
|
||||
local PL = 3
|
||||
local mki = {
|
||||
-- LuaFormatter off
|
||||
{ PL, PL, PM, PM, PS, ZO, ZO },
|
||||
{ PL, PL, PM, PS, PS, ZO, ZO },
|
||||
{ PL, PM, PS, PS, ZO, NS, NS },
|
||||
{ PM, PM, PS, ZO, NS, NM, NM },
|
||||
{ PM, PS, ZO, NS, NS, NM, NL },
|
||||
{ ZO, ZO, NS, NS, NM, NL, NL },
|
||||
{ ZO, ZO, NS, NM, NM, NL, NL },
|
||||
-- LuaFormatter on
|
||||
-- LuaFormatter off
|
||||
{ PL, PL, PM, PM, PS, ZO, ZO },
|
||||
{ PL, PL, PM, PS, PS, ZO, ZO },
|
||||
{ PL, PM, PS, PS, ZO, NS, NS },
|
||||
{ PM, PM, PS, ZO, NS, NM, NM },
|
||||
{ PM, PS, ZO, NS, NS, NM, NL },
|
||||
{ ZO, ZO, NS, NS, NM, NL, NL },
|
||||
{ ZO, ZO, NS, NM, NM, NL, NL },
|
||||
-- LuaFormatter on
|
||||
}
|
||||
local mkd = {
|
||||
-- LuaFormatter off
|
||||
{ NS, PS, PL, PL, PL, PM, NS },
|
||||
{ NS, PS, PL, PM, PM, PS, ZO },
|
||||
{ ZO, PS, PM, PM, PS, PS, ZO },
|
||||
{ ZO, PS, PS, PS, PS, PS, ZO },
|
||||
{ ZO, ZO, ZO, ZO, ZO, ZO, ZO },
|
||||
{ NL, NS, NS, NS, NS, NS, NL },
|
||||
{ NL, NM, NM, NM, NS, NS, NL },
|
||||
-- LuaFormatter on
|
||||
-- LuaFormatter off
|
||||
{ NS, PS, PL, PL, PL, PM, NS },
|
||||
{ NS, PS, PL, PM, PM, PS, ZO },
|
||||
{ ZO, PS, PM, PM, PS, PS, ZO },
|
||||
{ ZO, PS, PS, PS, PS, PS, ZO },
|
||||
{ ZO, ZO, ZO, ZO, ZO, ZO, ZO },
|
||||
{ NL, NS, NS, NS, NS, NS, NL },
|
||||
{ NL, NM, NM, NM, NS, NS, NL },
|
||||
-- LuaFormatter on
|
||||
}
|
||||
test:r(getmetatable(a.pid.fuzzy))
|
||||
assert(a.pid.fuzzy.new())
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
local test = {}
|
||||
function test:r(...)
|
||||
local io_write_cache = {}
|
||||
local function io_write(indent, ...)
|
||||
if io_write_cache[tostring(...)] then
|
||||
io.write(indent .. "*" .. tostring(...) .. "\n")
|
||||
else
|
||||
io_write_cache[tostring(...)] = true
|
||||
if type(...) == "table" then
|
||||
for pos, val in pairs(...) do
|
||||
if type(val) == "table" then
|
||||
io.write(indent .. "[" .. pos .. "] => " .. tostring(...) .. " {\n")
|
||||
io_write(indent .. string.rep(" ", string.len(pos) + 8), val)
|
||||
io.write(indent .. string.rep(" ", string.len(pos) + 6) .. "}\n")
|
||||
elseif type(val) == "string" then
|
||||
io.write(indent .. "[" .. pos .. '] => "' .. val .. '"\n')
|
||||
else
|
||||
io.write(indent .. "[" .. pos .. "] => " .. tostring(val) .. "\n")
|
||||
end
|
||||
local io_write_cache = {}
|
||||
local function io_write(indent, ...)
|
||||
if io_write_cache[tostring(...)] then
|
||||
io.write(indent .. "*" .. tostring(...) .. "\n")
|
||||
else
|
||||
io_write_cache[tostring(...)] = true
|
||||
if type(...) == "table" then
|
||||
for pos, val in pairs(...) do
|
||||
if type(val) == "table" then
|
||||
io.write(indent .. "[" .. pos .. "] => " .. tostring(...) .. " {\n")
|
||||
io_write(indent .. string.rep(" ", string.len(pos) + 8), val)
|
||||
io.write(indent .. string.rep(" ", string.len(pos) + 6) .. "}\n")
|
||||
elseif type(val) == "string" then
|
||||
io.write(indent .. "[" .. pos .. '] => "' .. val .. '"\n')
|
||||
else
|
||||
io.write(indent .. "[" .. pos .. "] => " .. tostring(val) .. "\n")
|
||||
end
|
||||
end
|
||||
else
|
||||
io.write(indent .. tostring(...) .. "\n")
|
||||
end
|
||||
end
|
||||
else
|
||||
io.write(indent .. tostring(...) .. "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
if type(...) == "table" then
|
||||
io.write(tostring(...) .. " {\n")
|
||||
io_write(" ", ...)
|
||||
io.write("}\n")
|
||||
else
|
||||
io_write(" ", ...)
|
||||
end
|
||||
if type(...) == "table" then
|
||||
io.write(tostring(...) .. " {\n")
|
||||
io_write(" ", ...)
|
||||
io.write("}\n")
|
||||
else
|
||||
io_write(" ", ...)
|
||||
end
|
||||
end
|
||||
function test:p(...)
|
||||
io.write(tostring(...) .. "\n")
|
||||
io.write(tostring(...) .. "\n")
|
||||
end
|
||||
return test
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
-- option: liba-lua
|
||||
option("liba-lua")
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_values("lua", "luajit")
|
||||
set_description("Enable/Disable lua")
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_values("lua", "luajit")
|
||||
set_description("Enable/Disable lua")
|
||||
option_end()
|
||||
|
||||
if has_config("liba-lua") then
|
||||
add_requires(get_config("liba-lua"))
|
||||
target("alua")
|
||||
set_basename("a")
|
||||
set_kind("shared")
|
||||
add_files("src/**.c")
|
||||
set_prefixname("lib")
|
||||
add_packages(get_config("liba-lua"))
|
||||
if is_plat("windows", "mingw") then
|
||||
set_extension(".dll")
|
||||
end
|
||||
add_defines("A_EXPORTS")
|
||||
on_load(function(target)
|
||||
local subdir = get_config("liba-lua")
|
||||
local libdir = path.join("lib", subdir)
|
||||
target:set("targetdir", path.join(target:targetdir(), subdir))
|
||||
target:set("installfiles", target:targetfile(), {prefixdir = libdir})
|
||||
end)
|
||||
add_deps("a")
|
||||
set_basename("a")
|
||||
set_kind("shared")
|
||||
add_files("src/**.c")
|
||||
set_prefixname("lib")
|
||||
add_packages(get_config("liba-lua"))
|
||||
if is_plat("windows", "mingw") then
|
||||
set_extension(".dll")
|
||||
end
|
||||
add_defines("A_EXPORTS")
|
||||
on_load(function(target)
|
||||
local subdir = get_config("liba-lua")
|
||||
local libdir = path.join("lib", subdir)
|
||||
target:set("targetdir", path.join(target:targetdir(), subdir))
|
||||
target:set("installfiles", target:targetfile(), { prefixdir = libdir })
|
||||
end)
|
||||
add_deps("a")
|
||||
target_end()
|
||||
end
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
target("test/host/que")
|
||||
building({"que.c", "que.cpp"})
|
||||
building({ "que.c", "que.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/host/str")
|
||||
building({"str.c", "str.cpp"})
|
||||
building({ "str.c", "str.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/host/vec")
|
||||
building({"vec.c", "vec.cpp"})
|
||||
building({ "vec.c", "vec.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/host/vector")
|
||||
building({"vector.c", "vector.cpp"})
|
||||
building({ "vector.c", "vector.cpp" })
|
||||
target_end()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
target("test/pid/expert")
|
||||
building({"expert.c", "expert.cpp"})
|
||||
building({ "expert.c", "expert.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/pid/fuzzy")
|
||||
building({"fuzzy.c", "fuzzy.cpp"})
|
||||
building({ "fuzzy.c", "fuzzy.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/pid/neuron")
|
||||
building({"neuron.c", "neuron.cpp"})
|
||||
building({ "neuron.c", "neuron.cpp" })
|
||||
target_end()
|
||||
|
|
|
@ -17,87 +17,87 @@ function building(sources)
|
|||
end
|
||||
|
||||
target("test/a")
|
||||
building({"a.c", "a.cpp"})
|
||||
building({ "a.c", "a.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/avl")
|
||||
building({"avl.c", "avl.cpp"})
|
||||
building({ "avl.c", "avl.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/buf")
|
||||
building({"buf.c", "buf.cpp"})
|
||||
building({ "buf.c", "buf.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/complex")
|
||||
building({"complex.c", "complex.cpp"})
|
||||
building({ "complex.c", "complex.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/crc")
|
||||
building({"crc.c", "crc.cpp"})
|
||||
building({ "crc.c", "crc.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/hpf")
|
||||
building({"hpf.c", "hpf.cpp"})
|
||||
building({ "hpf.c", "hpf.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/list")
|
||||
building({"list.c", "list.cpp"})
|
||||
building({ "list.c", "list.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/lpf")
|
||||
building({"lpf.c", "lpf.cpp"})
|
||||
building({ "lpf.c", "lpf.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/main")
|
||||
building({"main.c", "main.cpp"})
|
||||
building({ "main.c", "main.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/math")
|
||||
building({"math.c", "math.cpp"})
|
||||
building({ "math.c", "math.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/notefreqs")
|
||||
building({"notefreqs.c", "notefreqs.cpp"})
|
||||
building({ "notefreqs.c", "notefreqs.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/operator")
|
||||
building({"operator.c", "operator.cpp"})
|
||||
building({ "operator.c", "operator.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/pid")
|
||||
building({"pid.c", "pid.cpp"})
|
||||
building({ "pid.c", "pid.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/poly")
|
||||
building({"poly.c", "poly.cpp"})
|
||||
building({ "poly.c", "poly.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/polytrack")
|
||||
building({"polytrack.c", "polytrack.cpp"})
|
||||
building({ "polytrack.c", "polytrack.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/rbf")
|
||||
building({"rbf.c", "rbf.cpp"})
|
||||
building({ "rbf.c", "rbf.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/rbt")
|
||||
building({"rbt.c", "rbt.cpp"})
|
||||
building({ "rbt.c", "rbt.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/tf")
|
||||
building({"tf.c", "tf.cpp"})
|
||||
building({ "tf.c", "tf.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/slist")
|
||||
building({"slist.c", "slist.cpp"})
|
||||
building({ "slist.c", "slist.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/utf")
|
||||
building({"utf.c", "utf.cpp"})
|
||||
building({ "utf.c", "utf.cpp" })
|
||||
target_end()
|
||||
|
||||
target("test/version")
|
||||
building({"version.c", "version.cpp"})
|
||||
building({ "version.c", "version.cpp" })
|
||||
target_end()
|
||||
|
||||
if not table.empty(os.files("*/xmake.lua")) then
|
||||
|
|
253
xmake.lua
253
xmake.lua
|
@ -5,21 +5,21 @@ set_project("liba")
|
|||
set_xmakever("2.5.0")
|
||||
|
||||
-- set project version
|
||||
set_version("0.1.1", {build = "%Y%m%d%H%M"})
|
||||
set_version("0.1.1", { build = "%Y%m%d%H%M" })
|
||||
|
||||
-- option: liba-cxx
|
||||
option("liba-cxx")
|
||||
set_default(true)
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_description("Enable/Disable c++")
|
||||
set_default(true)
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_description("Enable/Disable c++")
|
||||
option_end()
|
||||
|
||||
-- option: warning
|
||||
option("warning")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
set_description("Enable/Disable warnings")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
set_description("Enable/Disable warnings")
|
||||
option_end()
|
||||
|
||||
if has_config("warning") then
|
||||
|
@ -49,146 +49,153 @@ end
|
|||
|
||||
-- option: float
|
||||
option("liba-float")
|
||||
set_default("8")
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_values("4", "8", "16")
|
||||
set_description("floating-point number bytes")
|
||||
set_default("8")
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_values("4", "8", "16")
|
||||
set_description("floating-point number bytes")
|
||||
option_end()
|
||||
|
||||
-- option: rpath
|
||||
option("liba-rpath")
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_description("dynamic library search path")
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_description("dynamic library search path")
|
||||
option_end()
|
||||
|
||||
target("a")
|
||||
-- make as a collection of objects
|
||||
set_kind("object")
|
||||
-- detect c code functions
|
||||
float = get_config("liba-float")
|
||||
includes("check_csnippets.lua")
|
||||
local source = 'printf("%u", (unsigned int)sizeof(void *));'
|
||||
configvar_check_csnippets("A_SIZE_POINTER", source, {output = true, number = true})
|
||||
local source = 'int x = 1; puts(*(char *)&x ? "1234" : "4321");'
|
||||
configvar_check_csnippets("A_BYTE_ORDER", source, {output = true, number = true})
|
||||
includes("check_cincludes.lua")
|
||||
function check_math(funcs, opt)
|
||||
includes("check_cfuncs.lua")
|
||||
for i, func in pairs(funcs) do
|
||||
local have = "A_HAVE_"..string.upper(func)
|
||||
if float == "16" then func = func..'l' end
|
||||
if float == "4" then func = func..'f' end
|
||||
configvar_check_cfuncs(have, func, opt)
|
||||
-- make as a collection of objects
|
||||
set_kind("object")
|
||||
-- detect c code functions
|
||||
float = get_config("liba-float")
|
||||
includes("check_csnippets.lua")
|
||||
local source = 'printf("%u", (unsigned int)sizeof(void *));'
|
||||
configvar_check_csnippets("A_SIZE_POINTER", source, { output = true, number = true })
|
||||
local source = 'int x = 1; puts(*(char *)&x ? "1234" : "4321");'
|
||||
configvar_check_csnippets("A_BYTE_ORDER", source, { output = true, number = true })
|
||||
includes("check_cincludes.lua")
|
||||
function check_math(funcs, opt)
|
||||
includes("check_cfuncs.lua")
|
||||
for i, func in pairs(funcs) do
|
||||
local have = "A_HAVE_" .. string.upper(func)
|
||||
if float == "16" then
|
||||
func = func .. "l"
|
||||
end
|
||||
if float == "4" then
|
||||
func = func .. "f"
|
||||
end
|
||||
configvar_check_cfuncs(have, func, opt)
|
||||
end
|
||||
local funcs = {"hypot", "log1p", "atan2"}
|
||||
check_math(funcs, {includes = "math.h"})
|
||||
local funcs = {
|
||||
"csqrt",
|
||||
"cpow", "cexp", "clog",
|
||||
"csin", "ccos", "ctan",
|
||||
"csinh", "ccosh", "ctanh",
|
||||
"casin", "cacos", "catan",
|
||||
"casinh", "cacosh", "catanh",
|
||||
}
|
||||
check_math(funcs, {includes = "complex.h"})
|
||||
-- set the auto-generated a.xmake.h
|
||||
a_have_h = path.relative(os.projectdir().."/$(buildir)/a.xmake.h", "include/a")
|
||||
add_defines("A_HAVE_H=\""..a_have_h.."\"", {public = true})
|
||||
set_configvar("XMAKE_VERSION", tostring(xmake.version()))
|
||||
set_configvar("A_SIZE_FLOAT", float, {quote = false})
|
||||
add_configfiles("include/a.xmake.h.in")
|
||||
-- add include directories
|
||||
add_includedirs("include", {public = true})
|
||||
-- set export library symbols
|
||||
add_defines("A_EXPORTS")
|
||||
-- add the common source files
|
||||
if not table.empty(os.files("src/**.cpp")) and has_config("liba-cxx") then
|
||||
add_files("src/**.cpp")
|
||||
end
|
||||
add_files("src/**.c")
|
||||
-- add the platform options
|
||||
rpath = get_config("liba-rpath")
|
||||
if rpath then
|
||||
add_rpathdirs(rpath, {public = true})
|
||||
add_linkdirs(rpath, {public = true})
|
||||
end
|
||||
if not is_plat("windows", "mingw") then
|
||||
add_syslinks("m", {public = true})
|
||||
add_cxflags("-fPIC")
|
||||
end
|
||||
after_build(function(target)
|
||||
import("core.tool.linker")
|
||||
local object = target:objectfiles()
|
||||
local output = path.join(target:targetdir(), "liba.o")
|
||||
local program = linker.linkargv("binary", "cc", object, output, {target = target})
|
||||
try{function()
|
||||
end
|
||||
local funcs = { "hypot", "log1p", "atan2" }
|
||||
check_math(funcs, { includes = "math.h" })
|
||||
-- stylua: ignore
|
||||
local funcs = {
|
||||
"csqrt",
|
||||
"cpow", "cexp", "clog",
|
||||
"csin", "ccos", "ctan",
|
||||
"csinh", "ccosh", "ctanh",
|
||||
"casin", "cacos", "catan",
|
||||
"casinh", "cacosh", "catanh",
|
||||
}
|
||||
check_math(funcs, { includes = "complex.h" })
|
||||
-- set the auto-generated a.xmake.h
|
||||
a_have_h = path.relative(os.projectdir() .. "/$(buildir)/a.xmake.h", "include/a")
|
||||
add_defines('A_HAVE_H="' .. a_have_h .. '"', { public = true })
|
||||
set_configvar("XMAKE_VERSION", tostring(xmake.version()))
|
||||
set_configvar("A_SIZE_FLOAT", float, { quote = false })
|
||||
add_configfiles("include/a.xmake.h.in")
|
||||
-- add include directories
|
||||
add_includedirs("include", { public = true })
|
||||
-- set export library symbols
|
||||
add_defines("A_EXPORTS")
|
||||
-- add the common source files
|
||||
if not table.empty(os.files("src/**.cpp")) and has_config("liba-cxx") then
|
||||
add_files("src/**.cpp")
|
||||
end
|
||||
add_files("src/**.c")
|
||||
-- add the platform options
|
||||
rpath = get_config("liba-rpath")
|
||||
if rpath then
|
||||
add_rpathdirs(rpath, { public = true })
|
||||
add_linkdirs(rpath, { public = true })
|
||||
end
|
||||
if not is_plat("windows", "mingw") then
|
||||
add_syslinks("m", { public = true })
|
||||
add_cxflags("-fPIC")
|
||||
end
|
||||
after_build(function(target)
|
||||
import("core.tool.linker")
|
||||
local object = target:objectfiles()
|
||||
local output = path.join(target:targetdir(), "liba.o")
|
||||
local program = linker.linkargv("binary", "cc", object, output, { target = target })
|
||||
try({
|
||||
function()
|
||||
os.runv(program, table.join("-nostdlib", "-o", output, "-r", object))
|
||||
end}
|
||||
end)
|
||||
after_install(function(target)
|
||||
local output = path.join(target:installdir(), "lib", "liba.o")
|
||||
os.trycp(path.join(target:targetdir(), "liba.o"), output)
|
||||
end)
|
||||
after_clean(function(target)
|
||||
os.tryrm(path.join(target:targetdir(), "liba.o"))
|
||||
end)
|
||||
end,
|
||||
})
|
||||
end)
|
||||
after_install(function(target)
|
||||
local output = path.join(target:installdir(), "lib", "liba.o")
|
||||
os.trycp(path.join(target:targetdir(), "liba.o"), output)
|
||||
end)
|
||||
after_clean(function(target)
|
||||
os.tryrm(path.join(target:targetdir(), "liba.o"))
|
||||
end)
|
||||
target_end()
|
||||
|
||||
target("alib")
|
||||
set_basename("a")
|
||||
-- make as a static library
|
||||
set_kind("static")
|
||||
-- add the header files for installing
|
||||
if not table.empty(os.files("include/**.hpp")) and has_config("liba-cxx") then
|
||||
add_headerfiles("include/(**.hpp)")
|
||||
set_basename("a")
|
||||
-- make as a static library
|
||||
set_kind("static")
|
||||
-- add the header files for installing
|
||||
if not table.empty(os.files("include/**.hpp")) and has_config("liba-cxx") then
|
||||
add_headerfiles("include/(**.hpp)")
|
||||
end
|
||||
add_headerfiles("include/(**.h)")
|
||||
add_headerfiles("$(buildir)/a.xmake.h", { prefixdir = "a" })
|
||||
after_install(function(target)
|
||||
if target:installdir() then
|
||||
local old = "#if defined(A_HAVE_H)"
|
||||
local new = '#include "a.xmake.h"\n' .. old
|
||||
local includedir = path.join(target:installdir(), "include")
|
||||
io.replace(path.join(includedir, "a", "a.h"), old, new, { plain = true })
|
||||
end
|
||||
add_headerfiles("include/(**.h)")
|
||||
add_headerfiles("$(buildir)/a.xmake.h", {prefixdir = "a"})
|
||||
after_install(function(target)
|
||||
if target:installdir() then
|
||||
local old = "#if defined(A_HAVE_H)"
|
||||
local new = "#include \"a.xmake.h\"\n"..old
|
||||
local includedir = path.join(target:installdir(), "include")
|
||||
io.replace(path.join(includedir, "a", "a.h"), old, new, {plain = true})
|
||||
end
|
||||
end)
|
||||
-- add the dependent target
|
||||
add_deps("a")
|
||||
end)
|
||||
-- add the dependent target
|
||||
add_deps("a")
|
||||
target_end()
|
||||
|
||||
target("liba")
|
||||
set_basename("a")
|
||||
set_prefixname("lib")
|
||||
-- make as a shared library
|
||||
set_kind("shared")
|
||||
-- add the platform options
|
||||
if is_plat("windows") then
|
||||
add_defines("A_IMPORTS", {interface = true})
|
||||
end
|
||||
-- add the dependent target
|
||||
add_deps("a")
|
||||
set_basename("a")
|
||||
set_prefixname("lib")
|
||||
-- make as a shared library
|
||||
set_kind("shared")
|
||||
-- add the platform options
|
||||
if is_plat("windows") then
|
||||
add_defines("A_IMPORTS", { interface = true })
|
||||
end
|
||||
-- add the dependent target
|
||||
add_deps("a")
|
||||
target_end()
|
||||
|
||||
-- option: liba-rust
|
||||
option("liba-rust")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_description("Enable/Disable rust")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
set_category("liba")
|
||||
set_description("Enable/Disable rust")
|
||||
option_end()
|
||||
|
||||
if has_config("liba-rust") then
|
||||
target("ars")
|
||||
add_deps("a")
|
||||
set_kind("static")
|
||||
set_basename("liba")
|
||||
add_files("src/lib.rs")
|
||||
if get_config("liba-float") == "4" then
|
||||
add_rcflags('--cfg=feature="float"')
|
||||
end
|
||||
add_deps("a")
|
||||
set_kind("static")
|
||||
set_basename("liba")
|
||||
add_files("src/lib.rs")
|
||||
if get_config("liba-float") == "4" then
|
||||
add_rcflags('--cfg=feature="float"')
|
||||
end
|
||||
target_end()
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue