2024-08-02 22:14:00 +08:00
|
|
|
import("core.project.project")
|
2024-08-01 23:45:44 +08:00
|
|
|
function add_define(target, name, is_static)
|
|
|
|
|
local api = string.upper(name) .. "_API"
|
|
|
|
|
if is_static then
|
|
|
|
|
target:add("defines", api .. "=", api .. "_VAL", {public = false})
|
|
|
|
|
else
|
|
|
|
|
target:add("defines", api.."=__declspec(dllimport)", {interface=true})
|
2024-08-02 22:14:00 +08:00
|
|
|
target:add("defines", api.."=__declspec(dllexport)", api .. "_VAL", {public=false})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function add_packages(target, deptarget)
|
|
|
|
|
local packs = deptarget:get("packages")
|
|
|
|
|
if packs and #packs > 0 then
|
|
|
|
|
local packages = {}
|
|
|
|
|
for _,v in ipairs(packs) do
|
|
|
|
|
table.insert(packages, v)
|
|
|
|
|
end
|
|
|
|
|
table.insert(packages, {public = true})
|
|
|
|
|
target:add("packages", unpack(packages))
|
2024-08-01 23:45:44 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function main(target)
|
|
|
|
|
local name = target:name()
|
|
|
|
|
local is_static = target:kind() == "static"
|
|
|
|
|
add_define(target, name, is_static)
|
|
|
|
|
local deps = target:get("deps")
|
2024-08-02 22:14:00 +08:00
|
|
|
if not deps then return end
|
|
|
|
|
local inherit = target:extraconf("rules", "engine.api", "inherit")
|
|
|
|
|
local linkdirs = {}
|
2024-08-01 23:45:44 +08:00
|
|
|
for _,dep in ipairs(deps) do
|
|
|
|
|
local deptarget = project.target(dep)
|
|
|
|
|
if deptarget:kind() == "static" then
|
|
|
|
|
add_define(target, dep, is_static)
|
2024-08-02 22:14:00 +08:00
|
|
|
add_packages(target, deptarget)
|
|
|
|
|
if inherit == false then
|
|
|
|
|
target:add("links", dep)
|
|
|
|
|
local dir = deptarget:targetdir()
|
|
|
|
|
if not linkdirs[dir] then
|
2024-08-03 09:44:59 +08:00
|
|
|
target:add("linkdirs", path.join(os.projectdir(),dir))
|
2024-08-02 22:14:00 +08:00
|
|
|
linkdirs[dir] = true
|
|
|
|
|
end
|
|
|
|
|
end
|
2024-08-01 23:45:44 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|