diff options
| author | ruki <[email protected]> | 2016-03-22 20:24:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-03-22 20:24:31 +0800 |
| commit | aca0257d26134ff95889acb419d49701fee4ec61 (patch) | |
| tree | c1a2f332156aba8295b0522fa70f08783e9633c6 /xmake/core | |
| parent | c1460e5be7f4b4e3356a8bda99703828c356cbfb (diff) | |
impl lua action
Diffstat (limited to 'xmake/core')
| -rw-r--r-- | xmake/core/platform/platform.lua | 73 | ||||
| -rw-r--r-- | xmake/core/project/config.lua | 6 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/platform/platform.lua (renamed from xmake/core/platform/tools/echo.lua) | 32 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/config.lua | 5 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/print.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/utils.lua | 10 |
6 files changed, 52 insertions, 76 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index c0e974460..f552ea3ef 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -27,7 +27,6 @@ local platform = platform or {} local os = require("base/os") local path = require("base/path") local utils = require("base/utils") -local option = require("base/option") local config = require("project/config") local global = require("project/global") @@ -123,8 +122,29 @@ function platform._load(plat) return module end --- get the configure of the given platform -function platform._configs(plat) +-- get the current platform module +function platform.module() + + -- get the platform + local plat = config.get("plat") + if plat then + -- load it + return platform._load(plat) + end +end + +-- get the current platform module directory +function platform.directory() + + -- load it + local module = platform.module() + if module then + return module._DIRECTORY + end +end + +-- load the configure of the given platform +function platform.load(plat) -- check assert(plat) @@ -154,38 +174,6 @@ function platform._configs(plat) return configs end --- get the current platform module -function platform.module() - - -- get the platform - local plat = config.get("plat") - if plat then - -- load it - return platform._load(plat) - end -end - --- get the current platform module directory -function platform.directory() - - -- load it - local module = platform.module() - if module then - return module._DIRECTORY - end -end - --- make the current platform configure -function platform.make() - - -- get the platform - local plat = config.get("plat") - assert(plat) - - -- make and get the current platform configure - return platform._configs(plat) -end - -- get the platform os function platform.os() @@ -204,7 +192,7 @@ function platform.get(name) assert(platform._CONFIGS) -- get the current platform configure - local configs = platform._configs(config.get("plat")) + local configs = platform.load(config.get("plat")) if configs then -- get it return configs[name] @@ -239,19 +227,6 @@ function platform.format(kind) end --- dump the platform configure -function platform.dump() - - -- check - assert(platform._CONFIGS) - - -- dump - if option.get("verbose") then - table.dump(platform._configs(config.get("plat"))) - end - -end - -- list all platforms function platform.plats() diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 1942ca5e6..58c04b256 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -151,10 +151,8 @@ end -- load the project configure function config.load(targetname) - -- check - if not targetname then - return false, "no target name!" - end + -- get the target name + targetname = targetname or "all" -- load configure from the file first local filepath = config._file() diff --git a/xmake/core/platform/tools/echo.lua b/xmake/core/sandbox/modules/import/core/platform/platform.lua index 9a858c765..f16ee8df2 100644 --- a/xmake/core/platform/tools/echo.lua +++ b/xmake/core/sandbox/modules/import/core/platform/platform.lua @@ -17,28 +17,28 @@ -- Copyright (C) 2015 - 2016, ruki All rights reserved. -- -- @author ruki --- @file echo.lua +-- @file platform.lua -- --- define module: echo -local echo = echo or {} +-- define module +local sandbox_core_platform_platform = sandbox_core_platform_platform or {} -- load modules -local io = require("base/io") -local string = require("base/string") +local platform = require("platform/platform") +local raise = require("sandbox/modules/raise") --- the main function -function echo.main(self, ...) +-- load the current platform +function sandbox_core_platform_platform.load(plat) - -- echo all - for _, v in ipairs(...) do - io.write(string.format("%s ", v:decode())) - end - io.write("\n") + -- check + assert(plat) - -- ok - return true + -- load the platform configure + if not platform.load(plat) then + raise("load platform: %s failed!", plat) + end end --- return module: echo -return echo + +-- return module +return sandbox_core_platform_platform diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua index 9eb77847c..2d2820f4a 100644 --- a/xmake/core/sandbox/modules/import/core/project/config.lua +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -126,11 +126,6 @@ function sandbox_core_project_config.probe() raise("probe the project configure failed!") end - -- make the platform configure - if not platform.make() then - raise("make platform configure: %s failed!", config.get("plat")) - end - end -- dump the configure diff --git a/xmake/core/sandbox/modules/print.lua b/xmake/core/sandbox/modules/print.lua index 9e8502c16..7ed930575 100644 --- a/xmake/core/sandbox/modules/print.lua +++ b/xmake/core/sandbox/modules/print.lua @@ -21,5 +21,5 @@ -- -- load module -return print +return require("sandbox/modules/utils").print diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua index f0cb95db9..395642268 100644 --- a/xmake/core/sandbox/modules/utils.lua +++ b/xmake/core/sandbox/modules/utils.lua @@ -21,6 +21,7 @@ -- -- load modules +local io = require("base/io") local utils = require("base/utils") local vformat = require("sandbox/modules/vformat") @@ -34,11 +35,18 @@ for k, v in pairs(utils) do end end +-- print with the builtin variables and newline +function sandbox_utils.print(format, ...) + + -- done + return io.write(vformat(format, ...) .. "\n") +end + -- printf with the builtin variables function sandbox_utils.printf(format, ...) -- done - return print(vformat(format, ...)) + return io.write(vformat(format, ...)) end -- return module |
