diff options
| author | ruki <[email protected]> | 2015-06-20 19:53:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-20 19:53:54 +0800 |
| commit | cd3922c36588023c8e0ffaeccb2fc2c95b05dd20 (patch) | |
| tree | a4597c30d982140a85d14c9cc4359f5555780834 | |
| parent | 12e518a819bb848c67452655abdfcce5c0d90bd2 (diff) | |
move some template implementation
| -rw-r--r-- | xmake/scripts/action/_create.lua | 27 | ||||
| -rw-r--r-- | xmake/templates/c/console/_template.lua | 21 |
2 files changed, 24 insertions, 24 deletions
diff --git a/xmake/scripts/action/_create.lua b/xmake/scripts/action/_create.lua index 47d0d2761..a49dd4915 100644 --- a/xmake/scripts/action/_create.lua +++ b/xmake/scripts/action/_create.lua @@ -45,7 +45,7 @@ function _create.done() local targetname = options.target or path.basename(xmake._PROJECT_DIR) or "demo" -- trace - utils.printf("create project %s ...", targetname) + utils.printf("create %s ...", targetname) -- the language local language = options.language @@ -79,14 +79,33 @@ function _create.done() return false end - -- done the template and create this project + -- check the template project + if not os.isdir("project") then + -- errors + utils.error("the template project not exists!") + return false + end + + -- ensure the project directory + if not os.isdir(xmake._PROJECT_DIR) then + os.mkdir(xmake._PROJECT_DIR) + end + + -- copy the project files + if not os.cp("project/*", xmake._PROJECT_DIR) then + -- errors + utils.error("copy files failed!") + return false + end + + -- done the template files if not module.done(targetname, xmake._PROJECT_DIR) then - utils.error("create project %s failed!", targetname) + utils.error("update the template failed!") return false end -- trace - utils.printf("create project %s ok!", targetname) + utils.printf("create %s ok!", targetname) -- ok return true diff --git a/xmake/templates/c/console/_template.lua b/xmake/templates/c/console/_template.lua index a24baffee..e1475e286 100644 --- a/xmake/templates/c/console/_template.lua +++ b/xmake/templates/c/console/_template.lua @@ -31,31 +31,12 @@ local utils = require("base/utils") -- init the template description _template.description = "The Console Program" --- create project using this template +-- done the template file function _template.done(targetname, projectdir) -- check assert(targetname and projectdir) - -- check the template project - if not os.isdir("project") then - -- errors - utils.error("the template project not exists!") - return false - end - - -- ensure the project directory - if not os.isdir(projectdir) then - os.mkdir(projectdir) - end - - -- copy the project files - if not os.cp("project/*", projectdir) then - -- errors - utils.error("install project failed!") - return false - end - -- ok return true end |
