diff options
| author | ruki <[email protected]> | 2015-06-10 14:57:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-10 14:57:56 +0800 |
| commit | 112bd89dfd816cac735e447e41de0ff9c5687390 (patch) | |
| tree | 64cb4a58b97e4ed2f60c5a77c8b54368887c6559 /xmake/scripts | |
| parent | 5621d811df57824463d48c41c8a9ffa26864d293 (diff) | |
remove wrap config for prober
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/base/main.lua | 28 | ||||
| -rw-r--r-- | xmake/scripts/platform/android/prober.lua | 33 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphoneos/prober.lua | 53 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphonesimulator/prober.lua | 51 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/prober.lua | 33 | ||||
| -rw-r--r-- | xmake/scripts/platform/macosx/prober.lua | 53 | ||||
| -rw-r--r-- | xmake/scripts/platform/platform.lua | 6 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/prober.lua | 36 |
8 files changed, 143 insertions, 150 deletions
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index a46c3ea81..8fed356c2 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -99,20 +99,8 @@ function main._prepare_global() -- xmake global? if options._ACTION == "global" then - -- wrap the global configure for more convenient to get and set values - local global_wrapped = {} - setmetatable(global_wrapped, - { - __index = function(tbl, key) - return global.get(key) - end, - __newindex = function(tbl, key, val) - global.set(key, val) - end - }) - -- probe the global platform configure - platform.probe(global_wrapped, true) + platform.probe(true) -- clear up the global configure global.clearup() @@ -141,20 +129,8 @@ function main._prepare_project() -- xmake config or marked as "reconfig"? if options._ACTION == "config" or config._RECONFIG then - -- wrap the configure for more convenient to get and set values - local config_wrapped = {} - setmetatable(config_wrapped, - { - __index = function(tbl, key) - return config.get(key) - end, - __newindex = function(tbl, key, val) - config.set(key, val) - end - }) - -- probe the current platform configure - platform.probe(config_wrapped, false) + platform.probe(false) -- clear up the configure config.clearup() diff --git a/xmake/scripts/platform/android/prober.lua b/xmake/scripts/platform/android/prober.lua index c53b2db57..eed124d8d 100644 --- a/xmake/scripts/platform/android/prober.lua +++ b/xmake/scripts/platform/android/prober.lua @@ -26,35 +26,38 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") local tools = require("tools/tools") +local config = require("base/config") +local global = require("base/global") -- define module: prober local prober = prober or {} -- probe the architecture -function prober._probe_arch(configs) +function prober._probe_arch() -- get the architecture - local arch = configs.arch + local arch = config.get("arch") -- ok? if arch then return true end -- init the default architecture - configs.arch = "armv7-a" + config.set("arch", "armv7-a") -- ok return true end -- probe the ccache -function prober._probe_ccache(configs) +function prober._probe_ccache() -- ok? - if configs.ccache and configs.__ccache then return true end + local ccache_enable = config.get("ccache") + if ccache_enable and config.get("__ccache") then return true end -- disable? - if type(configs.ccache) == "boolean" and not configs.ccache then - configs.__ccache = nil + if type(ccache_enable) == "boolean" and not ccache_enable then + config.set("__ccache", nil) return true end @@ -63,10 +66,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = true - configs.__ccache = ccache_path + config.set("ccache", true) + config.set("__ccache", ccache_path) else - configs.ccache = false + config.set("ccache", false) end -- ok @@ -74,21 +77,21 @@ function prober._probe_ccache(configs) end -- probe the project configure -function prober.config(configs) +function prober.config() -- probe the architecture - if not prober._probe_arch(configs) then return end + if not prober._probe_arch() then return end -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end -- probe the global configure -function prober.global(configs) +function prober.global() -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end diff --git a/xmake/scripts/platform/iphoneos/prober.lua b/xmake/scripts/platform/iphoneos/prober.lua index a9b7d63c4..3b885da6e 100644 --- a/xmake/scripts/platform/iphoneos/prober.lua +++ b/xmake/scripts/platform/iphoneos/prober.lua @@ -26,31 +26,33 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") local tools = require("tools/tools") +local config = require("base/config") +local global = require("base/global") -- define module: prober local prober = prober or {} -- probe the architecture -function prober._probe_arch(configs) +function prober._probe_arch() -- get the architecture - local arch = configs.arch + local arch = config.get("arch") -- ok? if arch then return true end -- init the default architecture - configs.arch = "armv7" + config.set("arch", "armv7") -- ok return true end -- probe the xcode application directory -function prober._probe_xcode(configs) +function prober._probe_xcode() -- get the xcode directory - local xcode_dir = configs.xcode_dir + local xcode_dir = config.get("xcode_dir") -- ok? if xcode_dir then return true end @@ -75,7 +77,7 @@ function prober._probe_xcode(configs) -- probe ok? update it if xcode_dir then - configs.xcode_dir = xcode_dir + config.set("xcode_dir", xcode_dir) else -- failed utils.error("The Xcode directory is unknown now, please config it first!") @@ -89,10 +91,10 @@ function prober._probe_xcode(configs) end -- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) +function prober._probe_xcode_sdkver() -- get the xcode sdk version - local xcode_sdkver = configs.xcode_sdkver + local xcode_sdkver = config.get("xcode_sdkver") -- ok? if xcode_sdkver then return true end @@ -102,7 +104,7 @@ function prober._probe_xcode_sdkver(configs) -- attempt to match the directory if not xcode_sdkver then - local dirs = os.match(configs.xcode_dir .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk", true) + local dirs = os.match(config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk", true) if dirs then for _, dir in ipairs(dirs) do xcode_sdkver = string.match(dir, "%d+%.%d+") @@ -113,7 +115,7 @@ function prober._probe_xcode_sdkver(configs) -- probe ok? update it if xcode_sdkver then - configs.xcode_sdkver = xcode_sdkver + config.set("xcode_sdkver", xcode_sdkver) else -- failed utils.error("The Xcode SDK version is unknown now, please config it first!") @@ -127,14 +129,15 @@ function prober._probe_xcode_sdkver(configs) end -- probe the ccache -function prober._probe_ccache(configs) +function prober._probe_ccache() -- ok? - if configs.ccache and configs.__ccache then return true end + local ccache_enable = config.get("ccache") + if ccache_enable and config.get("__ccache") then return true end -- disable? - if type(configs.ccache) == "boolean" and not configs.ccache then - configs.__ccache = nil + if type(ccache_enable) == "boolean" and not ccache_enable then + config.set("__ccache", nil) return true end @@ -143,10 +146,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = true - configs.__ccache = ccache_path + config.set("ccache", true) + config.set("__ccache", ccache_path) else - configs.ccache = false + config.set("ccache", false) end -- ok @@ -154,30 +157,30 @@ function prober._probe_ccache(configs) end -- probe the project configure -function prober.config(configs) +function prober.config() -- probe the architecture - if not prober._probe_arch(configs) then return end + if not prober._probe_arch() then return end -- probe the xcode application directory - if not prober._probe_xcode(configs) then return end + if not prober._probe_xcode() then return end -- probe the xcode sdk version - if not prober._probe_xcode_sdkver(configs) then return end + if not prober._probe_xcode_sdkver() then return end -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end -- probe the global configure -function prober.global(configs) +function prober.global() -- probe the xcode application directory - if not prober._probe_xcode(configs) then return end + if not prober._probe_xcode() then return end -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end diff --git a/xmake/scripts/platform/iphonesimulator/prober.lua b/xmake/scripts/platform/iphonesimulator/prober.lua index b23490169..89e6fb846 100644 --- a/xmake/scripts/platform/iphonesimulator/prober.lua +++ b/xmake/scripts/platform/iphonesimulator/prober.lua @@ -26,31 +26,33 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") local tools = require("tools/tools") +local config = require("base/config") +local global = require("base/global") -- define module: prober local prober = prober or {} -- probe the architecture -function prober._probe_arch(configs) +function prober._probe_arch() -- get the architecture - local arch = configs.arch + local arch = config.get("arch") -- ok? if arch then return true end -- init the default architecture - configs.arch = "x86" + config.set("arch", "x86") -- ok return true end -- probe the xcode application directory -function prober._probe_xcode(configs) +function prober._probe_xcode() -- get the xcode directory - local xcode_dir = configs.xcode_dir + local xcode_dir = config.get("xcode_dir") -- ok? if xcode_dir then return true end @@ -75,7 +77,7 @@ function prober._probe_xcode(configs) -- probe ok? update it if xcode_dir then - configs.xcode_dir = xcode_dir + config.set("xcode_dir", xcode_dir) else -- failed utils.error("The Xcode directory is unknown now, please config it first!") @@ -89,10 +91,10 @@ function prober._probe_xcode(configs) end -- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) +function prober._probe_xcode_sdkver() -- get the xcode sdk version - local xcode_sdkver = configs.xcode_sdkver + local xcode_sdkver = config.get("xcode_sdkver") -- ok? if xcode_sdkver then return true end @@ -102,7 +104,7 @@ function prober._probe_xcode_sdkver(configs) -- attempt to match the directory if not xcode_sdkver then - local dirs = os.match(configs.xcode_dir .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk", true) + local dirs = os.match(config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk", true) if dirs then for _, dir in ipairs(dirs) do xcode_sdkver = string.match(dir, "%d+%.%d+") @@ -113,7 +115,7 @@ function prober._probe_xcode_sdkver(configs) -- probe ok? update it if xcode_sdkver then - configs.xcode_sdkver = xcode_sdkver + config.set("xcode_sdkver", xcode_sdkver) else -- failed utils.error("The Xcode SDK version is unknown now, please config it first!") @@ -127,14 +129,15 @@ function prober._probe_xcode_sdkver(configs) end -- probe the ccache -function prober._probe_ccache(configs) +function prober._probe_ccache() -- ok? - if configs.ccache and configs.__ccache then return true end + local ccache_enable = config.get("ccache") + if ccache_enable and config.get("__ccache") then return true end -- disable? - if type(configs.ccache) == "boolean" and not configs.ccache then - configs.__ccache = nil + if type(ccache_enable) == "boolean" and not ccache_enable then + config.set("__ccache", nil) return true end @@ -143,10 +146,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = true - configs.__ccache = ccache_path + config.set("ccache", true) + config.set("__ccache", ccache_path) else - configs.ccache = false + config.set("ccache", false) end -- ok @@ -154,27 +157,27 @@ function prober._probe_ccache(configs) end -- probe the project configure -function prober.config(configs) +function prober.config() -- probe the architecture - if not prober._probe_arch(configs) then return end + if not prober._probe_arch() then return end -- probe the xcode application directory - if not prober._probe_xcode(configs) then return end + if not prober._probe_xcode() then return end -- probe the xcode sdk version - if not prober._probe_xcode_sdkver(configs) then return end + if not prober._probe_xcode_sdkver() then return end end -- probe the global configure -function prober.global(configs) +function prober.global() -- probe the xcode application directory - if not prober._probe_xcode(configs) then return end + if not prober._probe_xcode() then return end -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end diff --git a/xmake/scripts/platform/linux/prober.lua b/xmake/scripts/platform/linux/prober.lua index 5916a39bb..f6e6ff5de 100644 --- a/xmake/scripts/platform/linux/prober.lua +++ b/xmake/scripts/platform/linux/prober.lua @@ -26,35 +26,38 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") local tools = require("tools/tools") +local config = require("base/config") +local global = require("base/global") -- define module: prober local prober = prober or {} -- probe the architecture -function prober._probe_arch(configs) +function prober._probe_arch() -- get the architecture - local arch = configs.arch + local arch = config.get("arch") -- ok? if arch then return true end -- init the default architecture - configs.arch = xmake._ARCH + config.set("arch", xmake._ARCH) -- ok return true end -- probe the ccache -function prober._probe_ccache(configs) +function prober._probe_ccache() -- ok? - if configs.ccache and configs.__ccache then return true end + local ccache_enable = config.get("ccache") + if ccache_enable and config.get("__ccache") then return true end -- disable? - if type(configs.ccache) == "boolean" and not configs.ccache then - configs.__ccache = nil + if type(ccache_enable) == "boolean" and not ccache_enable then + config.set("__ccache", nil) return true end @@ -63,10 +66,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = true - configs.__ccache = ccache_path + config.set("ccache", true) + config.set("__ccache", ccache_path) else - configs.ccache = false + config.set("ccache", false) end -- ok @@ -74,21 +77,21 @@ function prober._probe_ccache(configs) end -- probe the project configure -function prober.config(configs) +function prober.config() -- probe the architecture - if not prober._probe_arch(configs) then return end + if not prober._probe_arch() then return end -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end -- probe the global configure -function prober.global(configs) +function prober.global() -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end diff --git a/xmake/scripts/platform/macosx/prober.lua b/xmake/scripts/platform/macosx/prober.lua index 1acc015ff..9a2298a71 100644 --- a/xmake/scripts/platform/macosx/prober.lua +++ b/xmake/scripts/platform/macosx/prober.lua @@ -26,31 +26,33 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") local tools = require("tools/tools") +local config = require("base/config") +local global = require("base/global") -- define module: prober local prober = prober or {} -- probe the architecture -function prober._probe_arch(configs) +function prober._probe_arch() -- get the architecture - local arch = configs.arch + local arch = config.get("arch") -- ok? if arch then return true end -- init the default architecture - configs.arch = xmake._ARCH + config.set("arch", xmake._ARCH) -- ok return true end -- probe the xcode application directory -function prober._probe_xcode(configs) +function prober._probe_xcode() -- get the xcode directory - local xcode_dir = configs.xcode_dir + local xcode_dir = config.get("xcode_dir") -- ok? if xcode_dir then return true end @@ -75,7 +77,7 @@ function prober._probe_xcode(configs) -- probe ok? update it if xcode_dir then - configs.xcode_dir = xcode_dir + config.set("xcode_dir", xcode_dir) else -- failed utils.error("The Xcode directory is unknown now, please config it first!") @@ -89,10 +91,10 @@ function prober._probe_xcode(configs) end -- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) +function prober._probe_xcode_sdkver() -- get the xcode sdk version - local xcode_sdkver = configs.xcode_sdkver + local xcode_sdkver = config.get("xcode_sdkver") -- ok? if xcode_sdkver then return true end @@ -102,7 +104,7 @@ function prober._probe_xcode_sdkver(configs) -- attempt to match the directory if not xcode_sdkver then - local dirs = os.match(configs.xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk", true) + local dirs = os.match(config.get("xcode_dir") .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk", true) if dirs then for _, dir in ipairs(dirs) do xcode_sdkver = string.match(dir, "%d+%.%d+") @@ -113,7 +115,7 @@ function prober._probe_xcode_sdkver(configs) -- probe ok? update it if xcode_sdkver then - configs.xcode_sdkver = xcode_sdkver + config.set("xcode_sdkver", xcode_sdkver) else -- failed utils.error("The Xcode SDK version is unknown now, please config it first!") @@ -127,14 +129,15 @@ function prober._probe_xcode_sdkver(configs) end -- probe the ccache -function prober._probe_ccache(configs) +function prober._probe_ccache() -- ok? - if configs.ccache and configs.__ccache then return true end + local ccache_enable = config.get("ccache") + if ccache_enable and config.get("__ccache") then return true end -- disable? - if type(configs.ccache) == "boolean" and not configs.ccache then - configs.__ccache = nil + if type(ccache_enable) == "boolean" and not ccache_enable then + config.set("__ccache", nil) return true end @@ -143,10 +146,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = true - configs.__ccache = ccache_path + config.set("ccache", true) + config.set("__ccache", ccache_path) else - configs.ccache = false + config.set("ccache", false) end -- ok @@ -154,30 +157,30 @@ function prober._probe_ccache(configs) end -- probe the project configure -function prober.config(configs) +function prober.config() -- probe the architecture - if not prober._probe_arch(configs) then return end + if not prober._probe_arch() then return end -- probe the xcode application directory - if not prober._probe_xcode(configs) then return end + if not prober._probe_xcode() then return end -- probe the xcode sdk version - if not prober._probe_xcode_sdkver(configs) then return end + if not prober._probe_xcode_sdkver() then return end -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end -- probe the global configure -function prober.global(configs) +function prober.global() -- probe the xcode application directory - if not prober._probe_xcode(configs) then return end + if not prober._probe_xcode() then return end -- probe the ccache - if not prober._probe_ccache(configs) then return end + if not prober._probe_ccache() then return end end diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua index 35ce7f9f1..07981c40a 100644 --- a/xmake/scripts/platform/platform.lua +++ b/xmake/scripts/platform/platform.lua @@ -336,7 +336,7 @@ function platform.menu(action) end -- probe the platform configure -function platform.probe(configs, is_global) +function platform.probe(is_global) -- probe global if is_global then @@ -349,7 +349,7 @@ function platform.probe(configs, is_global) for _, plat in ipairs(plats) do local module = platform._load(plat) if module and module._PROBER and module._PROBER.global and module._HOST and module._HOST == xmake._HOST then - module._PROBER.global(configs) + module._PROBER.global() end end @@ -358,7 +358,7 @@ function platform.probe(configs, is_global) -- probe it local module = platform.module() if module and module._PROBER and module._PROBER.config then - module._PROBER.config(configs) + module._PROBER.config() end end end diff --git a/xmake/scripts/platform/windows/prober.lua b/xmake/scripts/platform/windows/prober.lua index c730ad9f1..26968b0c8 100644 --- a/xmake/scripts/platform/windows/prober.lua +++ b/xmake/scripts/platform/windows/prober.lua @@ -25,31 +25,33 @@ local os = require("base/os") local path = require("base/path") local utils = require("base/utils") local string = require("base/string") +local config = require("base/config") +local global = require("base/global") -- define module: prober local prober = prober or {} -- probe the architecture -function prober._probe_arch(configs) +function prober._probe_arch() -- get the architecture - local arch = configs.arch + local arch = config.get("arch") -- ok? if arch then return true end -- init the default architecture - configs.arch = xmake._ARCH + config.set("arch", xmake._ARCH) -- ok return true end -- probe the vs version -function prober._probe_vs_version(configs) +function prober._probe_vs_version() -- get the vs version - local vs = configs.vs + local vs = config.get("vs") -- ok? if vs then return true end @@ -84,7 +86,7 @@ function prober._probe_vs_version(configs) -- probe ok? update it if vs then - configs.vs = vs + config.set("vs", vs) else -- failed utils.error("The Microsoft Visual Studio is unknown now, please config it first!") @@ -98,13 +100,13 @@ function prober._probe_vs_version(configs) end -- probe the vs path -function prober._probe_vs_path(configs) +function prober._probe_vs_path() -- ok? - if configs.__vsenv_path then return true end + if config.get("__vsenv_path") then return true end -- get the vs version - local vs = configs.vs + local vs = config.get("vs") assert(vs) -- make the map table @@ -178,7 +180,7 @@ function prober._probe_vs_path(configs) -- save the variables for k, v in pairs(variables) do - configs["__vsenv_" .. k] = v + config.set("__vsenv_" .. k, v) end -- ok @@ -186,27 +188,27 @@ function prober._probe_vs_path(configs) end -- probe the project configure -function prober.config(configs) +function prober.config() -- probe the architecture - if not prober._probe_arch(configs) then return end + if not prober._probe_arch() then return end -- probe the vs version - if not prober._probe_vs_version(configs) then return end + if not prober._probe_vs_version() then return end -- probe the vs path - if not prober._probe_vs_path(configs) then return end + if not prober._probe_vs_path() then return end end -- probe the global configure -function prober.global(configs) +function prober.global() -- probe the vs version - if not prober._probe_vs_version(configs) then return end + if not prober._probe_vs_version() then return end -- probe the vs path - if not prober._probe_vs_path(configs) then return end + if not prober._probe_vs_path() then return end end |
