From 9f1d3468c22adabab1ad06cdb0014c4f6ef2caa6 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 4 Jun 2015 12:01:02 +0800 Subject: find the given tool from name --- xmake/scripts/platform/platform.lua | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'xmake/scripts/platform/platform.lua') diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua index 120a03f84..718587c84 100644 --- a/xmake/scripts/platform/platform.lua +++ b/xmake/scripts/platform/platform.lua @@ -36,11 +36,11 @@ local compiler = require("compiler/compiler") function platform._load_prober(root) -- the platform file path - local file = string.format("%s/prober.lua", root) - if os.isfile(file) then + local filepath = string.format("%s/prober.lua", root) + if os.isfile(filepath) then -- load script - local script = loadfile(file) + local script = loadfile(filepath) if script then -- load prober @@ -58,11 +58,11 @@ end function platform._load_from(root, plat) -- the platform file path - local file = string.format("%s/platform/%s/%s.lua", root, plat, plat) - if os.isfile(file) then + local filepath = string.format("%s/platform/%s/%s.lua", root, plat, plat) + if os.isfile(filepath) then -- load script - local script = loadfile(file) + local script = loadfile(filepath) if script then -- load module @@ -70,7 +70,7 @@ function platform._load_from(root, plat) if module then -- save directory - module._DIRECTORY = path.directory(file) + module._DIRECTORY = path.directory(filepath) assert(module._DIRECTORY) -- attempt to load prober @@ -139,6 +139,23 @@ function platform._configs(plat) return configs end +-- get the current platform module +function platform.module() + + -- load it + return platform._load(config.get("plat")) +end + +-- get the current platform module directory +function platform.directory() + + -- load it + local module = platform.module() + if module then + return module._DIRECTORY + end +end + -- make the current platform configure function platform.make() @@ -374,7 +391,7 @@ function platform.probe(configs, is_global) -- probe config else -- probe it - local module = platform._load(config.get("plat")) + local module = platform.module() if module and module._PROBER and module._PROBER.done then module._PROBER.done(configs, is_global) end @@ -385,7 +402,7 @@ end function platform.build(mkfile, target) -- attempt to done the platform special make first - local module = platform._load(config.get("plat")) + local module = platform.module() if module and module._MAKER and module._MAKER.done then return module._MAKER.done(mkfile, target) end -- cgit v1.3.1