diff options
| author | ruki <[email protected]> | 2019-09-19 22:33:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-09-19 22:33:23 +0800 |
| commit | c33462b5d7afa7e82e9e0a278ca89ba4c4fbbe54 (patch) | |
| tree | a0acdad5b5c1280380564792f683dd5a5c96b4e3 | |
| parent | ab60d2da29bd4ec8e956b7ea0b17ee7f4e1d59c8 (diff) | |
| parent | e9ecfb089a3c4b358fb57ce3a6daece57cd5a388 (diff) | |
Merge branch 'template' into dev
92 files changed, 473 insertions, 1037 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 56f891e9a..ce350566c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * [#563](https://github.com/xmake-io/xmake/pull/563): Separate build rules for specific language files from action/build * [#570](https://github.com/xmake-io/xmake/issues/570): Add `qt.widgetapp` and `qt.quickapp` rules * [#576](https://github.com/xmake-io/xmake/issues/576): Uses `set_toolchain` instead of `add_tools` and `set_tools` +* Improve `xmake create` action ### Bugs fixed @@ -652,6 +653,7 @@ * [#563](https://github.com/xmake-io/xmake/pull/563): 重构构建逻辑,将特定语言的构建抽离到独立的rules中去 * [#570](https://github.com/xmake-io/xmake/issues/570): 改进Qt构建,将`qt.application`拆分成`qt.widgetapp`和`qt.quickapp`两个构建规则 * [#576](https://github.com/xmake-io/xmake/issues/576): 使用`set_toolchain`替代`add_tools`和`set_tools`,解决老接口使用歧义,提供更加易理解的设置方式 +* 改进`xmake create`创建模板工程 ### Bugs修复 diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 07d134cba..5636a89c0 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -90,6 +90,6 @@ function main() -- trace if option.get("rebuild") then - cprint("${bright}build ok!${clear}${ok_hand}") + cprint("${bright}build ok!${clear}") end end diff --git a/xmake/actions/build/trybuild.lua b/xmake/actions/build/trybuild.lua index 50013fd08..5049f0eab 100644 --- a/xmake/actions/build/trybuild.lua +++ b/xmake/actions/build/trybuild.lua @@ -146,7 +146,7 @@ function main(targetname) -- trace if ok then - cprint("${bright}build ok!${clear}${ok_hand}") + cprint("${bright}build ok!${clear}") else raise("build failed!") end diff --git a/xmake/actions/config/scangen.lua b/xmake/actions/config/scangen.lua index c459491f2..792fdb018 100644 --- a/xmake/actions/config/scangen.lua +++ b/xmake/actions/config/scangen.lua @@ -21,7 +21,6 @@ -- imports import("core.project.config") import("core.project.project") -import("core.project.template") import("core.language.language") -- scan project and generate xmake.lua automaticlly if the project codes exist @@ -145,7 +144,7 @@ function main() end -- add FAQ - file:print(template.faq()) + file:print(io.readfile(path.join(os.programdir(), "scripts", "faq.lua"))) -- exit file file:close() @@ -157,5 +156,5 @@ function main() end -- trace - cprint("${bright}xmake.lua generated, scan ok!${clear}${ok_hand}") + cprint("${bright}xmake.lua generated, scan ok!${clear}") end diff --git a/xmake/actions/create/main.lua b/xmake/actions/create/main.lua index bfd07e7bf..7d0dfeb97 100644 --- a/xmake/actions/create/main.lua +++ b/xmake/actions/create/main.lua @@ -23,6 +23,107 @@ import("core.base.option") import("core.project.project") import("core.project.template") +-- get the builtin variables +function _get_builtinvars(tempinst, targetname) + return {TARGETNAME = targetname, + FAQ = function() return io.readfile(path.join(os.programdir(), "scripts", "faq.lua")) end} +end + +-- create project from template +function _create_project(language, templateid, targetname) + + -- check the language + assert(language, "no language!") + + -- check the template id + assert(templateid, "no template id!") + + -- load all templates for the given language + local templates = template.templates(language) + + -- TODO: deprecated + -- in order to be compatible with the old version template + local templates_new = { quickapp_qt = "qt.quickapp", + widgetapp_qt = "qt.widgetapp", + console_qt = "qt.console", + static_qt = "qt.static", + shared_qt = "qt.shared", + console_tbox = "tbox.console", + static_tbox = "tbox.static", + shared_tbox = "tbox.shared"} + if templates_new[templateid] then + cprint("${yellow}deprecated: please uses template(%s) instead of template(%s)!", templates_new[templateid], templateid) + templateid = templates_new[templateid] + end + + -- get the given template instance + local tempinst = nil + if templates then + for _, t in ipairs(templates) do + if t:name() == templateid then + tempinst = t + break + end + end + end + assert(tempinst and tempinst:scriptdir(), "invalid template id: %s!", templateid) + + -- get project directory + local projectdir = path.absolute(option.get("project") or path.join(os.curdir(), targetname)) + + -- ensure the project directory + if not os.isdir(projectdir) then + os.mkdir(projectdir) + end + + -- enter the project directory + os.cd(projectdir) + + -- create project + local filedirs = {} + local sourcedir = path.join(tempinst:scriptdir(), "project") + if os.isdir(sourcedir) then + for _, filedir in ipairs(os.filedirs(path.join(sourcedir, "*"))) do + os.cp(filedir, projectdir) + table.insert(filedirs, path.relative(filedir, sourcedir)) + end + os.cp(path.join(os.programdir(), "scripts", "gitignore"), path.join(projectdir, ".gitignore")) + table.insert(filedirs, ".gitignore") + else + raise("template(%s): project not found!", templateid) + end + + -- get the builtin variables + local builtinvars = _get_builtinvars(tempinst, targetname) + + -- replace all variables + for _, configfile in ipairs(tempinst:get("configfiles")) do + local pattern = "%${(.-)}" + io.gsub(configfile, "(" .. pattern .. ")", function(_, variable) + variable = variable:trim() + local value = builtinvars[variable] + return type(value) == "function" and value() or value + end) + end + + -- do after_create + local after_create = tempinst:get("create_after") + if after_create then + after_create(tempinst, {targetname = targetname}) + end + + -- trace + for _, filedir in ipairs(filedirs) do + if os.isdir(filedir) then + for _, file in ipairs(os.files(path.join(filedir, "**"))) do + cprint(" ${green}[+]: ${clear}%s", file) + end + else + cprint(" ${green}[+]: ${clear}%s", filedir) + end + end +end + -- main function main() @@ -30,14 +131,14 @@ function main() os.cd(os.workingdir()) -- the target name - local targetname = option.get("target") or option.get("name") or path.basename(project.directory()) or "demo" + local targetname = option.get("target") or path.basename(project.directory()) or "demo" -- trace cprint("${bright}create %s ...", targetname) -- create project from template - template.create(option.get("language"), option.get("template"), targetname) + _create_project(option.get("language"), option.get("template"), targetname) -- trace - cprint("${bright}create ok!${ok_hand}") + cprint("${bright}create ok!") end diff --git a/xmake/actions/create/xmake.lua b/xmake/actions/create/xmake.lua index dee04b4b8..e0e8c75da 100644 --- a/xmake/actions/create/xmake.lua +++ b/xmake/actions/create/xmake.lua @@ -38,8 +38,7 @@ task("create") -- options , options = { - {'n', "name", "kv", nil, "The project name." } - , {'l', "language", "kv", "c", "The project language" + {'l', "language", "kv", "c++", "The project language" -- show the description of all languages , function () @@ -68,8 +67,8 @@ task("create") local templates = {} for _, l in ipairs(template.languages()) do for _, t in ipairs(template.templates(l)) do - templates[t.name] = templates[t.name] or {} - table.insert(templates[t.name], l) + templates[t:name()] = templates[t:name()] or {} + table.insert(templates[t:name()], l) end end diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua index f223b96fa..166f9c71f 100644 --- a/xmake/actions/install/main.lua +++ b/xmake/actions/install/main.lua @@ -82,7 +82,7 @@ function main() install(targetname or ifelse(option.get("all"), "__all", "__def")) -- trace - cprint("${bright}install ok!${clear}${ok_hand}") + cprint("${bright}install ok!${clear}") end, catch @@ -103,7 +103,7 @@ function main() install(targetname or ifelse(option.get("all"), "__all", "__def")) -- trace - cprint("${bright}install ok!${clear}${ok_hand}") + cprint("${bright}install ok!${clear}") -- ok return true @@ -131,7 +131,7 @@ function main() sudo.runl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or ifelse(option.get("all"), "__all", "__def"), option.get("installdir"), option.get("prefix")}) -- trace - cprint("${bright}install ok!${clear}${ok_hand}") + cprint("${bright}install ok!${clear}") end end end diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua index 0b6558b42..62beecea7 100644 --- a/xmake/actions/uninstall/main.lua +++ b/xmake/actions/uninstall/main.lua @@ -44,7 +44,7 @@ function main() uninstall(targetname) -- trace - cprint("${bright}uninstall ok!${clear}${ok_hand}") + cprint("${bright}uninstall ok!${clear}") end, catch @@ -62,7 +62,7 @@ function main() uninstall(targetname) -- trace - cprint("${bright}uninstall ok!${clear}${ok_hand}") + cprint("${bright}uninstall ok!${clear}") -- ok return true @@ -90,7 +90,7 @@ function main() sudo.runl(path.join(os.scriptdir(), "uninstall_admin.lua"), {targetname or "__all", option.get("installdir"), option.get("prefix")}) -- trace - cprint("${bright}uninstall ok!${clear}${ok_hand}") + cprint("${bright}uninstall ok!${clear}") end end end diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index 82ac2bea2..4e63ce544 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -386,7 +386,7 @@ function task.tasks() for _, dir in ipairs(dirs) do -- get files - local files = os.match(path.join(dir, "**/xmake.lua")) + local files = os.files(path.join(dir, "*", "xmake.lua")) if files then for _, filepath in ipairs(files) do diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index bfc742087..8fa4b63b9 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1145,10 +1145,7 @@ function package.load_from_system(packagename) end -- new an instance - local instance, errors = _instance.new(packagename, scopeinfo.new("package", packageinfo)) - if not instance then - return nil, errors - end + local instance = _instance.new(packagename, scopeinfo.new("package", packageinfo)) -- mark as system or 3rd package instance._isSys = true @@ -1195,10 +1192,7 @@ function package.load_from_project(packagename, project) end -- new an instance - local instance, errors = _instance.new(packagename, packages[packagename]) - if not instance then - return nil, errors - end + local instance = _instance.new(packagename, packages[packagename]) -- save instance to the cache package._PACKAGES[packagename] = instance @@ -1259,10 +1253,7 @@ function package.load_from_repository(packagename, repo, packagedir, packagefile end -- new an instance - local instance, errors = _instance.new(packagename, packageinfo, path.directory(scriptpath)) - if not instance then - return nil, errors - end + local instance = _instance.new(packagename, packageinfo, path.directory(scriptpath)) -- save repository instance._REPO = repo diff --git a/xmake/core/project/template.lua b/xmake/core/project/template.lua index 4dae83130..8fd7fa6a5 100644 --- a/xmake/core/project/template.lua +++ b/xmake/core/project/template.lua @@ -19,7 +19,8 @@ -- -- define module: template -local template = template or {} +local template = template or {} +local _instance = _instance or {} -- load modules local os = require("base/os") @@ -28,11 +29,36 @@ local path = require("base/path") local table = require("base/table") local utils = require("base/utils") local string = require("base/string") -local option = require("base/option") -local sandbox = require("sandbox/sandbox") -local project = require("project/project") local interpreter = require("base/interpreter") -local deprecated = require("base/deprecated") + +-- new an instance +function _instance.new(name, info, scriptdir) + local instance = table.inherit(_instance) + instance._NAME = name + instance._INFO = info + instance._SCRIPTDIR = scriptdir + return instance +end + +-- get the package name +function _instance:name() + return self._NAME +end + +-- get the package configure +function _instance:get(name) + + -- get it from info first + local value = self._INFO:get(name) + if value ~= nil then + return value + end +end + +-- get the script directory +function _instance:scriptdir() + return self._SCRIPTDIR +end -- the interpreter function template._interpreter() @@ -46,29 +72,18 @@ function template._interpreter() local interp = interpreter.new() assert(interp) - -- define apis (only root scope) + -- define apis interp:api_define { values = { - -- set_xxx - "set_name" - , "set_description" - , "set_projectdir" -- add_xxx - , "add_macrofiles" + "template.add_configfiles" } , script = { - -- on_xxx - "on_create" - } - , dictionary = - { - -- set_xxx - "set_macros" - -- add_xxx - , "add_macros" + -- after_xxx + "template.after_create" } } @@ -79,32 +94,6 @@ function template._interpreter() return interp end --- replace macros -function template._replace(macros, macrofiles) - - -- check - assert(macros and macrofiles) - - -- make all files - local files = {} - for _, macrofile in ipairs(table.wrap(macrofiles)) do - local matchfiles = os.files(macrofile) - if matchfiles then - table.join2(files, matchfiles) - end - end - - -- replace all files - for _, file in ipairs(files) do - for macro, value in pairs(macros) do - io.gsub(file, "%[" .. macro .. "%]", value) - end - end - - -- ok - return true -end - -- get the language list function template.languages() @@ -135,7 +124,7 @@ function template.templates(language) -- load all templates local templates = {} - local templatefiles = os.files(path.join(os.programdir(), "templates", language, "**", "template.lua")) + local templatefiles = os.files(path.join(os.programdir(), "templates", language, "*", "template.lua")) if templatefiles then -- load template @@ -147,225 +136,32 @@ function template.templates(language) os.raise(errors) end - -- load templates - local results, errors = interp:make(nil, true, true) + -- load template + local results, errors = interp:make("template", true, true) if not results then - -- trace os.raise(errors) end - -- save template directory - results:set("_DIRECTORY", path.directory(templatefile)) - - -- insert to templates - table.insert(templates, results:info()) - end - end - return templates -end - --- create project from template -function template.create(language, templateid, targetname) - - -- check the language - if not language then - return false, "no language!" - end - - -- check the template id - if not templateid then - return false, "no template id!" - end - - -- get interpreter - local interp = template._interpreter() - assert(interp) - - -- get project directory - local projectdir = path.absolute(option.get("project") or path.join(os.curdir(), targetname)) - - -- set filter - interp:filter():register("template", function (variable) - - -- init maps - local maps = - { - targetname = targetname - , projectdir = projectdir - } - - -- map it - local result = maps[variable] - if result ~= nil then - return result - end - - -- ok? - return variable - - end) - - -- load all templates for the given language - local templates = template.templates(language) - - -- TODO: deprecated - -- in order to be compatible with the old version template - local templates_old = { quickapp_qt = "qt.quickapp", - widgetapp_qt = "qt.widgetapp", - console_qt = "qt.console", - static_qt = "qt.static", - shared_qt = "qt.shared", - console_tbox = "tbox.console", - static_tbox = "tbox.static", - shared_tbox = "tbox.shared"} - if templates_old[templateid] then - deprecated.add("template(" .. templates_old[templateid] .. ")", "template(" .. templateid .. ")") - templateid = templates_old[templateid] - end - - -- get the given template module - local module = nil - if templates then - for _, t in ipairs(templates) do - if t.name == templateid then - module = t + -- get the template name and info + local templatename = nil + local templateinfo = nil + for name, info in pairs(results) do + templatename = name + templateinfo = info break end - end - end - - -- load the template module - if not module then - return false, string.format("invalid template id: %s!", templateid) - end - - -- enter the template directory - if not module._DIRECTORY or not os.cd(module._DIRECTORY) then - return false, string.format("not found template id: %s!", templateid) - end - - -- check the template project - if not module.projectdir or not os.isdir(module.projectdir) then - return false, string.format("the template project not exists!") - end - - -- ensure the project directory - if not os.isdir(projectdir) then - os.mkdir(projectdir) - end - - -- copy the project files - local ok, errors = os.cp(path.join(module.projectdir, "*"), projectdir) - if not ok then - return false, errors - end - - -- enter the project directory - if not os.cd(projectdir) then - return false, string.format("can not enter %s!", projectdir) - end - - -- replace macros - if module.macros and module.macrofiles then - ok, errors = template._replace(module.macros, module.macrofiles) - if not ok then - return false, errors - end - end + if not templateinfo then + return nil, string.format("%s: package not found!", templatefile) + end - -- create project - if module.create then - local ok, errors = sandbox.load(module.create) - if not ok then - utils.error(errors) - return false - end - end + -- new an instance + local instance = _instance.new(templatename, templateinfo, path.directory(templatefile)) - -- append FAQ to xmake.lua - local projectfile = path.join(projectdir, "xmake.lua") - if os.isfile(projectfile) then - local file = io.open(projectfile, "a+") - if file then - file:print("") - file:print(template.faq()) - file:close() + -- insert to templates + table.insert(templates, instance) end end - - -- generate .gitignore - os.cp(path.join(os.programdir(), "scripts", "gitignore"), path.join(projectdir, ".gitignore")) - - -- ok - return true -end - --- get FAQ -function template.faq() - return [[ --- --- FAQ --- --- You can enter the project directory firstly before building project. --- --- $ cd projectdir --- --- 1. How to build project? --- --- $ xmake --- --- 2. How to configure project? --- --- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release] --- --- 3. Where is the build output directory? --- --- The default output directory is `./build` and you can configure the output directory. --- --- $ xmake f -o outputdir --- $ xmake --- --- 4. How to run and debug target after building project? --- --- $ xmake run [targetname] --- $ xmake run -d [targetname] --- --- 5. How to install target to the system directory or other output directory? --- --- $ xmake install --- $ xmake install -o installdir --- --- 6. Add some frequently-used compilation flags in xmake.lua --- --- @code --- -- add macro defination --- add_defines("NDEBUG", "_GNU_SOURCE=1") --- --- -- set warning all as error --- set_warnings("all", "error") --- --- -- set language: c99, c++11 --- set_languages("c99", "cxx11") --- --- -- set optimization: none, faster, fastest, smallest --- set_optimize("fastest") --- --- -- add include search directories --- add_includedirs("/usr/include", "/usr/local/include") --- --- -- add link libraries and search directories --- add_links("tbox", "z", "pthread") --- add_linkdirs("/usr/local/lib", "/usr/lib") --- --- -- add compilation and link flags --- add_cxflags("-stdnolib", "-fno-strict-aliasing") --- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true}) --- --- @endcode --- --- 7. If you want to known more usage about xmake, please see http://xmake.io/#/home --- - ]] + return templates end -- return module: template diff --git a/xmake/core/sandbox/modules/import/core/project/template.lua b/xmake/core/sandbox/modules/import/core/project/template.lua index 59b3d9e67..83ab6407d 100644 --- a/xmake/core/sandbox/modules/import/core/project/template.lua +++ b/xmake/core/sandbox/modules/import/core/project/template.lua @@ -47,20 +47,5 @@ function sandbox_core_project_template.templates(language) return templates end --- create project from template -function sandbox_core_project_template.create(language, templateid, targetname) - - -- create it - local ok, errors = template.create(language, templateid, targetname) - if not ok then - raise(errors) - end -end - --- get FAQ -function sandbox_core_project_template.faq() - return template.faq() -end - -- return module return sandbox_core_project_template diff --git a/xmake/plugins/doxygen/main.lua b/xmake/plugins/doxygen/main.lua index 6b94fd1e1..fe9395aef 100644 --- a/xmake/plugins/doxygen/main.lua +++ b/xmake/plugins/doxygen/main.lua @@ -108,5 +108,5 @@ function main() -- trace cprint("${bright green}result: ${default green}%s/html/index.html", outputdir) - cprint("${bright}doxygen ok!${ok_hand}") + cprint("${bright}doxygen ok!") end diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua index cfcf10c2b..0f55057b3 100755 --- a/xmake/plugins/project/main.lua +++ b/xmake/plugins/project/main.lua @@ -81,5 +81,5 @@ function main() environment.leave("toolchains") -- trace - cprint("${bright}create ok!${ok_hand}") + cprint("${bright}create ok!") end diff --git a/xmake/scripts/faq.lua b/xmake/scripts/faq.lua new file mode 100644 index 000000000..602c89c34 --- /dev/null +++ b/xmake/scripts/faq.lua @@ -0,0 +1,68 @@ +-- +-- FAQ +-- +-- You can enter the project directory firstly before building project. +-- +-- $ cd projectdir +-- +-- 1. How to build project? +-- +-- $ xmake +-- +-- 2. How to configure project? +-- +-- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release] +-- +-- 3. Where is the build output directory? +-- +-- The default output directory is `./build` and you can configure the output directory. +-- +-- $ xmake f -o outputdir +-- $ xmake +-- +-- 4. How to run and debug target after building project? +-- +-- $ xmake run [targetname] +-- $ xmake run -d [targetname] +-- +-- 5. How to install target to the system directory or other output directory? +-- +-- $ xmake install +-- $ xmake install -o installdir +-- +-- 6. Add some frequently-used compilation flags in xmake.lua +-- +-- @code +-- -- add debug and release modes +-- add_rules("mode.debug", "mode.release") +-- +-- -- add macro defination +-- add_defines("NDEBUG", "_GNU_SOURCE=1") +-- +-- -- set warning all as error +-- set_warnings("all", "error") +-- +-- -- set language: c99, c++11 +-- set_languages("c99", "c++11") +-- +-- -- set optimization: none, faster, fastest, smallest +-- set_optimize("fastest") +-- +-- -- add include search directories +-- add_includedirs("/usr/include", "/usr/local/include") +-- +-- -- add link libraries and search directories +-- add_links("tbox") +-- add_linkdirs("/usr/local/lib", "/usr/lib") +-- +-- -- add system link libraries +-- add_syslinks("z", "pthread") +-- +-- -- add compilation and link flags +-- add_cxflags("-stdnolib", "-fno-strict-aliasing") +-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true}) +-- +-- @endcode +-- +-- 7. If you want to known more usage about xmake, please see https://xmake.io +-- diff --git a/xmake/templates/c++/console/project/xmake.lua b/xmake/templates/c++/console/project/xmake.lua index 86da6b2c0..5ea3f6136 100644 --- a/xmake/templates/c++/console/project/xmake.lua +++ b/xmake/templates/c++/console/project/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -11,3 +11,4 @@ target("[targetname]") -- add files add_files("src/*.cpp") +${FAQ} diff --git a/xmake/templates/c++/console/template.lua b/xmake/templates/c++/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/c++/console/template.lua +++ b/xmake/templates/c++/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/qt.console/project/xmake.lua b/xmake/templates/c++/qt.console/project/xmake.lua index 5dba5a131..4025a7218 100644 --- a/xmake/templates/c++/qt.console/project/xmake.lua +++ b/xmake/templates/c++/qt.console/project/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- add rules add_rules("qt.console") @@ -11,3 +11,4 @@ target("[targetname]") -- add files add_files("src/*.cpp") +${FAQ} diff --git a/xmake/templates/c++/qt.console/template.lua b/xmake/templates/c++/qt.console/template.lua index 5ca8ed018..6b5c26b3a 100644 --- a/xmake/templates/c++/qt.console/template.lua +++ b/xmake/templates/c++/qt.console/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("qt.console") - --- set description -set_description("The Console Program (Qt)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("qt.console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/qt.quickapp/project/xmake.lua b/xmake/templates/c++/qt.quickapp/project/xmake.lua index ed756850c..0a55677e8 100644 --- a/xmake/templates/c++/qt.quickapp/project/xmake.lua +++ b/xmake/templates/c++/qt.quickapp/project/xmake.lua @@ -3,16 +3,16 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- add rules add_rules("qt.quickapp") - -- add headers + -- add headerfiles add_headerfiles("src/*.h") -- add files add_files("src/*.cpp") add_files("src/qml.qrc") - +${FAQ} diff --git a/xmake/templates/c++/qt.quickapp/template.lua b/xmake/templates/c++/qt.quickapp/template.lua index 56e3adf6f..144deb174 100644 --- a/xmake/templates/c++/qt.quickapp/template.lua +++ b/xmake/templates/c++/qt.quickapp/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("qt.quickapp") - --- set description -set_description("The Quick Application (Qt)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("qt.quickapp") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/qt.quickapp_static/project/xmake.lua b/xmake/templates/c++/qt.quickapp_static/project/xmake.lua index f341f724f..b606b5f20 100644 --- a/xmake/templates/c++/qt.quickapp_static/project/xmake.lua +++ b/xmake/templates/c++/qt.quickapp_static/project/xmake.lua @@ -6,12 +6,12 @@ add_rules("mode.debug", "mode.release") includes("qt_add_static_plugins.lua") -- add target -target("[targetname]") +target("${TARGETNAME}") -- add rules add_rules("qt.quickapp_static") - -- add headers + -- add headerfiles add_headerfiles("src/*.h") -- add files @@ -22,3 +22,4 @@ target("[targetname]") qt_add_static_plugins("QtQuick2Plugin", {linkdirs = "qml/QtQuick.2", links = "qtquick2plugin"}) qt_add_static_plugins("QtQuick2WindowPlugin", {linkdirs = "qml/QtQuick/Window.2", links = "windowplugin"}) +${FAQ} diff --git a/xmake/templates/c++/qt.quickapp_static/template.lua b/xmake/templates/c++/qt.quickapp_static/template.lua index ab3239f58..ff528f69f 100644 --- a/xmake/templates/c++/qt.quickapp_static/template.lua +++ b/xmake/templates/c++/qt.quickapp_static/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("qt.quickapp_static") - --- set description -set_description("The Quick Application (Qt/Static)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("qt.quickapp_static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/qt.shared/project/xmake.lua b/xmake/templates/c++/qt.shared/project/xmake.lua index 0f6894fe9..ac70b48de 100644 --- a/xmake/templates/c++/qt.shared/project/xmake.lua +++ b/xmake/templates/c++/qt.shared/project/xmake.lua @@ -3,12 +3,12 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- add rules add_rules("qt.shared") - -- add headers + -- add headerfiles add_headerfiles("src/*.h") -- add files @@ -19,3 +19,5 @@ target("[targetname]") -- add frameworks add_frameworks("QtGui") + +${FAQ} diff --git a/xmake/templates/c++/qt.shared/template.lua b/xmake/templates/c++/qt.shared/template.lua index d98fae5c1..24960332a 100644 --- a/xmake/templates/c++/qt.shared/template.lua +++ b/xmake/templates/c++/qt.shared/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("qt.shared") - --- set description -set_description("The Share Library (Qt)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("qt.shared") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/qt.static/project/xmake.lua b/xmake/templates/c++/qt.static/project/xmake.lua index e69a47e61..2bf4505c5 100644 --- a/xmake/templates/c++/qt.static/project/xmake.lua +++ b/xmake/templates/c++/qt.static/project/xmake.lua @@ -3,12 +3,12 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- add rules add_rules("qt.static") - -- add headers + -- add headerfiles add_headerfiles("src/*.h") -- add files @@ -16,3 +16,5 @@ target("[targetname]") -- add frameworks add_frameworks("QtGui") + +${FAQ} diff --git a/xmake/templates/c++/qt.static/template.lua b/xmake/templates/c++/qt.static/template.lua index 60db73bcc..3a6f18019 100644 --- a/xmake/templates/c++/qt.static/template.lua +++ b/xmake/templates/c++/qt.static/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("qt.static") - --- set description -set_description("The Static Library (Qt)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("qt.static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/qt.widgetapp/project/xmake.lua b/xmake/templates/c++/qt.widgetapp/project/xmake.lua index 8b7bd5ec8..e7407f1fd 100644 --- a/xmake/templates/c++/qt.widgetapp/project/xmake.lua +++ b/xmake/templates/c++/qt.widgetapp/project/xmake.lua @@ -3,12 +3,12 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- add rules add_rules("qt.widgetapp") - -- add headers + -- add headerfiles add_headerfiles("src/*.h") -- add files @@ -18,4 +18,4 @@ target("[targetname]") -- add files with Q_OBJECT meta (only for qt.moc) add_files("src/mainwindow.h") - +${FAQ} diff --git a/xmake/templates/c++/qt.widgetapp/template.lua b/xmake/templates/c++/qt.widgetapp/template.lua index 94aeacb67..97a9fe3bb 100644 --- a/xmake/templates/c++/qt.widgetapp/template.lua +++ b/xmake/templates/c++/qt.widgetapp/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("qt.widgetapp") - --- set description -set_description("The Widget Application (Qt)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("qt.widgetapp") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua b/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua index 3c8e46c85..fe4eb971c 100644 --- a/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua +++ b/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua @@ -6,12 +6,12 @@ add_rules("mode.debug", "mode.release") includes("qt_add_static_plugins.lua") -- add target -target("[targetname]") +target("${TARGETNAME}") -- add rules add_rules("qt.widgetapp_static") - -- add headers + -- add headerfiles add_headerfiles("src/*.h") -- add files @@ -23,3 +23,5 @@ target("[targetname]") -- add plugin: QSvgPlugin (optional) qt_add_static_plugins("QSvgPlugin", {linkdirs = "plugins/imageformats", links = {"qsvg", "Qt5Svg"}}) + +${FAQ} diff --git a/xmake/templates/c++/qt.widgetapp_static/template.lua b/xmake/templates/c++/qt.widgetapp_static/template.lua index 8b3848e4d..6ccd9b178 100644 --- a/xmake/templates/c++/qt.widgetapp_static/template.lua +++ b/xmake/templates/c++/qt.widgetapp_static/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("qt.widgetapp_static") - --- set description -set_description("The Widget Application (Qt/Static)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("qt.widgetapp_static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/shared/project/xmake.lua b/xmake/templates/c++/shared/project/xmake.lua index 59fe4dbe6..79ce52043 100644 --- a/xmake/templates/c++/shared/project/xmake.lua +++ b/xmake/templates/c++/shared/project/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("shared") @@ -12,15 +12,15 @@ target("[targetname]") add_files("src/interface.cpp") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") -- add deps - add_deps("[targetname]") + add_deps("${TARGETNAME}") -- add files add_files("src/test.cpp") - +${FAQ} diff --git a/xmake/templates/c++/shared/template.lua b/xmake/templates/c++/shared/template.lua index 666542844..d7ec5bae4 100644 --- a/xmake/templates/c++/shared/template.lua +++ b/xmake/templates/c++/shared/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("shared") - --- set description -set_description("The Shared Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("shared") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/static_library/project/xmake.lua b/xmake/templates/c++/static_library/project/xmake.lua index 8375d78fe..c42aa839c 100644 --- a/xmake/templates/c++/static_library/project/xmake.lua +++ b/xmake/templates/c++/static_library/project/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("static") @@ -12,15 +12,15 @@ target("[targetname]") add_files("src/interface.cpp") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") -- add deps - add_deps("[targetname]") + add_deps("${TARGETNAME}") -- add files add_files("src/test.cpp") - +${FAQ} diff --git a/xmake/templates/c++/static_library/template.lua b/xmake/templates/c++/static_library/template.lua index f05045e07..abfe91a4b 100644 --- a/xmake/templates/c++/static_library/template.lua +++ b/xmake/templates/c++/static_library/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("static") - --- set description -set_description("The Static Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c++/tbox.console/project/src/xmake.lua b/xmake/templates/c++/tbox.console/project/src/xmake.lua index 73adf9675..63056c764 100644 --- a/xmake/templates/c++/tbox.console/project/src/xmake.lua +++ b/xmake/templates/c++/tbox.console/project/src/xmake.lua @@ -1,11 +1,11 @@ -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") -- add defines - add_defines("__tb_prefix__=\"[targetname]\"") + add_defines("__tb_prefix__=\"${TARGETNAME}\"") -- add packages add_packages("tbox") diff --git a/xmake/templates/c++/tbox.console/project/xmake.lua b/xmake/templates/c++/tbox.console/project/xmake.lua index 83a45434f..292b676c1 100644 --- a/xmake/templates/c++/tbox.console/project/xmake.lua +++ b/xmake/templates/c++/tbox.console/project/xmake.lua @@ -67,3 +67,5 @@ add_requires("tbox", {debug = is_mode("debug")}) -- include project sources includes("src") + +${FAQ} diff --git a/xmake/templates/c++/tbox.console/template.lua b/xmake/templates/c++/tbox.console/template.lua index f1edee39b..850b65ee0 100644 --- a/xmake/templates/c++/tbox.console/template.lua +++ b/xmake/templates/c++/tbox.console/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("tbox.console") - --- set description -set_description("The Console Program (tbox)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("src/xmake.lua") +template("tbox.console") + add_configfiles("src/xmake.lua") diff --git a/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp b/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp index 818ff6919..99a42f2a5 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp +++ b/xmake/templates/c++/tbox.shared/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.shared/project/src/_demo/xmake.lua b/xmake/templates/c++/tbox.shared/project/src/_demo/xmake.lua index c6f24eed7..b17bd70b4 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_demo/xmake.lua +++ b/xmake/templates/c++/tbox.shared/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.shared/project/src/_library/xmake.lua b/xmake/templates/c++/tbox.shared/project/src/_library/xmake.lua index 4f564356b..46559ec9d 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_library/xmake.lua +++ b/xmake/templates/c++/tbox.shared/project/src/_library/xmake.lua @@ -1,14 +1,14 @@ -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("shared") -- 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.shared/project/xmake.lua b/xmake/templates/c++/tbox.shared/project/xmake.lua index 1ebaa6e34..02a9271a3 100644 --- a/xmake/templates/c++/tbox.shared/project/xmake.lua +++ b/xmake/templates/c++/tbox.shared/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.shared/template.lua b/xmake/templates/c++/tbox.shared/template.lua index 31bd81e93..14fa4dbda 100644 --- a/xmake/templates/c++/tbox.shared/template.lua +++ b/xmake/templates/c++/tbox.shared/template.lua @@ -1,25 +1,9 @@ --- set name -set_name("tbox.shared") - --- set description -set_description("The Shared 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.shared") + 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, opt) + os.mv("src/_library", path.join("src", opt.targetname)) + os.mv("src/_demo", path.join("src", opt.targetname .. "_demo")) + end) 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..acc4e21bd 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, opt) + os.mv("src/_library", path.join("src", opt.targetname)) + os.mv("src/_demo", path.join("src", opt.targetname .. "_demo")) + end) diff --git a/xmake/templates/c/console/project/xmake.lua b/xmake/templates/c/console/project/xmake.lua index d0bffccc8..dedb01e53 100644 --- a/xmake/templates/c/console/project/xmake.lua +++ b/xmake/templates/c/console/project/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -11,3 +11,4 @@ target("[targetname]") -- add files add_files("src/*.c") +${FAQ} diff --git a/xmake/templates/c/console/template.lua b/xmake/templates/c/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/c/console/template.lua +++ b/xmake/templates/c/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c/shared/project/xmake.lua b/xmake/templates/c/shared/project/xmake.lua index 4a52ee6d0..4aaddabc9 100644 --- a/xmake/templates/c/shared/project/xmake.lua +++ b/xmake/templates/c/shared/project/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("shared") @@ -12,15 +12,15 @@ target("[targetname]") add_files("src/interface.c") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") -- add deps - add_deps("[targetname]") + add_deps("${TARGETNAME}") -- add files add_files("src/test.c") - +${FAQ} diff --git a/xmake/templates/c/shared/template.lua b/xmake/templates/c/shared/template.lua index 666542844..d7ec5bae4 100644 --- a/xmake/templates/c/shared/template.lua +++ b/xmake/templates/c/shared/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("shared") - --- set description -set_description("The Shared Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("shared") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c/static/project/xmake.lua b/xmake/templates/c/static/project/xmake.lua index 04d422083..a01a4407d 100644 --- a/xmake/templates/c/static/project/xmake.lua +++ b/xmake/templates/c/static/project/xmake.lua @@ -1,9 +1,8 @@ - -- add modes: debug and release add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("static") @@ -12,15 +11,15 @@ target("[targetname]") add_files("src/interface.c") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") -- add deps - add_deps("[targetname]") + add_deps("${TARGETNAME}") -- add files add_files("src/test.c") - +${FAQ} diff --git a/xmake/templates/c/static/template.lua b/xmake/templates/c/static/template.lua index f05045e07..abfe91a4b 100644 --- a/xmake/templates/c/static/template.lua +++ b/xmake/templates/c/static/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("static") - --- set description -set_description("The Static Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/c/tbox.console/project/src/xmake.lua b/xmake/templates/c/tbox.console/project/src/xmake.lua index 3f528a7ec..16287c25b 100644 --- a/xmake/templates/c/tbox.console/project/src/xmake.lua +++ b/xmake/templates/c/tbox.console/project/src/xmake.lua @@ -1,11 +1,11 @@ -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") -- add defines - add_defines("__tb_prefix__=\"[targetname]\"") + add_defines("__tb_prefix__=\"${TARGETNAME}\"") -- add packages add_packages("tbox") diff --git a/xmake/templates/c/tbox.console/template.lua b/xmake/templates/c/tbox.console/template.lua index f1edee39b..850b65ee0 100644 --- a/xmake/templates/c/tbox.console/template.lua +++ b/xmake/templates/c/tbox.console/template.lua @@ -1,15 +1,3 @@ --- set name -set_name("tbox.console") - --- set description -set_description("The Console Program (tbox)") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("src/xmake.lua") +template("tbox.console") + add_configfiles("src/xmake.lua") diff --git a/xmake/templates/c/tbox.shared/project/src/_demo/main.c b/xmake/templates/c/tbox.shared/project/src/_demo/main.c index 818ff6919..99a42f2a5 100644 --- a/xmake/templates/c/tbox.shared/project/src/_demo/main.c +++ b/xmake/templates/c/tbox.shared/project/src/_demo/main.c @@ -1,7 +1,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ -#include "[targetname]/interface.h" +#include "${TARGETNAME}/interface.h" /* ////////////////////////////////////////////////////////////////////////////////////// * main diff --git a/xmake/templates/c/tbox.shared/project/src/_demo/xmake.lua b/xmake/templates/c/tbox.shared/project/src/_demo/xmake.lua index c62ddcec5..145096668 100644 --- a/xmake/templates/c/tbox.shared/project/src/_demo/xmake.lua +++ b/xmake/templates/c/tbox.shared/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.shared/project/src/_library/xmake.lua b/xmake/templates/c/tbox.shared/project/src/_library/xmake.lua index cb36ba3b8..1941864d0 100644 --- a/xmake/templates/c/tbox.shared/project/src/_library/xmake.lua +++ b/xmake/templates/c/tbox.shared/project/src/_library/xmake.lua @@ -1,14 +1,14 @@ -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("shared") -- 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.shared/project/xmake.lua b/xmake/templates/c/tbox.shared/project/xmake.lua index 1ebaa6e34..02a9271a3 100644 --- a/xmake/templates/c/tbox.shared/project/xmake.lua +++ b/xmake/templates/c/tbox.shared/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.shared/template.lua b/xmake/templates/c/tbox.shared/template.lua index c64f17262..cf21d02a7 100644 --- a/xmake/templates/c/tbox.shared/template.lua +++ b/xmake/templates/c/tbox.shared/template.lua @@ -1,25 +1,9 @@ --- set name -set_name("tbox.shared") - --- set description -set_description("The Shared 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.c") -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.shared") + add_configfiles("xmake.lua") + add_configfiles("src/_demo/main.c") + add_configfiles("src/_demo/xmake.lua") + add_configfiles("src/_library/xmake.lua") + after_create(function (template, opt) + os.mv("src/_library", path.join("src", opt.targetname)) + os.mv("src/_demo", path.join("src", opt.targetname .. "_demo")) + end) diff --git a/xmake/templates/c/tbox.static/project/src/_demo/main.c b/xmake/templates/c/tbox.static/project/src/_demo/main.c index 818ff6919..99a42f2a5 100644 --- a/xmake/templates/c/tbox.static/project/src/_demo/main.c +++ b/xmake/templates/c/tbox.static/project/src/_demo/main.c @@ -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 c62ddcec5..145096668 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 45967cabc..bfc40162e 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 9ddc683f7..21c09ec3c 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.c") -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.c") + add_configfiles("src/_demo/xmake.lua") + add_configfiles("src/_library/xmake.lua") + after_create(function (template, opt) + os.mv("src/_library", path.join("src", opt.targetname)) + os.mv("src/_demo", path.join("src", opt.targetname .. "_demo")) + end) diff --git a/xmake/templates/cuda/console/project/xmake.lua b/xmake/templates/cuda/console/project/xmake.lua index deee20adf..6521e605c 100644 --- a/xmake/templates/cuda/console/project/xmake.lua +++ b/xmake/templates/cuda/console/project/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- define target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -28,3 +28,5 @@ target("[targetname]") -- -- generate PTX code from the highest SM architecture to guarantee forward-compatibility -- add_cugencodes("compute_75") + +${FAQ} diff --git a/xmake/templates/cuda/console/template.lua b/xmake/templates/cuda/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/cuda/console/template.lua +++ b/xmake/templates/cuda/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/cuda/shared/project/xmake.lua b/xmake/templates/cuda/shared/project/xmake.lua index ceef4438d..8f854764f 100644 --- a/xmake/templates/cuda/shared/project/xmake.lua +++ b/xmake/templates/cuda/shared/project/xmake.lua @@ -3,14 +3,11 @@ add_rules("mode.debug", "mode.release") -- define target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("shared") - -- add modes: debug and release - add_rules("mode.debug", "mode.release") - -- add include dirs add_includedirs("inc") @@ -34,3 +31,5 @@ target("[targetname]") -- -- generate PTX code from the highest SM architecture to guarantee forward-compatibility -- add_cugencodes("compute_75") + +${FAQ} diff --git a/xmake/templates/cuda/shared/template.lua b/xmake/templates/cuda/shared/template.lua index 6df920968..d7ec5bae4 100644 --- a/xmake/templates/cuda/shared/template.lua +++ b/xmake/templates/cuda/shared/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("shared") - --- set description -set_description("The Shared Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua")
\ No newline at end of file +template("shared") + add_configfiles("xmake.lua") diff --git a/xmake/templates/cuda/static/project/xmake.lua b/xmake/templates/cuda/static/project/xmake.lua index 3896fb238..5e22ba152 100644 --- a/xmake/templates/cuda/static/project/xmake.lua +++ b/xmake/templates/cuda/static/project/xmake.lua @@ -3,14 +3,11 @@ add_rules("mode.debug", "mode.release") -- define target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("static") - -- add modes: debug and release - add_rules("mode.debug", "mode.release") - -- add include dirs add_includedirs("inc") @@ -34,3 +31,5 @@ target("[targetname]") -- -- generate PTX code from the highest SM architecture to guarantee forward-compatibility -- add_cugencodes("compute_75") + +${FAQ} diff --git a/xmake/templates/cuda/static/template.lua b/xmake/templates/cuda/static/template.lua index ff9c56179..abfe91a4b 100644 --- a/xmake/templates/cuda/static/template.lua +++ b/xmake/templates/cuda/static/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("static") - --- set description -set_description("The Static Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua")
\ No newline at end of file +template("static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/dlang/console/project/xmake.lua b/xmake/templates/dlang/console/project/xmake.lua index de662d1b4..9f27dbf7f 100644 --- a/xmake/templates/dlang/console/project/xmake.lua +++ b/xmake/templates/dlang/console/project/xmake.lua @@ -1,9 +1,8 @@ - -- add modes: debug and release add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -11,3 +10,4 @@ target("[targetname]") -- add files add_files("src/*.d") +${FAQ} diff --git a/xmake/templates/dlang/console/template.lua b/xmake/templates/dlang/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/dlang/console/template.lua +++ b/xmake/templates/dlang/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/dlang/shared/project/xmake.lua b/xmake/templates/dlang/shared/project/xmake.lua index 962994618..7fe11f488 100644 --- a/xmake/templates/dlang/shared/project/xmake.lua +++ b/xmake/templates/dlang/shared/project/xmake.lua @@ -1,28 +1,8 @@ --- the debug mode -if is_mode("debug") then - - -- enable the debug symbols - set_symbols("debug") - - -- disable optimization - set_optimize("none") -end - --- the release mode -if is_mode("release") then - - -- set the symbols visibility: hidden - set_symbols("hidden") - - -- enable fastest optimization - set_optimize("fastest") - - -- strip all symbols - set_strip("all") -end +-- add modes: debug and release +add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("shared") @@ -31,23 +11,15 @@ target("[targetname]") add_files("src/interfaces.d") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") -- add deps - add_deps("test") + add_deps("${TARGETNAME}") -- add files add_files("src/main.d") - -- add links - add_links("[targetname]") - - -- add link directory - add_linkdirs("$(buildir)") - - -- add include directory - add_includedirs("$(projectdir)/src") - +${FAQ} diff --git a/xmake/templates/dlang/shared/template.lua b/xmake/templates/dlang/shared/template.lua index 666542844..d7ec5bae4 100644 --- a/xmake/templates/dlang/shared/template.lua +++ b/xmake/templates/dlang/shared/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("shared") - --- set description -set_description("The Shared Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("shared") + add_configfiles("xmake.lua") diff --git a/xmake/templates/dlang/static/project/xmake.lua b/xmake/templates/dlang/static/project/xmake.lua index 8cc9d7d9d..6a3d805ad 100644 --- a/xmake/templates/dlang/static/project/xmake.lua +++ b/xmake/templates/dlang/static/project/xmake.lua @@ -1,28 +1,8 @@ --- the debug mode -if is_mode("debug") then - - -- enable the debug symbols - set_symbols("debug") - - -- disable optimization - set_optimize("none") -end - --- the release mode -if is_mode("release") then - - -- set the symbols visibility: hidden - set_symbols("hidden") - - -- enable fastest optimization - set_optimize("fastest") - - -- strip all symbols - set_strip("all") -end +-- add modes: debug and release +add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("static") @@ -31,23 +11,15 @@ target("[targetname]") add_files("src/interfaces.d") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") -- add deps - add_deps("[targetname]") + add_deps("${TARGETNAME}") -- add files add_files("src/main.d") - -- add links - add_links("[targetname]") - - -- add link directory - add_linkdirs("$(buildir)") - - -- add include directory - add_includedirs("$(projectdir)/src") - +${FAQ} diff --git a/xmake/templates/dlang/static/template.lua b/xmake/templates/dlang/static/template.lua index f05045e07..abfe91a4b 100644 --- a/xmake/templates/dlang/static/template.lua +++ b/xmake/templates/dlang/static/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("static") - --- set description -set_description("The Static Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/go/console/project/xmake.lua b/xmake/templates/go/console/project/xmake.lua index 090935ed2..35f458b68 100644 --- a/xmake/templates/go/console/project/xmake.lua +++ b/xmake/templates/go/console/project/xmake.lua @@ -1,9 +1,8 @@ - -- add modes: debug and release add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -11,3 +10,4 @@ target("[targetname]") -- add files add_files("src/*.go") +${FAQ} diff --git a/xmake/templates/go/console/template.lua b/xmake/templates/go/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/go/console/template.lua +++ b/xmake/templates/go/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/go/static/project/xmake.lua b/xmake/templates/go/static/project/xmake.lua index ddf3b14c5..3c0f05209 100644 --- a/xmake/templates/go/static/project/xmake.lua +++ b/xmake/templates/go/static/project/xmake.lua @@ -1,26 +1,3 @@ --- the debug mode -if is_mode("debug") then - - -- enable the debug symbols - set_symbols("debug") - - -- disable optimization - set_optimize("none") -end - --- the release mode -if is_mode("release") then - - -- set the symbols visibility: hidden - set_symbols("hidden") - - -- enable fastest optimization - set_optimize("fastest") - - -- strip all symbols - set_strip("all") -end - -- add target target("module") @@ -31,7 +8,7 @@ target("module") add_files("src/test/*.go") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") @@ -48,3 +25,4 @@ target("[targetname]_demo") -- add include directory add_includedirs("$(buildir)") +${FAQ} diff --git a/xmake/templates/go/static/template.lua b/xmake/templates/go/static/template.lua index f05045e07..abfe91a4b 100644 --- a/xmake/templates/go/static/template.lua +++ b/xmake/templates/go/static/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("static") - --- set description -set_description("The Static Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/objc++/console/project/xmake.lua b/xmake/templates/objc++/console/project/xmake.lua index 68cba346c..736de146c 100644 --- a/xmake/templates/objc++/console/project/xmake.lua +++ b/xmake/templates/objc++/console/project/xmake.lua @@ -1,38 +1,8 @@ --- the debug mode -if is_mode("debug") then - - -- enable the debug symbols - set_symbols("debug") - - -- disable optimization - set_optimize("none") -end - --- the release mode -if is_mode("release") then - - -- set the symbols visibility: hidden - set_symbols("hidden") - - -- enable fastest optimization - set_optimize("fastest") - - -- strip all symbols - set_strip("all") -end - --- add frameworks -add_frameworks("Foundation", "CoreFoundation") - --- for macosx or ios -if is_os("macosx", "ios") then - - -- enable arc? - add_mxflags("-fobjc-arc") -end +-- add modes: debug and release +add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -40,3 +10,12 @@ target("[targetname]") -- add files add_files("src/*.mm") + -- for macosx or ios + if is_os("macosx", "ios") then + add_mxflags("-fobjc-arc") + end + + -- add frameworks + add_frameworks("Foundation", "CoreFoundation") + +${FAQ} diff --git a/xmake/templates/objc++/console/template.lua b/xmake/templates/objc++/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/objc++/console/template.lua +++ b/xmake/templates/objc++/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/objc/console/project/xmake.lua b/xmake/templates/objc/console/project/xmake.lua index 0477ea739..199d79528 100644 --- a/xmake/templates/objc/console/project/xmake.lua +++ b/xmake/templates/objc/console/project/xmake.lua @@ -1,19 +1,8 @@ - -- add modes: debug and release add_rules("mode.debug", "mode.release") --- add frameworks -add_frameworks("Foundation", "CoreFoundation") - --- for macosx or ios -if is_os("macosx", "ios") then - - -- enable arc? - add_mxflags("-fobjc-arc") -end - -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -21,3 +10,12 @@ target("[targetname]") -- add files add_files("src/*.m") + -- add frameworks + add_frameworks("Foundation", "CoreFoundation") + + -- for macosx or ios + if is_os("macosx", "ios") then + add_mxflags("-fobjc-arc") + end + +${FAQ} diff --git a/xmake/templates/objc/console/template.lua b/xmake/templates/objc/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/objc/console/template.lua +++ b/xmake/templates/objc/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/rust/console/project/xmake.lua b/xmake/templates/rust/console/project/xmake.lua index e67de58ab..15fafa7f2 100644 --- a/xmake/templates/rust/console/project/xmake.lua +++ b/xmake/templates/rust/console/project/xmake.lua @@ -1,9 +1,8 @@ - -- add modes: debug and release add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -11,3 +10,4 @@ target("[targetname]") -- add files add_files("src/*.rs") +${FAQ} diff --git a/xmake/templates/rust/console/template.lua b/xmake/templates/rust/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/rust/console/template.lua +++ b/xmake/templates/rust/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/rust/static/project/xmake.lua b/xmake/templates/rust/static/project/xmake.lua index c3a5b497a..fcaaa55f7 100644 --- a/xmake/templates/rust/static/project/xmake.lua +++ b/xmake/templates/rust/static/project/xmake.lua @@ -1,26 +1,3 @@ --- the debug mode -if is_mode("debug") then - - -- enable the debug symbols - set_symbols("debug") - - -- disable optimization - set_optimize("none") -end - --- the release mode -if is_mode("release") then - - -- set the symbols visibility: hidden - set_symbols("hidden") - - -- enable fastest optimization - set_optimize("fastest") - - -- strip all symbols - set_strip("all") -end - -- add target target("interfaces") @@ -31,7 +8,7 @@ target("interfaces") add_files("src/interfaces.rs") -- add target -target("[targetname]_demo") +target("${TARGETNAME}_demo") -- set kind set_kind("binary") @@ -45,4 +22,4 @@ target("[targetname]_demo") -- add link directory add_linkdirs("$(buildir)") - +${FAQ} diff --git a/xmake/templates/rust/static/template.lua b/xmake/templates/rust/static/template.lua index f05045e07..abfe91a4b 100644 --- a/xmake/templates/rust/static/template.lua +++ b/xmake/templates/rust/static/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("static") - --- set description -set_description("The Static Library") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/swift/console/project/xmake.lua b/xmake/templates/swift/console/project/xmake.lua index b9e0d0f9a..4b8c614fa 100644 --- a/xmake/templates/swift/console/project/xmake.lua +++ b/xmake/templates/swift/console/project/xmake.lua @@ -1,9 +1,8 @@ - -- add modes: debug and release add_rules("mode.debug", "mode.release") -- add target -target("[targetname]") +target("${TARGETNAME}") -- set kind set_kind("binary") @@ -11,3 +10,4 @@ target("[targetname]") -- add files add_files("src/*.swift") +${FAQ} diff --git a/xmake/templates/swift/console/template.lua b/xmake/templates/swift/console/template.lua index 52c362723..ed2e13b57 100644 --- a/xmake/templates/swift/console/template.lua +++ b/xmake/templates/swift/console/template.lua @@ -1,14 +1,2 @@ --- set name -set_name("console") - --- set description -set_description("The Console Program") - --- set project directory -set_projectdir("project") - --- add macros -add_macros("targetname", "$(targetname)") - --- add macro files -add_macrofiles("xmake.lua") +template("console") + add_configfiles("xmake.lua") |
