diff options
| author | ruki <[email protected]> | 2016-02-17 21:04:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-02-17 21:04:40 +0800 |
| commit | e1e38b8b2cf04bfd41ded133aac6604bdde06293 (patch) | |
| tree | cff3279c4a8a5b94107ea7a3e571b95d97fa3465 | |
| parent | d316be4334127336822e8daeb8a45d2ffe0bdde7 (diff) | |
remove vformat for templates
| -rw-r--r-- | xmake/core/base/sandbox.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/assert.lua (renamed from xmake/core/sandbox/builtin/assert.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/builtin/vprintf.lua | 25 | ||||
| -rw-r--r-- | xmake/core/sandbox/format.lua (renamed from xmake/core/sandbox/builtin/format.lua) | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/import.lua (renamed from xmake/core/sandbox/builtin/import.lua) | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/import/project.lua (renamed from xmake/core/sandbox/project.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/ipairs.lua (renamed from xmake/core/sandbox/builtin/ipairs.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/os.lua (renamed from xmake/core/sandbox/builtin/os.lua) | 75 | ||||
| -rw-r--r-- | xmake/core/sandbox/pairs.lua (renamed from xmake/core/sandbox/builtin/pairs.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/path.lua (renamed from xmake/core/sandbox/builtin/path.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/print.lua (renamed from xmake/core/sandbox/builtin/print.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/printf.lua (renamed from xmake/core/sandbox/builtin/printf.lua) | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/string.lua (renamed from xmake/core/sandbox/builtin/string.lua) | 14 | ||||
| -rw-r--r-- | xmake/core/sandbox/table.lua (renamed from xmake/core/sandbox/builtin/table.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/utils.lua (renamed from xmake/core/sandbox/builtin/utils.lua) | 16 | ||||
| -rw-r--r-- | xmake/core/sandbox/vformat.lua (renamed from xmake/core/sandbox/builtin/vformat.lua) | 2 | ||||
| -rw-r--r-- | xmake/templates/c++/console_tbox/template.lua | 4 | ||||
| -rw-r--r-- | xmake/templates/c++/shared_library_tbox/template.lua | 8 | ||||
| -rw-r--r-- | xmake/templates/c++/static_library_tbox/template.lua | 8 | ||||
| -rw-r--r-- | xmake/templates/c/console_tbox/template.lua | 4 | ||||
| -rw-r--r-- | xmake/templates/c/shared_library_tbox/template.lua | 8 | ||||
| -rw-r--r-- | xmake/templates/c/static_library_tbox/template.lua | 8 |
22 files changed, 106 insertions, 74 deletions
diff --git a/xmake/core/base/sandbox.lua b/xmake/core/base/sandbox.lua index 570a22fa4..495be81fd 100644 --- a/xmake/core/base/sandbox.lua +++ b/xmake/core/base/sandbox.lua @@ -96,7 +96,7 @@ function sandbox._init() end -- load builtin module files - local builtin_module_files = os.match(path.join(xmake._CORE_DIR, "sandbox/builtin/*.lua")) + local builtin_module_files = os.match(path.join(xmake._CORE_DIR, "sandbox/*.lua")) if builtin_module_files then for _, builtin_module_file in ipairs(builtin_module_files) do diff --git a/xmake/core/sandbox/builtin/assert.lua b/xmake/core/sandbox/assert.lua index 480271b4f..480271b4f 100644 --- a/xmake/core/sandbox/builtin/assert.lua +++ b/xmake/core/sandbox/assert.lua diff --git a/xmake/core/sandbox/builtin/vprintf.lua b/xmake/core/sandbox/builtin/vprintf.lua deleted file mode 100644 index f0381aff4..000000000 --- a/xmake/core/sandbox/builtin/vprintf.lua +++ /dev/null @@ -1,25 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file vprintf.lua --- - --- load module -return require("sandbox/builtin/utils").vprintf - diff --git a/xmake/core/sandbox/builtin/format.lua b/xmake/core/sandbox/format.lua index 13417e546..deb7280ac 100644 --- a/xmake/core/sandbox/builtin/format.lua +++ b/xmake/core/sandbox/format.lua @@ -21,6 +21,6 @@ -- -- return module -return require("sandbox/builtin/string").format +return require("sandbox/string").format diff --git a/xmake/core/sandbox/builtin/import.lua b/xmake/core/sandbox/import.lua index ccbef0052..e2011c55b 100644 --- a/xmake/core/sandbox/builtin/import.lua +++ b/xmake/core/sandbox/import.lua @@ -27,7 +27,7 @@ local utils = require("base/utils") function sandbox_builtin_import(name) -- load module - local module = require("sandbox/" .. name) + local module = require("sandbox/import" .. name) if not module then utils.error("cannot import module: %s", name) utils.abort() diff --git a/xmake/core/sandbox/project.lua b/xmake/core/sandbox/import/project.lua index f3f726c6f..f3f726c6f 100644 --- a/xmake/core/sandbox/project.lua +++ b/xmake/core/sandbox/import/project.lua diff --git a/xmake/core/sandbox/builtin/ipairs.lua b/xmake/core/sandbox/ipairs.lua index b3551f862..b3551f862 100644 --- a/xmake/core/sandbox/builtin/ipairs.lua +++ b/xmake/core/sandbox/ipairs.lua diff --git a/xmake/core/sandbox/builtin/os.lua b/xmake/core/sandbox/os.lua index cd1380f03..c83593cd4 100644 --- a/xmake/core/sandbox/builtin/os.lua +++ b/xmake/core/sandbox/os.lua @@ -21,19 +21,27 @@ -- -- load modules -local io = require("base/io") -local os = require("base/os") -local utils = require("base/utils") +local io = require("base/io") +local os = require("base/os") +local utils = require("base/utils") +local vformat = require("sandbox/vformat") -- define module local sandbox_builtin_os = sandbox_builtin_os or {} +-- inherit the public interfaces of os +sandbox_builtin_os.curdir = os.curdir + -- copy file or directory function sandbox_builtin_os.cp(src, dst) -- check assert(src and dst) + -- format it first + src = vformat(src) + dst = vformat(dst) + -- done local ok, errors = os.cp(src, dst) if not ok then @@ -49,6 +57,10 @@ function sandbox_builtin_os.mv(src, dst) -- check assert(src and dst) + -- format it first + src = vformat(src) + dst = vformat(dst) + -- done local ok, errors = os.mv(src, dst) if not ok then @@ -64,6 +76,9 @@ function sandbox_builtin_os.rm(file_or_dir, emptydir) -- check assert(file_or_dir) + -- format it first + file_or_dir = vformat(file_or_dir) + -- done local ok, errors = os.rm(file_or_dir, emptydir) if not ok then @@ -79,6 +94,9 @@ function sandbox_builtin_os.cd(dir) -- check assert(dir) + -- format it first + dir = vformat(dir) + -- done local ok, errors = os.cd(dir) if not ok then @@ -94,6 +112,9 @@ function sandbox_builtin_os.mkdir(dir) -- check assert(dir) + -- format it first + dir = vformat(dir) + -- done if not os.mkdir(dir) then utils.error("create directory: %s failed!", dir) @@ -108,6 +129,9 @@ function sandbox_builtin_os.rmdir(dir) -- check assert(dir) + -- format it first + dir = vformat(dir) + -- done if os.isdir(dir) then if not os.rmdir(dir) then @@ -122,7 +146,7 @@ end function sandbox_builtin_os.run(cmd, ...) -- make command - cmd = string.format(cmd, ...) + cmd = vformat(cmd, ...) -- make temporary log file log = os.tmpname() @@ -138,11 +162,44 @@ function sandbox_builtin_os.run(cmd, ...) os.rm(log) end --- register some public interfaces -sandbox_builtin_os.match = os.match -sandbox_builtin_os.isdir = os.isdir -sandbox_builtin_os.isfile = os.isfile -sandbox_builtin_os.curdir = os.curdir +-- match files or directories +function sandbox_builtin_os.match(pattern, findir) + + -- check + assert(pattern) + + -- format it first + pattern = vformat(pattern) + + -- match it + return os.match(pattern, findir) +end + +-- is directory? +function sandbox_builtin_os.isdir(dirpath) + + -- check + assert(dirpath) + + -- format it first + dirpath = vformat(dirpath) + + -- done + return os.isdir(dirpath) +end + +-- is directory? +function sandbox_builtin_os.isfile(filepath) + + -- check + assert(filepath) + + -- format it first + filepath = vformat(filepath) + + -- done + return os.isfile(filepath) +end -- return module return sandbox_builtin_os diff --git a/xmake/core/sandbox/builtin/pairs.lua b/xmake/core/sandbox/pairs.lua index f4f74b7e4..f4f74b7e4 100644 --- a/xmake/core/sandbox/builtin/pairs.lua +++ b/xmake/core/sandbox/pairs.lua diff --git a/xmake/core/sandbox/builtin/path.lua b/xmake/core/sandbox/path.lua index 925ad7cf8..925ad7cf8 100644 --- a/xmake/core/sandbox/builtin/path.lua +++ b/xmake/core/sandbox/path.lua diff --git a/xmake/core/sandbox/builtin/print.lua b/xmake/core/sandbox/print.lua index b9e9b9f86..b9e9b9f86 100644 --- a/xmake/core/sandbox/builtin/print.lua +++ b/xmake/core/sandbox/print.lua diff --git a/xmake/core/sandbox/builtin/printf.lua b/xmake/core/sandbox/printf.lua index 41acbf7c6..e3d524abd 100644 --- a/xmake/core/sandbox/builtin/printf.lua +++ b/xmake/core/sandbox/printf.lua @@ -21,5 +21,5 @@ -- -- load module -return require("sandbox/builtin/utils").printf +return require("sandbox/utils").printf diff --git a/xmake/core/sandbox/builtin/string.lua b/xmake/core/sandbox/string.lua index 1947e9f0a..f87460a39 100644 --- a/xmake/core/sandbox/builtin/string.lua +++ b/xmake/core/sandbox/string.lua @@ -27,6 +27,13 @@ local sandbox = require("base/sandbox") -- define module local sandbox_builtin_string = sandbox_builtin_string or {} +-- inherit the public interfaces of string +for k, v in pairs(string) do + if not k:startswith("_") and type(v) == "function" then + sandbox_builtin_string[k] = v + end +end + -- format string with the builtin variables function sandbox_builtin_string.vformat(format, ...) @@ -51,13 +58,6 @@ function sandbox_builtin_string.vformat(format, ...) return result end --- inherit the public interfaces of string -for k, v in pairs(string) do - if not k:startswith("_") and type(v) == "function" then - sandbox_builtin_string[k] = v - end -end - -- return module return sandbox_builtin_string diff --git a/xmake/core/sandbox/builtin/table.lua b/xmake/core/sandbox/table.lua index a697504fd..a697504fd 100644 --- a/xmake/core/sandbox/builtin/table.lua +++ b/xmake/core/sandbox/table.lua diff --git a/xmake/core/sandbox/builtin/utils.lua b/xmake/core/sandbox/utils.lua index 96e8d74d9..9c80cb05d 100644 --- a/xmake/core/sandbox/builtin/utils.lua +++ b/xmake/core/sandbox/utils.lua @@ -22,18 +22,11 @@ -- load modules local utils = require("base/utils") -local string = require("sandbox/builtin/string") +local vformat = require("sandbox/vformat") -- define module local sandbox_builtin_utils = sandbox_builtin_utils or {} --- printf with the builtin variables -function sandbox_builtin_utils.vprintf(format, ...) - - -- done - return print(string.vformat(format, ...)) -end - -- inherit the public interfaces of utils for k, v in pairs(utils) do if not k:startswith("_") and type(v) == "function" then @@ -41,6 +34,13 @@ for k, v in pairs(utils) do end end +-- printf with the builtin variables +function sandbox_builtin_utils.printf(format, ...) + + -- done + return print(vformat(format, ...)) +end + -- return module return sandbox_builtin_utils diff --git a/xmake/core/sandbox/builtin/vformat.lua b/xmake/core/sandbox/vformat.lua index 462d5f54d..eb8751856 100644 --- a/xmake/core/sandbox/builtin/vformat.lua +++ b/xmake/core/sandbox/vformat.lua @@ -21,6 +21,6 @@ -- -- return module -return require("sandbox/builtin/string").vformat +return require("sandbox/string").vformat diff --git a/xmake/templates/c++/console_tbox/template.lua b/xmake/templates/c++/console_tbox/template.lua index 7bcf3001c..0b63ab745 100644 --- a/xmake/templates/c++/console_tbox/template.lua +++ b/xmake/templates/c++/console_tbox/template.lua @@ -14,7 +14,7 @@ add_macrofiles("src/xmake.lua") set_createscript(function () -- copy packages - os.cp(vformat("$(packagesdir)/tbox.pkg"), "pkg/tbox.pkg") - os.cp(vformat("$(packagesdir)/base.pkg"), "pkg/base.pkg") + os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg") + os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg") end) diff --git a/xmake/templates/c++/shared_library_tbox/template.lua b/xmake/templates/c++/shared_library_tbox/template.lua index 89d0ecedf..56cff2596 100644 --- a/xmake/templates/c++/shared_library_tbox/template.lua +++ b/xmake/templates/c++/shared_library_tbox/template.lua @@ -17,11 +17,11 @@ add_macrofiles("src/_library/xmake.lua") set_createscript(function () -- rename target directory - os.mv("src/_library", vformat("src/$(targetname)")) - os.mv("src/_demo", vformat("src/$(targetname)_demo")) + os.mv("src/_library", "src/$(targetname)") + os.mv("src/_demo", "src/$(targetname)_demo") -- copy packages - os.cp(vformat("$(packagesdir)/tbox.pkg"), "pkg/tbox.pkg") - os.cp(vformat("$(packagesdir)/base.pkg"), "pkg/base.pkg") + os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg") + os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg") end) diff --git a/xmake/templates/c++/static_library_tbox/template.lua b/xmake/templates/c++/static_library_tbox/template.lua index 6b0ae2801..97e9fc089 100644 --- a/xmake/templates/c++/static_library_tbox/template.lua +++ b/xmake/templates/c++/static_library_tbox/template.lua @@ -17,11 +17,11 @@ add_macrofiles("src/_library/xmake.lua") set_createscript(function () -- rename target directory - os.mv("src/_library", vformat("src/$(targetname)")) - os.mv("src/_demo", vformat("src/$(targetname)_demo")) + os.mv("src/_library", "src/$(targetname)") + os.mv("src/_demo", "src/$(targetname)_demo") -- copy packages - os.cp(vformat("$(packagesdir)/tbox.pkg"), "pkg/tbox.pkg") - os.cp(vformat("$(packagesdir)/base.pkg"), "pkg/base.pkg") + os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg") + os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg") end) diff --git a/xmake/templates/c/console_tbox/template.lua b/xmake/templates/c/console_tbox/template.lua index 7bcf3001c..0b63ab745 100644 --- a/xmake/templates/c/console_tbox/template.lua +++ b/xmake/templates/c/console_tbox/template.lua @@ -14,7 +14,7 @@ add_macrofiles("src/xmake.lua") set_createscript(function () -- copy packages - os.cp(vformat("$(packagesdir)/tbox.pkg"), "pkg/tbox.pkg") - os.cp(vformat("$(packagesdir)/base.pkg"), "pkg/base.pkg") + os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg") + os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg") end) diff --git a/xmake/templates/c/shared_library_tbox/template.lua b/xmake/templates/c/shared_library_tbox/template.lua index 89d0ecedf..56cff2596 100644 --- a/xmake/templates/c/shared_library_tbox/template.lua +++ b/xmake/templates/c/shared_library_tbox/template.lua @@ -17,11 +17,11 @@ add_macrofiles("src/_library/xmake.lua") set_createscript(function () -- rename target directory - os.mv("src/_library", vformat("src/$(targetname)")) - os.mv("src/_demo", vformat("src/$(targetname)_demo")) + os.mv("src/_library", "src/$(targetname)") + os.mv("src/_demo", "src/$(targetname)_demo") -- copy packages - os.cp(vformat("$(packagesdir)/tbox.pkg"), "pkg/tbox.pkg") - os.cp(vformat("$(packagesdir)/base.pkg"), "pkg/base.pkg") + os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg") + os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg") end) diff --git a/xmake/templates/c/static_library_tbox/template.lua b/xmake/templates/c/static_library_tbox/template.lua index 6b0ae2801..97e9fc089 100644 --- a/xmake/templates/c/static_library_tbox/template.lua +++ b/xmake/templates/c/static_library_tbox/template.lua @@ -17,11 +17,11 @@ add_macrofiles("src/_library/xmake.lua") set_createscript(function () -- rename target directory - os.mv("src/_library", vformat("src/$(targetname)")) - os.mv("src/_demo", vformat("src/$(targetname)_demo")) + os.mv("src/_library", "src/$(targetname)") + os.mv("src/_demo", "src/$(targetname)_demo") -- copy packages - os.cp(vformat("$(packagesdir)/tbox.pkg"), "pkg/tbox.pkg") - os.cp(vformat("$(packagesdir)/base.pkg"), "pkg/base.pkg") + os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg") + os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg") end) |
