diff options
| author | ruki <[email protected]> | 2018-12-28 22:31:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-12-28 09:08:02 +0800 |
| commit | 04aca8108118992c4962bff9862b34ff8d4384a1 (patch) | |
| tree | af02b9584427fb629142e1e85c9a02ee3cfab4c2 | |
| parent | b7fcf6c2262341a9a19579fc56349ff98711e809 (diff) | |
improve to load platform
| -rw-r--r-- | xmake/core/base/interpreter.lua | 15 | ||||
| -rw-r--r-- | xmake/core/platform/platform.lua | 23 |
2 files changed, 35 insertions, 3 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index d45640064..5e996057c 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -768,6 +768,21 @@ function interpreter:rootscope_set(scope_kind) self._PRIVATE._ROOTSCOPE = scope_kind end +-- get apis +function interpreter:apis(scope_kind) + + -- check + assert(self and self._PRIVATE) + + -- get apis from the given scope kind + if scope_kind and scope_kind ~= "__rootkind" then + local apis = self._PRIVATE._APIS + return apis and apis[scope_kind] or {} + else + return self._PRIVATE._ROOTAPIS or {} + end +end + -- register api -- -- interp:api_register(nil, "apiroot", function () end) diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index b281864bd..3e153c2f2 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -67,7 +67,7 @@ function _instance:add(name, ...) self._INFO[name] = table.unwrap(table.join(info, ...)) end --- get the platform configure +-- get the platform configuration function _instance:get(name) -- attempt to get the static configure value @@ -76,8 +76,8 @@ function _instance:get(name) return value end - -- lazy loading platform - if not self._LOADED then + -- lazy loading platform if get other configuration + if not self._LOADED and not self:_is_builtin_conf(name) then local on_load = self._INFO.load if on_load then local ok, errors = sandbox.load(on_load, self) @@ -135,6 +135,23 @@ function _instance:data_add(name, data) self._DATA[name] = table.unwrap(table.join(self._DATA[name] or {}, data)) end +-- is builtin configuration? +function _instance:_is_builtin_conf(name) + + local builtin_configs = self._BUILTIN_CONFIGS + if not builtin_configs then + builtin_configs = {} + for apiname, _ in pairs(platform._interpreter():apis("platform")) do + local pos = apiname:find('_', 1, true) + if pos then + builtin_configs[apiname:sub(pos + 1)] = true + end + end + self._BUILTIN_CONFIGS = builtin_configs + end + return builtin_configs[name] +end + -- the directories of platform function platform._directories() |
