-
-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve rule API and build dependency order #6202
Comments
Unified DAG ImplementationIf no additional dependency chains are added, xmake will add a default dependency order according to its internal build rules. rule("foo")
on_build_file(function (target, jobgraph, sourcefile, opt)
jobgraph:add_job(target:name() .. "/" .. sourcefile, function(job, opt)
-- TODO
end)
end, {jobgraph = true}) Source file granularity dependency order controlrule("foo")
on_build_files(function (target, jobgraph, sourcebatch, opt)
for _, sourcefile in sourcebatch.sourcefiles do
local job_name = target:name() .. "/" .. sourcefile
jobgraph:add_job(job_name, function(job, opt)
-- TODO
end)
-- add dependency chain, job -> other target jobs
jobgraph:add_deps(job_name, other_target:name() .. "/buildfiles")
end
end, {jobgraph = true}) Insert and remove build tasks in real timerule("foo")
on_build_file(function (target, jobgraph, sourcefile, opt)
local job_name = target:name() .. "/" .. sourcefile
jobgraph:add_job(job_name, function(job, opt)
-- TODO
jobgraph:add_job("zoo/build", function (job, opt)
end)
jobgraph:remove_job("bar/buildfiles")
end)
end, {jobgraph = true}) Add a preparation phase before buildingon_prepare scripts are called before all build scripts, we can do some things, e.g. scan c++ module source files, autogen ... rule("scan_module_files")
on_prepare(function (target, opt)
-- scan module files
end) or rule("scan_module_files")
on_prepare(function (target, jobgraph, opt)
jobgraph:add_job(target:name() .. "/scanfiles", function (job, opt)
-- scan module files
end)
end, {jobgraph = true}) or rule("scan_module_files")
set_extensions("*.mpp")
on_prepare_files(function (target, jobgraph, sourcebatch, opt)
jobgraph:add_job(target:name() .. "/scanfiles", function (job, opt)
-- scan module files
end)
end, {jobgraph = true}) Insert custom rule before built-in ruleWe can use -- the builtin rule
rule("c++")
-- ...
-- c++ depend on foo
rule("foo")
add_parents("c++")
-- ... Support for job group for same rulerule("foo")
on_build_files(function (target, jobgraph, sourcebatch, opt)
local group_name = target:name() .. "/buildfiles"
jobgraph:add_group(group_name, function ()
for _, sourcefile in sourcebatch.sourcefiles do
local job_name = target:name() .. "/" .. sourcefile
jobgraph:add_job(job_name, function(job, opt)
-- TODO
end)
end
end)
-- add dependency chain, other target jobs -> this build group
jobgraph:add_deps(other_target:name() .. "/buildfiles", group_name)
end, {jobgraph = true}) |
This is an initial draft, any idea? @Arthapz @SirLynix @star-hengxing |
It cover all my needs for module and the api is simple, I like it |
Ok, I will implement them in next version. |
Roadmap
Related
The text was updated successfully, but these errors were encountered: