diff options
| author | star9029 <[email protected]> | 2025-05-06 17:49:23 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2025-05-06 17:49:23 +0800 |
| commit | 7dc8bf58b37e7b3ba513b27490ee3107b29e0730 (patch) | |
| tree | dffaba2ca91486042a23dcdf36a8a8e2c1fab9a7 | |
| parent | a4d1b8c7ee7caa4d48ce8182e948e5058c005ec0 (diff) | |
Improve idl rule
| -rw-r--r-- | xmake/rules/platform/windows/idl/idl.lua | 93 | ||||
| -rw-r--r-- | xmake/rules/verilator/verilator.lua | 2 |
2 files changed, 31 insertions, 64 deletions
diff --git a/xmake/rules/platform/windows/idl/idl.lua b/xmake/rules/platform/windows/idl/idl.lua index 3f18380cf..7e8036a3b 100644 --- a/xmake/rules/platform/windows/idl/idl.lua +++ b/xmake/rules/platform/windows/idl/idl.lua @@ -32,19 +32,15 @@ function generate_single(target, sourcefile, opt) local fileconfig = target:fileconfig(sourcefile) local autogendir = path.join(target:autogendir(), "platform/windows/idl") - local enable_server = true - local enable_client = true + local enable_server + local enable_client local defs = table.wrap(target:get("defines") or {}) local incs = table.wrap(target:get("includedirs") or {}) local undefs = table.wrap(target:get("undefines") or {}) if fileconfig then - if fileconfig.server then - enable_server = fileconfig.server - end - if fileconfig.client then - enable_client = fileconfig.client - end + enable_server = fileconfig.server + enable_client = fileconfig.client if fileconfig.includedirs then table.join2(incs, fileconfig.includedirs) end @@ -110,7 +106,8 @@ function generate_single(target, sourcefile, opt) os.vrunv(midl.program, flags, { envs = msvc:runenvs() }) end, { files = sourcefile, - dependfile = dependfile + dependfile = target:dependfile(sourcefile), + changed = target:is_rebuilt() }) end @@ -124,67 +121,37 @@ function configure(target) end function generate_idl(target, jobgraph, sourcebatch, opt) - local idljob = target:fullname() .. "/generate/midl" - jobgraph:group(idljob, function() - for _, sourcefile in ipairs(sourcebatch.sourcefiles) do - local midljob = target:fullname() .. "/generate/" .. sourcefile - jobgraph:add(midljob, function (index, total, opt) - generate_single(target, sourcefile, opt) - end) - end - end) + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + local midljob = target:fullname() .. "/generate/" .. sourcefile + jobgraph:add(midljob, function (index, total, opt) + generate_single(target, sourcefile, opt) + end) + end end function build_idlfiles(target, jobgraph, sourcebatch, opt) local autogendir = path.join(target:autogendir(), "platform/windows/idl") - - local function addsrc(sourcename, suffix, mysources) - local fullfile = path.join(autogendir, sourcename .. suffix) - if os.exists(fullfile) then - table.insert(mysources, fullfile) + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + local fileconfig = target:fileconfig(sourcefile) + local files = {"_i.c", "_c.c", "_s.c"} + if fileconfig and fileconfig.proxy then + table.insert(files, "_p.c") end - end - - local build_midl = target:fullname() .. "/obj/midl" - jobgraph:group(build_midl, function() - for _, sourcefile in ipairs(sourcebatch.sourcefiles) do - local ccjob = target:fullname() .. "/obj/" .. sourcefile - jobgraph:add(ccjob, function (index, total, opt) - local fileconfig = target:fileconfig(sourcefile) - local enable_proxy = true - if fileconfig then - if fileconfig.proxy then - enable_proxy = fileconfig.proxy - end - end - local name = path.basename(sourcefile) - local mysources = {} + local name = path.basename(sourcefile) + for _, suffix in ipairs(files) do + local c_sourcefile = path.join(autogendir, name .. suffix) + local objectfile = target:objectfile(c_sourcefile) + local dependfile = target:dependfile(objectfile) + local cc_job_name = path.join(target:fullname(), "/obj/", c_sourcefile) + jobgraph:add(cc_job_name, function (index, total, jobopt) -- we don't have a way to detect which midl files are generated - addsrc(name, "_i.c", mysources) - if enable_proxy then - addsrc(name, "_p.c", mysources) + if os.exists(c_sourcefile) then + table.insert(target:objectfiles(), objectfile) + local build_opt = table.join({objectfile = objectfile, dependfile = dependfile, sourcekind = "cc", progress = jobopt.progress}, opt) + build_objectfiles.build_object(target, c_sourcefile, build_opt) end - addsrc(name, "_c.c", mysources) - addsrc(name, "_s.c", mysources) - - local batchcxx = { - rulename = "c.build", - sourcekind = "cc", - sourcefiles = mysources, - objectfiles = {}, - dependfiles = {} - } - for _, sourcefile in ipairs(batchcxx.sourcefiles) do - local objfile = target:objectfile(sourcefile) - local depfile = target:objectfile(objfile) - table.insert(target:objectfiles(), objfile) - table.insert(batchcxx.objectfiles, objfile) - table.insert(batchcxx.dependfiles, depfile) - table.insert(target:objectfiles(), objfile) - end - build_objectfiles.build(target, batchcxx, opt) - end) + end, {distcc = opt.distcc}) end - end) + end end diff --git a/xmake/rules/verilator/verilator.lua b/xmake/rules/verilator/verilator.lua index 0a87c40ff..084b2ab96 100644 --- a/xmake/rules/verilator/verilator.lua +++ b/xmake/rules/verilator/verilator.lua @@ -256,7 +256,7 @@ function build_cppfiles(target, jobgraph, sourcebatch, opt) dependfiles = {}} for _, sourcefile in ipairs(sourcefiles) do local objectfile = target:objectfile(sourcefile) - local dependfile = target:objectfile(objectfile) + local dependfile = target:dependfile(objectfile) table.insert(target:objectfiles(), objectfile) table.insert(sourcebatch_cpp.objectfiles, objectfile) table.insert(sourcebatch_cpp.dependfiles, dependfile) |
