diff options
| author | ruki <[email protected]> | 2016-04-09 20:11:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-04-09 20:11:34 +0800 |
| commit | 71296f55db2d5b0a9249592c3428797708cd0683 (patch) | |
| tree | 4e214293f83204be13d9e8e9bbeda78557fe781b | |
| parent | a684950c450b7490f3a95c2200cd1943a30a4272 (diff) | |
remove instace:interfaces for cache module
| -rwxr-xr-x | xmake/actions/config/main.lua | 7 | ||||
| -rw-r--r-- | xmake/core/project/cache.lua | 5 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import.lua | 13 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/cache.lua | 61 | ||||
| -rwxr-xr-x | xmake/tools/gcc.lua | 23 |
5 files changed, 89 insertions, 20 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index ec4334196..1c5311cf2 100755 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -26,7 +26,7 @@ import("core.project.config") import("core.project.global") import("core.project.project") import("core.platform.platform") -import("core.project.cache", {instance = "local.build"}) +import("core.project.cache") import("config_h") import("makefile") @@ -110,8 +110,9 @@ function main() end -- need rebuild it - cache:set("rebuild", true) - cache:flush() + cache.enter("local.build") + cache.set("rebuild", true) + cache.flush() -- save the project configure config.save(targetname) diff --git a/xmake/core/project/cache.lua b/xmake/core/project/cache.lua index 78eb6a188..9a7491aed 100644 --- a/xmake/core/project/cache.lua +++ b/xmake/core/project/cache.lua @@ -101,10 +101,7 @@ end function cache:flush() -- save to file - local ok, errors = io.save(self._CACHEPATH, self._CACHEDATA) - if not ok then - os.raise(errors) - end + return io.save(self._CACHEPATH, self._CACHEDATA) end -- return module diff --git a/xmake/core/sandbox/modules/import.lua b/xmake/core/sandbox/modules/import.lua index 9be583544..2b423613c 100644 --- a/xmake/core/sandbox/modules/import.lua +++ b/xmake/core/sandbox/modules/import.lua @@ -83,7 +83,7 @@ function sandbox_import._loadfile(filepath, instance) -- only export new public functions local result = {} for k, v in pairs(scope_public) do - if type(v) == "function" and scope_backup[k] == nil then + if type(v) == "function" and not k:startswith("_") and scope_backup[k] == nil then result[k] = v end end @@ -233,9 +233,6 @@ end -- => core -- => core.platform -- --- import("core.project.cache", {instance = "local.build"}) --- => cache == cache("local.build") --- function sandbox_import.import(name, args) -- check @@ -268,14 +265,6 @@ function sandbox_import.import(name, args) raise("cannot import module: %s, %s", name, errors) end - -- init module instance - if args.instance and type(module) == "function" then - module = module(args.instance) - if not module then - raise("cannot construct module: %s, %s", name, errors) - end - end - -- get module name local modulename = sandbox_import._modulename(name) if not modulename then diff --git a/xmake/core/sandbox/modules/import/core/project/cache.lua b/xmake/core/sandbox/modules/import/core/project/cache.lua index b13129750..bdff5d17b 100644 --- a/xmake/core/sandbox/modules/import/core/project/cache.lua +++ b/xmake/core/sandbox/modules/import/core/project/cache.lua @@ -20,5 +20,64 @@ -- @file cache.lua -- +-- define module +local sandbox_core_project_cache = {} + +-- load modules +local cache = require("project/cache") +local raise = require("sandbox/modules/raise") +local instance = nil + +-- enter the cache scope +function sandbox_core_project_cache.enter(scopename) + + -- get the cache instance + instance = cache(scopename) +end + +-- get the value +function sandbox_core_project_cache.get(name) + + -- check + assert(instance) + + -- get it + return instance:get(name) +end + +-- set the value +function sandbox_core_project_cache.set(name, value) + + -- check + assert(instance) + + -- set it + instance:set(name, value) +end + +-- clear all +function sandbox_core_project_cache:clear() + + -- check + assert(instance) + + -- clear it + instance:clear() +end + +-- flush to sandbox_core_project_cache file +function sandbox_core_project_cache:flush() + + -- check + assert(instance) + + -- flush it + local ok, errors = instance:flush() + if not ok then + raise(errors) + end +end + -- return module -return require("project/cache") +return sandbox_core_project_cache + diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua new file mode 100755 index 000000000..c1e1b9622 --- /dev/null +++ b/xmake/tools/gcc.lua @@ -0,0 +1,23 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file gcc.lua +-- + + |
