zengine/engine/xmake/rule_plugin/make_plugin.lua

30 lines
1.0 KiB
Lua
Raw Normal View History

2024-07-20 18:04:19 +08:00
import("core.project.depend")
function cmd_compile(target, genfile, file)
2024-07-27 14:24:46 +08:00
import("find_sdk")
print("find make_plugin", is_mode("debug"))
local plugin = find_sdk.find_my_program("make_plugin")
if not plugin then return end
print("cmd_compile plugin", genfile, file)
argv = { os.projectdir() , genfile, target:scriptdir(), file, target:name() .. ".plugin"}
os.execv(plugin.program, argv)
2024-07-20 18:04:19 +08:00
end
function main(target, file)
local sourcedir = path.join(target:autogendir({root = true}), target:plat())
if not os.isdir(sourcedir) then
os.mkdir(sourcedir)
end
2024-07-27 14:24:46 +08:00
local genfile = path.join(sourcedir,"xmake.lua")
2024-07-20 18:04:19 +08:00
local dependfile = target:dependfile(genfile)
depend.on_changed(
function()
cmd_compile(target, genfile, file)
end,
2024-07-27 14:24:46 +08:00
{dependfile = dependfile, files = {path.join(target:scriptdir(), file)}}
2024-07-20 18:04:19 +08:00
)
2024-07-27 14:24:46 +08:00
if os.exists(genfile) then
local dependency = io.load(genfile)
for k,v in ipairs(dependency) do
target:add("deps", v[1], v[2])
end
end
2024-07-20 18:04:19 +08:00
end