summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunity <[email protected]>2020-01-20 22:18:58 +0800
committerOpportunity <[email protected]>2020-01-20 22:21:47 +0800
commit08d00484b84526bf8b20f8ff9016ad2c0fc851ae (patch)
treea5eac2509adfcd291e14472aaa8c364549a68fcd
parentd3e45885b8fa8e905e061b9c14f0cc34ba35b5f5 (diff)
fix code style
-rw-r--r--xmake/actions/config/xmake.lua59
-rw-r--r--xmake/actions/update/xmake.lua26
-rw-r--r--xmake/core/base/task.lua8
-rw-r--r--xmake/core/theme/theme.lua10
-rw-r--r--xmake/platforms/windows/xmake.lua25
-rw-r--r--xmake/plugins/lua/main.lua2
-rw-r--r--xmake/plugins/lua/xmake.lua4
7 files changed, 71 insertions, 63 deletions
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index 3dd486c96..91c5147f4 100644
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -11,7 +11,7 @@
-- 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
@@ -39,16 +39,21 @@ task("config")
, shortname = 'f'
-- options
- , options =
+ , options =
{
{'c', "clean", "k", nil , "Clean the cached configure and configure all again." }
, {nil, "menu", "k", nil , "Configure project with a menu-driven user interface." }
- , {nil, "require", "kv", nil , "Require all dependent packages?",
- " - y: force to enable",
- " - n: disable" }
+ , {nil, "require", "kv", nil , "Require all dependent packages?"
+ , values = function (complete)
+ if complete then
+ return {"yes", "no"}
+ else
+ return {"y: force to enable", "n: disable" }
+ end
+ end }
, {category = "."}
- , {'p', "plat", "kv", "$(host)" , "Compile for the given platform."
+ , {'p', "plat", "kv", "$(host)" , "Compile for the given platform."
, values = function ()
return import("core.platform.platform").plats()
end }
@@ -56,7 +61,7 @@ task("config")
-- show the description of all architectures
function ()
- -- import platform
+ -- import platform
import("core.platform.platform")
-- make description
@@ -74,8 +79,8 @@ task("config")
-- get it
return description
end
- , values = function (completing, opt)
- if not completing then return end
+ , values = function (complete, opt)
+ if not complete then return end
-- import
import("core.platform.platform")
@@ -105,44 +110,48 @@ task("config")
-- get it
return arches:to_array()
end }
- , {'m', "mode", "kv", "release" , "Compile for the given mode.",
- " - debug",
- " - release",
- " - ... (custom)"
- , values = function (completing)
- if not completing then return end
- return {"debug", "release", "profile", "check", "coverage"}
+ , {'m', "mode", "kv", "release" , "Compile for the given mode."
+ , values = function (complete)
+
+ local modes = try {
+ function() return import("core.project.project").modes() end
+ } or {"debug", "release"}
+ table.sort(modes)
+ if not complete then
+ table.insert(modes, "... (custom)")
+ end
+ return modes
end }
, {'k', "kind", "kv", "static" , "Compile for the given target kind."
, values = {"static", "shared", "binary"} }
, {nil, "host", "kv", "$(host)" , "The Current Host Environment." }
-- show project menu options
- , function ()
+ , function ()
- -- import project menu
+ -- import project menu
import("core.project.menu")
- -- get project menu options
- return menu.options()
+ -- get project menu options
+ return menu.options()
end
, {category = "Cross Complation Configuration"}
- , {nil, "cross", "kv", nil, "The Cross Toolchains Prefix"
+ , {nil, "cross", "kv", nil, "The Cross Toolchains Prefix"
, "e.g."
, " - i386-mingw32-"
, " - arm-linux-androideabi-" }
- , {nil, "bin", "kv", nil, "The Cross Toolchains Bin Directory"
+ , {nil, "bin", "kv", nil, "The Cross Toolchains Bin Directory"
, "e.g."
, " - sdk/bin (/arm-linux-gcc ..)" }
- , {nil, "sdk", "kv", nil, "The Cross SDK Directory"
+ , {nil, "sdk", "kv", nil, "The Cross SDK Directory"
, "e.g."
, " - sdk/bin"
, " - sdk/lib"
, " - sdk/include" }
-- show language menu options
- , function ()
+ , function ()
-- import language menu
import("core.language.menu")
@@ -152,7 +161,7 @@ task("config")
end
-- show platform menu options
- , function ()
+ , function ()
-- import platform menu
import("core.platform.menu")
diff --git a/xmake/actions/update/xmake.lua b/xmake/actions/update/xmake.lua
index c4b281638..74dcd0ba9 100644
--- a/xmake/actions/update/xmake.lua
+++ b/xmake/actions/update/xmake.lua
@@ -49,14 +49,14 @@ task("update")
" https://github.com/xmake-io/xmake",
" github:xmake-io/xmake#~2.2.3",
" git://github.com/xmake-io/xmake.git#master",
- values = function (completing)
- if not completing then
+ values = function (complete)
+ if not complete then
return
end
return try{ function ()
import("private.action.update.fetch_version")
- local seg = completing:split('#', { plain = true, limit = 2, strict = true })
+ local seg = complete:split('#', { plain = true, limit = 2, strict = true })
if #seg == 1 then
if seg[1]:find(':', 1, true) then
-- incomplete custom source
@@ -67,19 +67,19 @@ task("update")
end
local versions = fetch_version(seg[1])
- if versions.is_official then
- for i,v in ipairs(versions.tags) do
- if v:startswith("v") and #v > 5 then
- versions.tags[i] = v:sub(2)
- end
+ for i,v in ipairs(versions.tags) do
+ if v:startswith("v") and #v > 5 then
+ versions.tags[i] = v:sub(2)
end
- return table.join(versions.branches, table.reverse(versions.tags))
+ end
+ local candidates = table.join("latest", versions.branches, table.reverse(versions.tags))
+ if versions.is_official then
+ return candidates
else
- local values = table.join(versions.branches, table.reverse(versions.tags))
- for i, v in ipairs(values) do
- values[i] = seg[1] .. "#" .. v
+ for i, v in ipairs(candidates) do
+ candidates[i] = seg[1] .. "#" .. v
end
- return values
+ return candidates
end
end }
end}
diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua
index 39a3711da..7ffcdfcc4 100644
--- a/xmake/core/base/task.lua
+++ b/xmake/core/base/task.lua
@@ -37,12 +37,8 @@ function task.common_options()
{
{'q', "quiet", "k", nil, "Quiet operation." }
, {'y', "yes", "k", nil, "Input yes by default if need user confirm." }
- , {nil, "confirm", "kv", nil, "Input the given result if need user confirm.",
- " - y|yes",
- " - n|no",
- " - d|def"
- , values = function (complete)
- if not complete then return end
+ , {nil, "confirm", "kv", nil, "Input the given result if need user confirm."
+ , values = function ()
return {"yes", "no", "def"}
end }
, {'v', "verbose", "k", nil, "Print lots of verbose information for users." }
diff --git a/xmake/core/theme/theme.lua b/xmake/core/theme/theme.lua
index adf5024fb..f8070c44b 100644
--- a/xmake/core/theme/theme.lua
+++ b/xmake/core/theme/theme.lua
@@ -11,7 +11,7 @@
-- 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
@@ -59,7 +59,7 @@ function theme._interpreter()
-- init interpreter
local interp = interpreter.new()
assert(interp)
-
+
-- define apis
interp:api_define(theme._apis())
@@ -72,7 +72,7 @@ end
-- get theme apis
function theme._apis()
- return
+ return
{
keyvalues =
{
@@ -90,7 +90,7 @@ function theme.directories()
local dirs = theme._DIRS or { path.join(global.directory(), "themes")
, path.join(os.programdir(), "themes")
}
-
+
-- save directories to cache
theme._DIRS = dirs
return dirs
@@ -101,7 +101,7 @@ function theme.names()
local paths = {}
for _, dir in ipairs(theme.directories()) do
- table.join2(paths, (os.match(path.join(dir, "*", "xmake.lua"), "f")))
+ table.join2(paths, (os.files(path.join(dir, "*", "xmake.lua"))))
end
for i, v in ipairs(paths) do
local value = path.split(v)
diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua
index 0dc7b91f8..43c7acccb 100644
--- a/xmake/platforms/windows/xmake.lua
+++ b/xmake/platforms/windows/xmake.lua
@@ -11,7 +11,7 @@
-- 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
@@ -50,10 +50,10 @@ platform("windows")
-- set menu
set_menu {
- config =
- {
+ config =
+ {
{category = "Visual Studio SDK Configuration" }
- , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio"
+ , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio"
, " e.g. --vs=2017" }
, {nil, "vs_toolset", "kv", nil, "The Microsoft Visual Studio Toolset Version"
, " e.g. --vs_toolset=14.0" }
@@ -67,19 +67,20 @@ platform("windows")
, {category = "WDK Configuration" }
, {nil, "wdk", "kv", "auto", "The WDK Directory" }
, {nil, "wdk_sdkver", "kv", "auto", "The WDK Version" }
- , {nil, "wdk_winver", "kv", "auto", "The WDK Windows Version",
- " - win10_rs3",
- " - win10",
- " - win81",
- " - win8",
- " - win7",
- " - win7_[sp1|sp2|sp3]" }
+ , {nil, "wdk_winver", "kv", "auto", "The WDK Windows Version"
+ , values = function (complete)
+ if complete then
+ return {"win10_rs3", "win10", "win81", "win8", "win7_sp3", "win7_sp2", "win7_sp1", "win7"}
+ else
+ return {"win10[|_rs3]", "win81", "win8", "win7[|_sp1|_sp2|_sp3]"}
+ end
+ end }
, {category = "Vcpkg Configuration" }
, {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" }
}
, global =
- {
+ {
{category = "Visual Studio SDK Configuration" }
, {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" }
, {category = "Cuda SDK Configuration" }
diff --git a/xmake/plugins/lua/main.lua b/xmake/plugins/lua/main.lua
index 7586ab65a..c0ed6e3d0 100644
--- a/xmake/plugins/lua/main.lua
+++ b/xmake/plugins/lua/main.lua
@@ -26,7 +26,7 @@ import("core.sandbox.sandbox")
-- get all lua scripts
function scripts()
local names = {}
- local files = os.match(path.join(os.scriptdir(), "scripts/*.lua"))
+ local files = os.files(path.join(os.scriptdir(), "scripts/*.lua"))
for _, file in ipairs(files) do
table.insert(names, path.basename(file))
end
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua
index 7b7bb8dd3..23d00b145 100644
--- a/xmake/plugins/lua/xmake.lua
+++ b/xmake/plugins/lua/xmake.lua
@@ -52,7 +52,9 @@ task("lua")
" - xmake lua core.xxx.xxx",
" - xmake lua -c 'print(...)' hello xmake!"
, values = function (complete, opt)
- if not complete or opt.command or opt.list then return end
+ if not complete or opt.command or opt.list then
+ return
+ end
return import("main.scripts")()
end }