summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
diff options
context:
space:
mode:
authorruki <[email protected]>2015-05-21 10:10:24 +0800
committerruki <[email protected]>2015-05-21 10:10:24 +0800
commit24e6b488718dab5dc58a7b4adc901884d716f478 (patch)
treea3963cc0d8ee123de1fcaacf9354e996401b06c3 /xmake/scripts/base
parent111bd8e8cbf0c3b242ed3b137415d9560c4aac37 (diff)
list plats and archs for options
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/config.lua23
-rw-r--r--xmake/scripts/base/main.lua32
-rw-r--r--xmake/scripts/base/option.lua42
3 files changed, 65 insertions, 32 deletions
diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua
index d2ffc546b..ca6420e81 100644
--- a/xmake/scripts/base/config.lua
+++ b/xmake/scripts/base/config.lua
@@ -29,22 +29,6 @@ local utils = require("base/utils")
local option = require("base/option")
local preprocessor = require("base/preprocessor")
--- make the automatic configure
-function config._auto(name)
-
- -- get platform or host
- if name == "plat" or name == "host" then
- return xmake._HOST
- -- get architecture
- elseif name == "arch" then
- return xmake._ARCH
- end
-
- -- unknown
- utils.error("unknown config: %s", name)
- return "unknown"
-end
-
-- save object with the level
function config._save_with_level(file, object, level)
@@ -332,12 +316,7 @@ function config.loadxconf()
-- save the default option to the target
if not target[k] then
-
- if v == "auto" then
- target[k] = config._auto(k)
- else
- target[k] = v
- end
+ target[k] = v
end
end
end
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua
index 97ec71b01..13ce70dfa 100644
--- a/xmake/scripts/base/main.lua
+++ b/xmake/scripts/base/main.lua
@@ -143,13 +143,39 @@ local menu =
-- options
, options =
{
- {'p', "plat", "kv", "auto", "Compile for the given platform." }
- , {'a', "arch", "kv", "auto", "Compile for the given architecture." }
+ {'p', "plat", "kv", xmake._HOST, "Compile for the given platform."
+ , function ()
+ local descriptions = {}
+ local plats = platform.plats()
+ if plats then
+ for i, plat in ipairs(plats) do
+ descriptions[i] = " - " .. plat
+ end
+ end
+ return descriptions
+ end }
+ , {'a', "arch", "kv", xmake._ARCH, "Compile for the given architecture."
+ , function ()
+ local descriptions = {}
+ local plats = platform.plats()
+ if plats then
+ for i, plat in ipairs(plats) do
+ descriptions[i] = " - " .. plat .. ":"
+ local archs = platform.archs(plat)
+ if archs then
+ for _, arch in ipairs(archs) do
+ descriptions[i] = descriptions[i] .. " " .. arch
+ end
+ end
+ end
+ end
+ return descriptions
+ end }
, {'m', "mode", "kv", "release", "Compile for the given mode."
, " - debug"
, " - release"
, " - profile" }
- , {'-', "host", "kv", "auto", "The current host environment." }
+ , {'-', "host", "kv", xmake._HOST, "The current host environment." }
, {}
, {'o', "buildir", "kv", "build", "Set the build directory" }
diff --git a/xmake/scripts/base/option.lua b/xmake/scripts/base/option.lua
index 60b769dd8..7e3d963b4 100644
--- a/xmake/scripts/base/option.lua
+++ b/xmake/scripts/base/option.lua
@@ -442,16 +442,44 @@ function option.print_options(options)
-- print more description if exists
for i = 6, #option do
- if option[i] then
- -- make spaces
- local spaces = ""
- for i = 0, padding do
- spaces = spaces .. " "
+ -- the description
+ local description = option[i]
+ if description then
+
+ -- is function? get results
+ if type(description) == "function" then
+ description = description()
end
- -- print this description
- print(spaces .. option[i])
+ -- the description is string?
+ if type(description) == "string" then
+
+ -- make spaces
+ local spaces = ""
+ for i = 0, padding do
+ spaces = spaces .. " "
+ end
+
+ -- print this description
+ print(spaces .. description)
+
+ -- the description is table?
+ elseif type(description) == "table" then
+
+ -- print all descriptions
+ for _, v in pairs(description) do
+
+ -- make spaces
+ local spaces = ""
+ for i = 0, padding do
+ spaces = spaces .. " "
+ end
+
+ -- print this description
+ print(spaces .. v)
+ end
+ end
end
end
end