summaryrefslogtreecommitdiff
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
parent111bd8e8cbf0c3b242ed3b137415d9560c4aac37 (diff)
list plats and archs for options
-rwxr-xr-xinstall3
-rw-r--r--xmake/scripts/base/config.lua23
-rw-r--r--xmake/scripts/base/main.lua32
-rw-r--r--xmake/scripts/base/option.lua42
-rw-r--r--xmake/scripts/platform/android/_android.lua (renamed from xmake/scripts/platform/_android.lua)15
-rw-r--r--xmake/scripts/platform/ios/_ios.lua (renamed from xmake/scripts/platform/_ios.lua)16
-rw-r--r--xmake/scripts/platform/linux/_linux.lua (renamed from xmake/scripts/platform/_linux.lua)15
-rw-r--r--xmake/scripts/platform/macosx/_macosx.lua (renamed from xmake/scripts/platform/_macosx.lua)15
-rw-r--r--xmake/scripts/platform/platform.lua49
-rw-r--r--xmake/scripts/platform/windows/_windows.lua (renamed from xmake/scripts/platform/_windows.lua)17
10 files changed, 167 insertions, 60 deletions
diff --git a/install b/install
index 1116fabd4..7a2344fec 100755
--- a/install
+++ b/install
@@ -53,6 +53,9 @@ cd ..
# create the xmake install directory
xmake_dir_install=/usr/local/share/xmake
+if [ -d $xmake_dir_install ]; then
+ sudo rm -rf $xmake_dir_install
+fi
if [ ! -d $xmake_dir_install ]; then
sudo mkdir $xmake_dir_install
fi
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
diff --git a/xmake/scripts/platform/_android.lua b/xmake/scripts/platform/android/_android.lua
index 18d74cd35..910a61b68 100644
--- a/xmake/scripts/platform/_android.lua
+++ b/xmake/scripts/platform/android/_android.lua
@@ -26,11 +26,16 @@ local _android = _android or {}
-- init _android
function _android.init(configs)
- -- init the file name format
- configs.format = {}
- configs.format.static = {"lib", ".a"}
- configs.format.object = {"", ".o"}
- configs.format.shared = {"", ".so"}
+ -- init the file name formats
+ configs.formats = {}
+ configs.formats.static = {"lib", ".a"}
+ configs.formats.object = {"", ".o"}
+ configs.formats.shared = {"", ".so"}
+
+ -- init the architecture scopes
+ configs.archs = {}
+ configs.archs.armv5te = {}
+ configs.archs.armv6 = {}
-- ok
return true
diff --git a/xmake/scripts/platform/_ios.lua b/xmake/scripts/platform/ios/_ios.lua
index d9fd2ff39..23979b46e 100644
--- a/xmake/scripts/platform/_ios.lua
+++ b/xmake/scripts/platform/ios/_ios.lua
@@ -26,11 +26,17 @@ local _ios = _ios or {}
-- init _ios
function _ios.init(configs)
- -- init the file name format
- configs.format = {}
- configs.format.static = {"lib", ".a"}
- configs.format.object = {"", ".o"}
- configs.format.shared = {"", ".dylib"}
+ -- init the file name formats
+ configs.formats = {}
+ configs.formats.static = {"lib", ".a"}
+ configs.formats.object = {"", ".o"}
+ configs.formats.shared = {"", ".dylib"}
+
+ -- init the architecture scopes
+ configs.archs = {}
+ configs.archs.armv7 = {}
+ configs.archs.armv7s = {}
+ configs.archs.arm64 = {}
-- ok
return true
diff --git a/xmake/scripts/platform/_linux.lua b/xmake/scripts/platform/linux/_linux.lua
index c4e7d67bc..0366bbbbe 100644
--- a/xmake/scripts/platform/_linux.lua
+++ b/xmake/scripts/platform/linux/_linux.lua
@@ -26,11 +26,16 @@ local _linux = _linux or {}
-- init _linux
function _linux.init(configs)
- -- init the file name format
- configs.format = {}
- configs.format.static = {"lib", ".a"}
- configs.format.object = {"", ".o"}
- configs.format.shared = {"", ".so"}
+ -- init the file name formats
+ configs.formats = {}
+ configs.formats.static = {"lib", ".a"}
+ configs.formats.object = {"", ".o"}
+ configs.formats.shared = {"", ".so"}
+
+ -- init the architecture scopes
+ configs.archs = {}
+ configs.archs.x86 = {}
+ configs.archs.x64 = {}
-- ok
return true
diff --git a/xmake/scripts/platform/_macosx.lua b/xmake/scripts/platform/macosx/_macosx.lua
index 3a3879730..54dd35e85 100644
--- a/xmake/scripts/platform/_macosx.lua
+++ b/xmake/scripts/platform/macosx/_macosx.lua
@@ -26,11 +26,16 @@ local _macosx = _macosx or {}
-- init _macosx
function _macosx.init(configs)
- -- init the file name format
- configs.format = {}
- configs.format.static = {"lib", ".a"}
- configs.format.object = {"", ".o"}
- configs.format.shared = {"", ".dylib"}
+ -- init the file name formats
+ configs.formats = {}
+ configs.formats.static = {"lib", ".a"}
+ configs.formats.object = {"", ".o"}
+ configs.formats.shared = {"", ".dylib"}
+
+ -- init the architecture scopes
+ configs.archs = {}
+ configs.archs.x86 = {}
+ configs.archs.x64 = {}
-- ok
return true
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
diff --git a/xmake/scripts/platform/_windows.lua b/xmake/scripts/platform/windows/_windows.lua
index 699d4d2d6..c810f5024 100644
--- a/xmake/scripts/platform/_windows.lua
+++ b/xmake/scripts/platform/windows/_windows.lua
@@ -26,12 +26,17 @@ local _windows = _windows or {}
-- init _windows
function _windows.init(configs)
- -- init the file name format
- configs.format = {}
- configs.format.static = {"", ".lib"}
- configs.format.object = {"", ".obj"}
- configs.format.shared = {"", ".dll"}
- configs.format.console = {"", ".exe"}
+ -- init the file name formats
+ configs.formats = {}
+ configs.formats.static = {"", ".lib"}
+ configs.formats.object = {"", ".obj"}
+ configs.formats.shared = {"", ".dll"}
+ configs.formats.console = {"", ".exe"}
+
+ -- init the architecture scopes
+ configs.archs = {}
+ configs.archs.x86 = {}
+ configs.archs.x64 = {}
-- ok
return true