diff options
| author | ruki <[email protected]> | 2019-09-19 00:55:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-09-18 23:33:46 +0800 |
| commit | 336029c68e4d0fc58bb55dca3ce5fb62bfdbf41b (patch) | |
| tree | 68072128ac59708b7f56615e626d87e30ed951e2 /xmake/templates/c++/tbox.static | |
| parent | bb3455b845e0b776937283b3ddae4ae557eea52e (diff) | |
rewrite templates
Diffstat (limited to 'xmake/templates/c++/tbox.static')
5 files changed, 17 insertions, 31 deletions
diff --git a/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp b/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp index 818ff6919..99a42f2a5 100644 --- a/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp +++ b/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp @@ -1,7 +1,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ -#include "[targetname]/interface.h" +#include "${TARGETNAME}/interface.h" /* ////////////////////////////////////////////////////////////////////////////////////// * main diff --git a/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua b/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua index c6f24eed7..b17bd70b4 100644 --- a/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua +++ b/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua @@ -5,7 +5,7 @@ target("demo") set_kind("binary") -- add deps - add_deps("[targetname]") + add_deps("${TARGETNAME}") -- add defines add_defines("__tb_prefix__=\"demo\"") diff --git a/xmake/templates/c++/tbox.static/project/src/_library/xmake.lua b/xmake/templates/c++/tbox.static/project/src/_library/xmake.lua index 71a5e698f..cb5f26ec6 100644 --- a/xmake/templates/c++/tbox.static/project/src/_library/xmake.lua +++ b/xmake/templates/c++/tbox.static/project/src/_library/xmake.lua @@ -1,14 +1,14 @@ -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("static") -- add defines - add_defines("__tb_prefix__=\"[targetname]\"") + add_defines("__tb_prefix__=\"${TARGETNAME}\"") -- add the header files for installing - add_headerfiles("../([targetname]/**.h)") + add_headerfiles("../(${TARGETNAME}/**.h)") -- add includes directory add_includedirs("..", {interface = true}) diff --git a/xmake/templates/c++/tbox.static/project/xmake.lua b/xmake/templates/c++/tbox.static/project/xmake.lua index 1ebaa6e34..02a9271a3 100644 --- a/xmake/templates/c++/tbox.static/project/xmake.lua +++ b/xmake/templates/c++/tbox.static/project/xmake.lua @@ -66,4 +66,6 @@ else add_syslinks("pthread", "dl", "m", "c") end add_requires("tbox", {debug = is_mode("debug")}) -- include project sources -includes("src/[targetname]", "src/[targetname]_demo") +includes("src/${TARGETNAME}", "src/${TARGETNAME}_demo") + +${FAQ} diff --git a/xmake/templates/c++/tbox.static/template.lua b/xmake/templates/c++/tbox.static/template.lua index a9acb2caa..b49207e48 100644 --- a/xmake/templates/c++/tbox.static/template.lua +++ b/xmake/templates/c++/tbox.static/template.lua @@ -1,25 +1,9 @@ --- set name -set_name("tbox.static") - --- set description -set_description("The Static Library (tbox)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") -add_macrofiles("src/_demo/main.cpp") -add_macrofiles("src/_demo/xmake.lua") -add_macrofiles("src/_library/xmake.lua") - --- set create script -on_create(function () - - -- rename target directory - os.mv("src/_library", "src/$(targetname)") - os.mv("src/_demo", "src/$(targetname)_demo") -end) +template("tbox.static") + add_configfiles("xmake.lua") + add_configfiles("src/_demo/main.cpp") + add_configfiles("src/_demo/xmake.lua") + add_configfiles("src/_library/xmake.lua") + after_create(function (template) + os.mv("src/_library", "src/${TARGETNAME}") + os.mv("src/_demo", "src/${TARGETNAME}_demo") + end) |
