2021-07-31 21:11:20 +08:00
|
|
|
set_project("lcui")
|
2026-11-24 22:01:30 +08:00
|
|
|
set_version("3.0.0-alpha.2")
|
2026-11-19 21:56:04 +08:00
|
|
|
set_languages("c11")
|
2023-11-26 22:35:17 +08:00
|
|
|
set_warnings("all", "error")
|
2024-08-24 16:24:10 +08:00
|
|
|
set_policy("package.requires_lock", true)
|
2022-02-20 22:12:44 +08:00
|
|
|
add_rules("mode.debug", "mode.release", "mode.coverage")
|
|
|
|
|
add_rpathdirs("@loader_path/lib", "@loader_path")
|
2023-04-29 23:38:26 +08:00
|
|
|
add_defines("UNICODE", "_CRT_SECURE_NO_WARNINGS", "YUTIL_EXPORTS")
|
2026-11-19 21:56:04 +08:00
|
|
|
if not is_plat("windows") then
|
|
|
|
|
-- Strict C11 hides POSIX/GNU extensions behind feature macros.
|
|
|
|
|
add_defines("_GNU_SOURCE=1")
|
|
|
|
|
end
|
2023-02-23 23:41:16 +08:00
|
|
|
add_includedirs(
|
2023-03-13 23:27:36 +08:00
|
|
|
"lib/ctest/include",
|
2023-02-23 23:41:16 +08:00
|
|
|
"lib/yutil/include",
|
|
|
|
|
"lib/pandagl/include",
|
2023-04-29 23:38:26 +08:00
|
|
|
"lib/thread/include",
|
2023-03-13 23:27:36 +08:00
|
|
|
"lib/css/include",
|
2023-05-30 00:02:50 +08:00
|
|
|
"lib/i18n/include",
|
2024-09-17 23:56:43 +08:00
|
|
|
"lib/ptk/include",
|
2024-12-28 00:41:02 +08:00
|
|
|
"lib/router/include",
|
2023-03-19 22:27:01 +08:00
|
|
|
"lib/ui/include",
|
|
|
|
|
"lib/ui-server/include",
|
2023-04-29 23:38:26 +08:00
|
|
|
"lib/ui-xml/include",
|
2023-08-12 23:47:12 +08:00
|
|
|
"include",
|
|
|
|
|
{public = true}
|
2023-02-23 23:41:16 +08:00
|
|
|
)
|
2026-05-23 18:46:07 +08:00
|
|
|
|
|
|
|
|
option("memcheck")
|
|
|
|
|
set_default(false)
|
|
|
|
|
set_showmenu(true)
|
|
|
|
|
set_description("Enable memory check tools (drmemory on Windows, valgrind on Linux)")
|
|
|
|
|
option_end()
|
|
|
|
|
|
2026-11-19 01:26:36 +08:00
|
|
|
option("merge-archive")
|
|
|
|
|
set_default(false)
|
|
|
|
|
set_showmenu(true)
|
|
|
|
|
set_description("Merge the sub-library archives into lcui for standalone distribution")
|
|
|
|
|
option_end()
|
|
|
|
|
|
2026-05-23 18:46:07 +08:00
|
|
|
rule("tests.runnable")
|
|
|
|
|
on_test(function (target, opt)
|
|
|
|
|
import("core.base.option")
|
|
|
|
|
opt = opt or {}
|
|
|
|
|
local args = opt.runargs or {}
|
|
|
|
|
local rundir = opt.rundir or target:rundir()
|
|
|
|
|
local envs = opt.runenvs
|
|
|
|
|
local exec_opt = {curdir = rundir, envs = envs}
|
|
|
|
|
local exepath = path.absolute(target:targetfile())
|
|
|
|
|
if has_config("memcheck") then
|
|
|
|
|
local cmd
|
|
|
|
|
if is_plat("windows") then
|
|
|
|
|
cmd = {"drmemory", "--", exepath}
|
|
|
|
|
else
|
|
|
|
|
cmd = {"valgrind",
|
|
|
|
|
"--leak-check=full",
|
|
|
|
|
"--error-exitcode=42",
|
|
|
|
|
"--num-callers=20",
|
|
|
|
|
exepath}
|
|
|
|
|
end
|
|
|
|
|
for _, a in ipairs(args) do
|
|
|
|
|
table.insert(cmd, a)
|
|
|
|
|
end
|
|
|
|
|
local ok = try { function ()
|
|
|
|
|
os.execv(cmd[1], table.slice(cmd, 2), exec_opt)
|
|
|
|
|
return true
|
|
|
|
|
end }
|
|
|
|
|
return ok ~= nil, ok == nil and "memcheck failed" or nil
|
|
|
|
|
end
|
|
|
|
|
local ok = try { function ()
|
|
|
|
|
os.execv(exepath, args, exec_opt)
|
|
|
|
|
return true
|
|
|
|
|
end }
|
|
|
|
|
return ok ~= nil, ok == nil and "test failed" or nil
|
|
|
|
|
end)
|
|
|
|
|
rule_end()
|
|
|
|
|
|
2022-02-20 22:12:44 +08:00
|
|
|
includes("lib/*/xmake.lua")
|
|
|
|
|
includes("tests/xmake.lua")
|
2026-06-23 22:37:32 +08:00
|
|
|
includes("examples/xmake.lua")
|
2021-07-24 21:09:05 +08:00
|
|
|
|
2022-01-22 21:43:05 +08:00
|
|
|
option("ci-env", {showmenu = true, default = false})
|
|
|
|
|
|
|
|
|
|
if has_config("ci-env") then
|
|
|
|
|
add_defines("CI_ENV")
|
|
|
|
|
end
|
|
|
|
|
|
2021-07-24 21:09:05 +08:00
|
|
|
if is_plat("windows") then
|
|
|
|
|
add_defines("_CRT_SECURE_NO_WARNINGS")
|
|
|
|
|
else
|
|
|
|
|
add_cxflags("-fPIC")
|
|
|
|
|
if is_mode("coverage") then
|
|
|
|
|
add_cflags("-ftest-coverage", "-fprofile-arcs", {force = true})
|
|
|
|
|
add_syslinks("gcov")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
target("lcui")
|
2022-02-20 22:12:44 +08:00
|
|
|
set_kind("$(kind)")
|
2024-12-28 00:41:02 +08:00
|
|
|
add_files("src/**.c")
|
2023-04-29 23:38:26 +08:00
|
|
|
if is_kind("static") then
|
|
|
|
|
set_configvar("LCUI_STATIC_BUILD", 1)
|
|
|
|
|
elseif is_plat("windows") then
|
|
|
|
|
add_defines("LCUI_DLL_EXPORT")
|
|
|
|
|
end
|
2025-03-13 19:25:44 +08:00
|
|
|
if has_package("fontconfig") then
|
|
|
|
|
add_defines("HAVE_FONTCONFIG")
|
|
|
|
|
end
|
2023-02-23 23:41:16 +08:00
|
|
|
add_configfiles("src/config.h.in")
|
2022-02-20 22:12:44 +08:00
|
|
|
set_configdir("include/LCUI")
|
2023-04-29 23:38:26 +08:00
|
|
|
add_deps(
|
|
|
|
|
"yutil",
|
|
|
|
|
"libthread",
|
2024-09-17 23:56:43 +08:00
|
|
|
"libptk",
|
2023-04-29 23:38:26 +08:00
|
|
|
"pandagl",
|
|
|
|
|
"libcss",
|
2023-05-30 00:02:50 +08:00
|
|
|
"libi18n",
|
2023-04-29 23:38:26 +08:00
|
|
|
"libui",
|
|
|
|
|
"libui-server",
|
2024-12-28 00:41:02 +08:00
|
|
|
"librouter",
|
2023-04-29 23:38:26 +08:00
|
|
|
"libui-xml"
|
|
|
|
|
)
|
2024-12-28 00:41:02 +08:00
|
|
|
add_headerfiles("include/LCUI.h", "include/(LCUI/**.h)")
|
2026-11-02 22:49:00 +08:00
|
|
|
-- lcui is a self-contained package: the umbrella header LCUI.h includes each
|
|
|
|
|
-- sub-library's flat root header, so those headers must be installed together
|
|
|
|
|
-- with lcui for consumers to be able to #include <LCUI.h>.
|
|
|
|
|
-- Iterate over lib/* instead of listing every sub-library: the set of
|
|
|
|
|
-- sub-libraries changes over time (ui-cursor, ui-router and worker were
|
|
|
|
|
-- merged away) and the loop adapts on its own. A directory counts as a
|
|
|
|
|
-- sub-library only when it has its own xmake.lua -- lib/ui-router is a
|
|
|
|
|
-- leftover holding nothing but a generated config header.
|
|
|
|
|
for _, subdir in ipairs(os.filedirs("lib/*")) do
|
|
|
|
|
local incdir = subdir:gsub("\\", "/") .. "/include"
|
|
|
|
|
if os.isfile(subdir .. "/xmake.lua") and os.isdir(incdir) then
|
|
|
|
|
add_headerfiles(incdir .. "/(**.h)")
|
|
|
|
|
end
|
|
|
|
|
end
|
2026-11-19 01:26:36 +08:00
|
|
|
-- Merge the sub-library archives into lcui.lib for releases that ship a
|
|
|
|
|
-- single standalone library. Development and test builds keep the archives
|
|
|
|
|
-- separate so add_deps() can export each sub-library's own links.
|
|
|
|
|
if has_config("merge-archive") then
|
|
|
|
|
set_policy("build.merge_archive", true)
|
|
|
|
|
end
|