Skip to content

Commit

Permalink
improve prober
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 1, 2015
1 parent e88ecbf commit e56812a
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 86 deletions.
4 changes: 3 additions & 1 deletion xmake/scripts/action/_global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ end
function _global.done()

-- probe the global platform configure
platform.probe(true)
if not platform.probe(true) then
return false
end

-- clear up the global configure
global.clearup()
Expand Down
4 changes: 3 additions & 1 deletion xmake/scripts/action/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ function action.done(name)

-- probe the platform
if _action.need("platform") and (options._ACTION == "config" or config._RECONFIG) then
platform.probe(false)
if not platform.probe(false) then
return false
end
end

-- merge the default options
Expand Down
7 changes: 5 additions & 2 deletions xmake/scripts/base/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,13 @@ function utils.call(funcs, pred, ...)

-- exists predicate?
if pred and type(pred) == "function" then
if not pred(name, result) then break end
if not pred(name, result) then return false end
-- failed?
elseif not result then break end
elseif not result then return false end
end

-- ok
return true
end

-- return module: utils
Expand Down
34 changes: 22 additions & 12 deletions xmake/scripts/platform/android/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ function prober._probe_toolpath(configs, kind, cross, name, description)
utils.verbose("checking for %s (%s) ... no", description, kind)
end

-- failed?
if not toolpath and not configs.get("ndk") then
utils.error("checking for the NDK directory ... no")
utils.error(" - xmake config --ndk=xxx")
utils.error("or - xmake global --ndk=xxx")
return false
end

-- ok
return true
end
Expand All @@ -226,32 +234,34 @@ function prober._probe_toolchains(configs)
if not prober._probe_toolpath(configs, "ld", prefix, "g++", "the linker") then return false end
if not prober._probe_toolpath(configs, "ar", prefix, "ar", "the static library linker") then return false end
if not prober._probe_toolpath(configs, "sh", prefix, "g++", "the shared library linker") then return false end

-- ok
return true
end

-- probe the project configure
function prober.config()

-- call all probe functions
utils.call( { prober._probe_arch
, prober._probe_make
, prober._probe_ccache
, prober._probe_ndk_sdkver
, prober._probe_toolchains}
, nil
, config)
return utils.call( { prober._probe_arch
, prober._probe_make
, prober._probe_ccache
, prober._probe_ndk_sdkver
, prober._probe_toolchains}
, nil
, config)

end

-- probe the global configure
function prober.global()

-- call all probe functions
utils.call( { prober._probe_make
, prober._probe_ccache
, prober._probe_ndk_sdkver}
, nil
, global)
return utils.call( { prober._probe_make
, prober._probe_ccache
, prober._probe_ndk_sdkver}
, nil
, global)
end

-- return module: prober
Expand Down
26 changes: 13 additions & 13 deletions xmake/scripts/platform/iphoneos/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,26 +247,26 @@ end
function prober.config()

-- call all probe functions
utils.call( { prober._probe_arch
, prober._probe_xcode
, prober._probe_xcode_sdkver
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
return utils.call( { prober._probe_arch
, prober._probe_xcode
, prober._probe_xcode_sdkver
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)

end

-- probe the global configure
function prober.global()

-- call all probe functions
utils.call( { prober._probe_xcode
, prober._probe_make
, prober._probe_ccache}
, nil
, global)
return utils.call( { prober._probe_xcode
, prober._probe_make
, prober._probe_ccache}
, nil
, global)
end

-- return module: prober
Expand Down
26 changes: 13 additions & 13 deletions xmake/scripts/platform/iphonesimulator/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,25 +246,25 @@ end
function prober.config()

-- call all probe functions
utils.call( { prober._probe_arch
, prober._probe_xcode
, prober._probe_xcode_sdkver
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
return utils.call( { prober._probe_arch
, prober._probe_xcode
, prober._probe_xcode_sdkver
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
end

-- probe the global configure
function prober.global()

-- call all probe functions
utils.call( { prober._probe_xcode
, prober._probe_make
, prober._probe_ccache}
, nil
, global)
return utils.call( { prober._probe_xcode
, prober._probe_make
, prober._probe_ccache}
, nil
, global)
end

-- return module: prober
Expand Down
20 changes: 10 additions & 10 deletions xmake/scripts/platform/linux/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,22 @@ end
function prober.config()

-- call all probe functions
utils.call( { prober._probe_arch
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
return utils.call( { prober._probe_arch
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
end

-- probe the global configure
function prober.global()

-- call all probe functions
utils.call( { prober._probe_make
, prober._probe_ccache}
, nil
, global)
return utils.call( { prober._probe_make
, prober._probe_ccache}
, nil
, global)
end

-- return module: prober
Expand Down
24 changes: 12 additions & 12 deletions xmake/scripts/platform/macosx/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,24 @@ end
function prober.config()

-- call all probe functions
utils.call( { prober._probe_arch
, prober._probe_xcode
, prober._probe_xcode_sdkver
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
return utils.call( { prober._probe_arch
, prober._probe_xcode
, prober._probe_xcode_sdkver
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
end

-- probe the global configure
function prober.global()

-- call all probe functions
utils.call( { prober._probe_xcode
, prober._probe_ccache}
, nil
, global)
return utils.call( { prober._probe_xcode
, prober._probe_ccache}
, nil
, global)
end

-- return module: prober
Expand Down
20 changes: 10 additions & 10 deletions xmake/scripts/platform/mingw/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ end
function prober.config()

-- call all probe functions
utils.call( { prober._probe_arch
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
return utils.call( { prober._probe_arch
, prober._probe_make
, prober._probe_ccache
, prober._probe_toolchains}
, nil
, config)
end

-- probe the global configure
function prober.global()

-- call all probe functions
utils.call( { prober._probe_make
, prober._probe_ccache}
, nil
, global)
return utils.call( { prober._probe_make
, prober._probe_ccache}
, nil
, global)
end

-- return module: prober
Expand Down
7 changes: 5 additions & 2 deletions xmake/scripts/platform/platform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function platform.probe(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()
if not module._PROBER.global() then return false end
end
end

Expand All @@ -373,9 +373,12 @@ function platform.probe(is_global)
-- probe it
local module = platform.module()
if module and module._PROBER and module._PROBER.config then
module._PROBER.config()
if not module._PROBER.config() then return false end
end
end

-- ok
return true
end

-- return module: platform
Expand Down
20 changes: 10 additions & 10 deletions xmake/scripts/platform/windows/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,22 +251,22 @@ end
function prober.config()

-- call all probe functions
utils.call( { prober._probe_arch
, prober._probe_vs_version
, prober._probe_vs_path
, prober._probe_toolchains}
, nil
, config)
return utils.call( { prober._probe_arch
, prober._probe_vs_version
, prober._probe_vs_path
, prober._probe_toolchains}
, nil
, config)
end

-- probe the global configure
function prober.global()

-- call all probe functions
utils.call( { prober._probe_vs_version
, prober._probe_vs_path}
, nil
, global)
return utils.call( { prober._probe_vs_version
, prober._probe_vs_path}
, nil
, global)
end

-- return module: prober
Expand Down

0 comments on commit e56812a

Please sign in to comment.