summaryrefslogtreecommitdiff
path: root/xmake/core/platform/platform.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-04-23 20:02:18 +0800
committerruki <[email protected]>2016-04-23 20:02:18 +0800
commit48a228f6bb2e4870bf0e4952c0c752ddeae72219 (patch)
tree933c64e6834ef2d5a05ebd52eaffb210737b9033 /xmake/core/platform/platform.lua
parent31e930871e159dc022ddd1f7a326fcc120e2fb00 (diff)
add iphoneos platform
Diffstat (limited to 'xmake/core/platform/platform.lua')
-rw-r--r--xmake/core/platform/platform.lua67
1 files changed, 62 insertions, 5 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index c17509558..66593b678 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -35,14 +35,15 @@ local config = require("project/config")
local global = require("project/global")
-- new an instance
-function _instance.new(name, info)
+function _instance.new(name, info, rootdir)
-- new an instance
local instance = table.inherit(_instance)
- -- save name and info
- instance._NAME = name
- instance._INFO = info
+ -- init instance
+ instance._NAME = name
+ instance._INFO = info
+ instance._ROOTDIR = rootdir
-- ok
return instance
@@ -76,6 +77,59 @@ function _instance:archs()
return self._INFO.archs
end
+-- get the checker
+function _instance:checker()
+
+ -- return it directly if cached
+ if self._CHECKER then
+ return self._CHECKER
+ end
+
+ -- get checker
+ if not self._INFO.checker then
+ return nil, string.format("the checker of %s not found!", self._NAME)
+ end
+
+ -- get the script path
+ local scriptpath = path.join(self._ROOTDIR, self._INFO.checker .. ".lua")
+
+ -- not exists?
+ if not scriptpath or not os.isfile(scriptpath) then
+ return nil, string.format("the checker of %s not found!", self._NAME)
+ end
+
+ -- load script
+ local script, errors = loadfile(scriptpath)
+ if script then
+
+ -- make sandbox instance with the given script
+ local instance, errors = sandbox.new(script, nil, self._ROOTDIR)
+ if not instance then
+ return nil, errors
+ end
+
+ -- import the module
+ local module, errors = instance:import()
+ if not module then
+ return nil, errors
+ end
+
+ -- init the module
+ if module.init then
+ module.init()
+ end
+
+ -- save tool to the cache
+ self._CHECKER = module
+
+ -- ok?
+ return module
+ end
+
+ -- failed
+ return nil, errors
+end
+
-- get the platform configure
function _instance:get(name)
@@ -138,6 +192,9 @@ function platform._interpreter()
-- register api: set_platform_menu()
interp:api_register_set_values("platform", "platform", "menu")
+ -- register api: set_platform_checker()
+ interp:api_register_set_values("platform", "platform", "checker")
+
-- register api: on_platform_load()
interp:api_register_on_script("platform", "platform", "load")
@@ -191,7 +248,7 @@ function platform.load(plat)
end
-- new an instance
- local instance, errors = _instance.new(plat, results[plat])
+ local instance, errors = _instance.new(plat, results[plat], platform._interpreter():rootdir())
if not instance then
return nil, errors
end