import("core.project.project") 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}) 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)) 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") if not deps then return end local inherit = target:extraconf("rules", "engine.api", "inherit") local linkdirs = {} for _,dep in ipairs(deps) do local deptarget = project.target(dep) if deptarget:kind() == "static" then add_define(target, dep, is_static) add_packages(target, deptarget) if inherit == false then target:add("links", dep) local dir = deptarget:targetdir() if not linkdirs[dir] then target:add("linkdirs", path.join(os.projectdir(),dir)) linkdirs[dir] = true end end end end end