Recently, xmake's description syntax has been enhanced to support two different grammar styles at the same time.
set-add stylekey-val styleset-add styleThis is xmake's classic style, for example:
target("test")
set_kind("static")
add_defines("DEBUG")
add_files("src/*.c", "test/*.cpp")
key-val styleThis is added style recently, for example:
target
{
name = "test",
defines = "DEBUG",
files = {"src/*.c", "test/*.cpp"}
}
These two styles, xmake are currently compatible with the support, but our recommendations are:
In addition, not only for target, like option, task, template are supported in two ways to write, for example:
-- set-add style
option("demo")
set_default(true)
set_showmenu(true)
set_category("option")
set_description("Enable or disable the demo module", " =y|n")
-- key-val style
option
{
name = "demo",
default = true,
showmenu = true,
category = "option",
desciption = {"Enable or disable the demo module", " =y|n"}
}
The custom tasks or plugins can be written like this:
-- set-add style
task("hello")
-- on run
on_run(function ()
-- trace
print("hello xmake!")
end)
-- set menu
set_menu({
-- usage
usage = "xmake hello [options]"
-- description
, description = "Hello xmake!"
-- options
, options = {}
})
-- key-val style
task
{
name = "hello",
run = (function ()
-- trace
print("hello xmake!")
end),
menu = {
-- usage
usage = "xmake hello [options]"
-- description
, description = "Hello xmake!"
-- options
, options = {}
}
}