summaryrefslogtreecommitdiff
path: root/xmake/scripts/platform/platform.lua
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/platform/platform.lua
parent111bd8e8cbf0c3b242ed3b137415d9560c4aac37 (diff)
list plats and archs for options
Diffstat (limited to 'xmake/scripts/platform/platform.lua')
-rw-r--r--xmake/scripts/platform/platform.lua49
1 files changed, 47 insertions, 2 deletions
diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua
index 7ae8af969..ab3384bed 100644
--- a/xmake/scripts/platform/platform.lua
+++ b/xmake/scripts/platform/platform.lua
@@ -24,6 +24,8 @@
local platform = platform or {}
-- load modules
+local os = require("base/os")
+local path = require("base/path")
local utils = require("base/utils")
local config = require("base/config")
@@ -35,7 +37,7 @@ function platform.init()
local configs = platform._CONFIGS
-- load platform
- local p = require("platform/_" .. config.get("plat"))
+ local p = require("platform/" .. config.get("plat") .. "/_" .. config.get("plat"))
if not p then
return false
end
@@ -58,7 +60,7 @@ end
function platform.format(kind)
-- get format
- local format = platform.get("format")
+ local format = platform.get("formats")
-- get it
return format[kind] or {"", ""}
@@ -77,5 +79,48 @@ function platform.dump()
end
+-- list all platforms
+function platform.plats()
+
+ -- return it directly if exists
+ if platform._PLATS then
+ return platform._PLATS
+ end
+
+ -- get the platform list
+ local plats = os.match(xmake._SCRIPTS_DIR .. "/platform/*", true)
+ if plats then
+ for i, v in ipairs(plats) do
+ plats[i] = path.basename(v)
+ end
+ end
+
+ -- save it
+ platform._PLATS = plats
+
+ -- ok
+ return plats
+end
+
+-- list all architectures
+function platform.archs(plat)
+
+ -- check
+ assert(plat)
+
+ -- load all platform configs
+ local archs = {}
+ local configs = {}
+ local p = require("platform/" .. plat .. "/_" .. plat)
+ if p and p.init(configs) and configs.archs then
+ for arch, _ in pairs(configs.archs) do
+ archs[table.getn(archs) + 1] = arch
+ end
+ end
+
+ -- ok
+ return archs
+end
+
-- return module: platform
return platform