summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunity <[email protected]>2020-01-18 15:04:36 +0800
committerOpportunity <[email protected]>2020-01-19 13:01:08 +0800
commit31835e7868e053d02f20d56a380c0cf1d19cef33 (patch)
treeb46923e67e29fadebef3452997616137dd8292ca
parent1c3b4323b86f19940d20cdaf65963647caff1fe4 (diff)
fix when not in a project
-rw-r--r--xmake/actions/build/xmake.lua2
-rw-r--r--xmake/actions/clean/xmake.lua2
-rw-r--r--xmake/actions/config/xmake.lua8
-rw-r--r--xmake/actions/install/xmake.lua2
-rw-r--r--xmake/actions/package/xmake.lua2
-rw-r--r--xmake/actions/run/xmake.lua2
-rw-r--r--xmake/actions/uninstall/xmake.lua2
-rw-r--r--xmake/core/base/option.lua6
-rw-r--r--xmake/core/base/todisplay.lua2
9 files changed, 13 insertions, 15 deletions
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua
index 0eb4eb991..51fd34302 100644
--- a/xmake/actions/build/xmake.lua
+++ b/xmake/actions/build/xmake.lua
@@ -56,7 +56,7 @@ task("build")
, {}
, {nil, "target", "v", nil , "The target name. It will build all default targets if this parameter is not specified."
- , values = function () return table.keys(import("core.project.project").targets()) end }
+ , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
}
}
diff --git a/xmake/actions/clean/xmake.lua b/xmake/actions/clean/xmake.lua
index 1b088c181..0d9b265c1 100644
--- a/xmake/actions/clean/xmake.lua
+++ b/xmake/actions/clean/xmake.lua
@@ -45,7 +45,7 @@ task("clean")
, {}
, {nil, "target", "v", nil , "The target name. It will clean all default targets if this parameter is not specified."
- , values = function () return table.keys(import("core.project.project").targets()) end }
+ , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
}
}
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index 8f1f1d06e..1f04ce1a8 100644
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -78,11 +78,9 @@ task("config")
, {'m', "mode", "kv", "release", "Compile for the given mode."
, " - debug"
, " - release"
- , " - ... (custom)" }
+ , " - ... (custom)" }
, {'k', "kind", "kv", "static", "Compile for the given target kind."
- , values = function ()
- return {"static", "shared", "binary"}
- end }
+ , values = {"static", "shared", "binary"} }
, {nil, "host", "kv", "$(host)", "The Current Host Environment." }
-- show project menu options
@@ -137,7 +135,7 @@ task("config")
, {}
, {nil, "target", "v", nil , "Configure for the given target."
- , values = function () return table.keys(import("core.project.project").targets()) end }
+ , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
}
}
diff --git a/xmake/actions/install/xmake.lua b/xmake/actions/install/xmake.lua
index 4aad1a62f..09ecc883f 100644
--- a/xmake/actions/install/xmake.lua
+++ b/xmake/actions/install/xmake.lua
@@ -50,7 +50,7 @@ task("install")
, { }
, {nil, "target", "v", nil , "The target name. It will install all default targets if this parameter is not specified."
- , values = function () return table.keys(import("core.project.project").targets()) end }
+ , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
}
}
diff --git a/xmake/actions/package/xmake.lua b/xmake/actions/package/xmake.lua
index d50562ad0..13c3f4b28 100644
--- a/xmake/actions/package/xmake.lua
+++ b/xmake/actions/package/xmake.lua
@@ -45,7 +45,7 @@ task("package")
, {'a', "all", "k", nil , "Package all targets." }
, {}
, {nil, "target", "v", nil , "The target name. It will package all default targets if this parameter is not specified."
- , values = function () return table.keys(import("core.project.project").targets()) end }
+ , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
}
}
diff --git a/xmake/actions/run/xmake.lua b/xmake/actions/run/xmake.lua
index 6daf6f328..f33184be5 100644
--- a/xmake/actions/run/xmake.lua
+++ b/xmake/actions/run/xmake.lua
@@ -49,7 +49,7 @@ task("run")
" --workdir=`pwd`" }
, {}
, {nil, "target", "v", nil , "The target name. It will run all default targets if this parameter is not specified."
- , values = function () return table.keys(import("core.project.project").targets()) end }
+ , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
, {nil, "arguments", "vs", nil , "The target arguments" }
}
}
diff --git a/xmake/actions/uninstall/xmake.lua b/xmake/actions/uninstall/xmake.lua
index 511b61e9e..4f70922c2 100644
--- a/xmake/actions/uninstall/xmake.lua
+++ b/xmake/actions/uninstall/xmake.lua
@@ -52,7 +52,7 @@ task("uninstall")
"or $ PREFIX=local xmake uninstall" }
, { }
, {nil, "target", "v", nil , "The target name. It will uninstall all default targets if this parameter is not specified."
- , values = function () return table.keys(import("core.project.project").targets()) end }
+ , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
}
}
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 36bcf6c39..e49b47f40 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -787,11 +787,11 @@ function option.show_options(options, taskname)
end
-- append values
- local values, ok = opt.values
+ local values = opt.values
if type(values) == "function" then
- ok, values = pcall(values)
+ values = values()
end
- if ok and values then
+ if values then
for _, value in ipairs(table.wrap(values)) do
table.insert(desp_strs, " - " .. tostring(value))
end
diff --git a/xmake/core/base/todisplay.lua b/xmake/core/base/todisplay.lua
index 8ce782a79..ed821e2f2 100644
--- a/xmake/core/base/todisplay.lua
+++ b/xmake/core/base/todisplay.lua
@@ -70,7 +70,7 @@ function todisplay._print_default_scalar(value, style, formatkey)
formatkey = nil
end
elseif __tostring then
- local ok, str = pcall(__todisplay, value)
+ local ok, str = pcall(__tostring, value)
if ok then
value = str
end