-
I spent several hours today looking in to adopting xmake but the documentation to add custom targets appears to be the most minimum it could be. I am coming in from systems like Plan 9 Mk, PyDoIt and Ninja where it is easy to set up arbitrary rules for obscure tools. Some of these will probably need to be split in to their own separate issues.
two examples of order only dependencies here:
for example i was able to dig out a way to get a target to actually run what it should:
but since i used the objects kind i lose access to being able to set a filename which is also aggravating. so i have to use custom values to set that and xmake will always try to rebuild these. i could fiddle around with writing some documentation but i have no idea how this is supposed to work (short of just copying the protobuf code and changing some strings) for example in plan 9 mk the job is just
in please.build there's just a simple seven lines to make a new rule for something like this
i'm not yet sure if xmake is just not suitable for jobs other than bog standard cmake like builds, or if it's 👍 but just needs someone to write docs. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
some docs: https://xmake.io/#/manual/custom_rule?id=ruleon_buildcmd_file
see https://xmake.io/#/manual/builtin_modules?id=osexecv
Both of these can be used and have not been discarded. But using on_buildcmd_file will be simpler, and it can handle dependency update issues more conveniently. If you use on_build_file, you can also use on_build_file is more flexible, but on_buildcmd_file is simpler. For novices, I recommend using on_buildcmd_file related issue: #1246
rule('gsl')
set_extensions(".xml")
on_buildcmd_file(function (target, batchcmds, sourcefile, opt)
local script = target:values('gsl.script')
local outputfile = --? we need get output file path
batchcmds:execv("gsl", {"-script:" .. script, sourcefile}, {stdout = outputfile})
batchcmds:add_depfiles(sourcefile)
batchcmds:set_depmtime(os.mtime(outputfile))
batchcmds:set_depcache(target:dependfile(outputfile))
end
end) or rule('gsl')
set_extensions(".xml")
on_build_file(function (target, sourcefile, opt)
import("core.project.depend")
local script = target:values('gsl.script')
local outputfile = --? we need get output file path
depend.on_changed(function ()
os.execv("gsl", {"-script:" .. script, sourcefile}, {stdout = outputfile})
end, {dependfile = target:dependfile(outputfile), files = sourcefile, lastmtime = os.mtime(outputfile)})
end
end) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I do agree that the documentation for rules is too simple. It lacks examples for many useful cases. For me I usually read the built-in rules under the folder https://github.com/xmake-io/xmake/tree/master/xmake/rules (but I can seldom find the exactly same case as what I need) and get help from github discussions. In my port of suitesparse https://github.com/xq114/SuiteSparse-xmake/blob/main/xmake.lua I felt that even with detailed help from @waruqi (much thanks!), writing rules is still not a easy thing to do, at least for now. I wish if there was a more detailed documentation about the |
Beta Was this translation helpful? Give feedback.
-
The examples in the document really cannot meet the needs of all users. I suggest you can directly read https://github.com/xmake-io/xmake/tree/master/xmake/rules or https://github.com/xmake-io/xmake/tree/master/tests/projects Of course, if I have time, I will consider adding more examples to the document. It takes a lot of time and work to complete the documentation, and my current fragmentation time can only barely satisfy the resolution of issues and the development of some new features. I will update part of the documentation before publishing new version, and I will also consider adding documentation for the option and target instance interface later. |
Beta Was this translation helpful? Give feedback.
-
About rules, I have used batchcmd to simplify them before. I think it should not be too complicated to implement a rule by referring to the existing rules with batchcmd. Of course, I haven't used batchcmd to simplify some of the built-in rules of xmake, so it seems to be more complicated, and I will continue to update them later. |
Beta Was this translation helpful? Give feedback.
-
i'll go through some of these some time tonight and start trying to break them down in to individual issues. the ones that come to mind are:
goal would be getting these templates documented so you just open the docs for custom rules, pick the one closest to what you need, copy/paste it and change out some text. ex. please.build and meson shows off how |
Beta Was this translation helpful? Give feedback.
I do agree that the documentation for rules is too simple. It lacks examples for many useful cases. For me I usually read the built-in rules under the folder https://github.com/xmake-io/xmake/tree/master/xmake/rules (but I can seldom find the exactly same case as what I need) and get help from github discussions. In my port of suitesparse https://github.com/xq114/SuiteSparse-xmake/blob/main/xmake.lua I felt that even with detailed help from @waruqi (much thanks!), writing rules is still not a easy thing to do, at least for now. I wish if there was a more detailed documentation about the
target
object, theoption
object, and more examples of rules explained in detail about the usage, desig…