diff options
| author | ruki <[email protected]> | 2020-06-04 22:40:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-06-04 10:03:55 +0800 |
| commit | a9078281697bac4e2b6e1ccaa144bdd5101a0e49 (patch) | |
| tree | 7c479ad0d4f5114f6f4bbd5e4cdfa479997932b3 | |
| parent | c0ae2b21a94c639237a0cacb37577dcdde0c39d6 (diff) | |
add is_host and is_subhost for interpreter
| -rw-r--r-- | xmake/core/project/project.lua | 12 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/interpreter/ifelse.lua | 9 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/interpreter/is_host.lua | 23 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/interpreter/is_subhost.lua | 23 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/utils.lua | 41 | ||||
| -rw-r--r-- | xmake/themes/dark/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/themes/default/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/themes/emoji/xmake.lua | 8 | ||||
| -rw-r--r-- | xmake/themes/ninja/xmake.lua | 2 |
9 files changed, 76 insertions, 46 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index be492e662..96d4256ef 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -95,16 +95,6 @@ function project._api_is_kind(interp, ...) end end --- the current host is belong to the given hosts? -function project._api_is_host(interp, ...) - return os.is_host(...) -end - --- the current subsystem host is belong to the given hosts? -function project._api_is_subhost(interp, ...) - return os.is_subhost(...) -end - -- the current config is belong to the given config values? function project._api_is_config(interp, name, ...) return config.is_value(name, ...) @@ -670,8 +660,6 @@ function project.apis() {"is_os", project._api_is_os } , {"is_kind", project._api_is_kind } , {"is_arch", project._api_is_arch } - , {"is_host", project._api_is_host } - , {"is_subhost", project._api_is_subhost } , {"is_mode", project._api_is_mode } , {"is_plat", project._api_is_plat } , {"is_config", project._api_is_config } diff --git a/xmake/core/sandbox/modules/interpreter/ifelse.lua b/xmake/core/sandbox/modules/interpreter/ifelse.lua index 9793264a7..e2914aa2d 100644 --- a/xmake/core/sandbox/modules/interpreter/ifelse.lua +++ b/xmake/core/sandbox/modules/interpreter/ifelse.lua @@ -18,6 +18,9 @@ -- @file ifelse.lua -- --- load module -return require("sandbox/modules/ifelse") - +return function (...) + local utils = require("base/utils") + local deprecated = require("base/deprecated") + deprecated.add("(a and b or c)", "ifelse(a, b, c)") + return utils.ifelse(...) +end diff --git a/xmake/core/sandbox/modules/interpreter/is_host.lua b/xmake/core/sandbox/modules/interpreter/is_host.lua new file mode 100644 index 000000000..172b5c3cc --- /dev/null +++ b/xmake/core/sandbox/modules/interpreter/is_host.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file is_host.lua +-- + +-- return module +return require("base/os").is_host + diff --git a/xmake/core/sandbox/modules/interpreter/is_subhost.lua b/xmake/core/sandbox/modules/interpreter/is_subhost.lua new file mode 100644 index 000000000..f29fd3d36 --- /dev/null +++ b/xmake/core/sandbox/modules/interpreter/is_subhost.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file is_subhost.lua +-- + +-- return module +return require("base/os").is_subhost + diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua index 4dac4a91e..dc330197f 100644 --- a/xmake/core/sandbox/modules/utils.lua +++ b/xmake/core/sandbox/modules/utils.lua @@ -19,25 +19,27 @@ -- -- load modules -local io = require("base/io") -local os = require("base/os") -local utils = require("base/utils") -local colors = require("base/colors") -local option = require("base/option") -local log = require("base/log") -local try = require("sandbox/modules/try") -local catch = require("sandbox/modules/catch") -local vformat = require("sandbox/modules/vformat") +local io = require("base/io") +local os = require("base/os") +local utils = require("base/utils") +local colors = require("base/colors") +local option = require("base/option") +local log = require("base/log") +local deprecated = require("base/deprecated") +local try = require("sandbox/modules/try") +local catch = require("sandbox/modules/catch") +local vformat = require("sandbox/modules/vformat") -- define module local sandbox_utils = sandbox_utils or {} --- inherit the public interfaces of utils -for k, v in pairs(utils) do - if not k:startswith("_") and type(v) == "function" then - sandbox_utils[k] = v - end -end +-- inherit some builtin interfaces +sandbox_utils.dump = utils.dump -- do not change to a function call to utils.dump since debug.getinfo is called in utils.dump to get caller info +sandbox_utils.confirm = utils.confirm +sandbox_utils.error = utils.error +sandbox_utils.warning = utils.warning +sandbox_utils.trycall = utils.trycall +sandbox_utils.ifelse = utils.ifelse -- print each arguments function sandbox_utils._print(...) @@ -184,15 +186,6 @@ function sandbox_utils.assert(value, format, ...) return value end --- get user confirm -function sandbox_utils.confirm(opt) - return utils.confirm(opt) -end - --- dump value --- do not change to a function call to utils.dump since debug.getinfo is called in utils.dump to get caller info -sandbox_utils.dump = utils.dump - -- return module return sandbox_utils diff --git a/xmake/themes/dark/xmake.lua b/xmake/themes/dark/xmake.lua index 580fc81fd..a72a1aa8b 100644 --- a/xmake/themes/dark/xmake.lua +++ b/xmake/themes/dark/xmake.lua @@ -53,7 +53,7 @@ theme("dark") set_color("build.target", "magenta") -- the spinner chars - if os.subhost() ~= "msys" and os.subhost() ~= "cygwin" then + if not os.subhost("msys", "cygwin") then set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') else set_text("spinner.chars", '\\', '-', '/', '|') diff --git a/xmake/themes/default/xmake.lua b/xmake/themes/default/xmake.lua index a34cb3731..a1d8651b4 100644 --- a/xmake/themes/default/xmake.lua +++ b/xmake/themes/default/xmake.lua @@ -53,7 +53,7 @@ theme("default") set_color("build.target", "magenta bright") -- the spinner chars - if os.subhost() ~= "msys" and os.subhost() ~= "cygwin" then + if not os.subhost("msys", "cygwin") then set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') else set_text("spinner.chars", '\\', '-', '/', '|') diff --git a/xmake/themes/emoji/xmake.lua b/xmake/themes/emoji/xmake.lua index 771c3f640..59d640bd2 100644 --- a/xmake/themes/emoji/xmake.lua +++ b/xmake/themes/emoji/xmake.lua @@ -35,22 +35,22 @@ theme("emoji") -- the error info set_text("error", "exclamation error") - set_color("error", "red") + set_color("error", "red bright") -- the warning info set_text("warning", "warning $warning") - set_color("warning", "yellow") + set_color("warning", "yellow bright") -- the building progress set_text("build.progress_format", "[%3d%%]") set_text("build.progress_style", "scroll") - set_color("build.progress", "green") + set_color("build.progress", "green bright") -- the building object file set_color("build.object", "") -- the building target file - set_color("build.target", "magenta") + set_color("build.target", "magenta bright") -- the spinner chars set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') diff --git a/xmake/themes/ninja/xmake.lua b/xmake/themes/ninja/xmake.lua index d501d6eac..aaccfbd9d 100644 --- a/xmake/themes/ninja/xmake.lua +++ b/xmake/themes/ninja/xmake.lua @@ -53,7 +53,7 @@ theme("ninja") set_color("build.target", "magenta bright") -- the spinner chars - if os.subhost() ~= "msys" and os.subhost() ~= "cygwin" then + if not os.subhost("msys", "cygwin") then set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') else set_text("spinner.chars", '\\', '-', '/', '|') |
