summaryrefslogtreecommitdiff
path: root/xmake/core/project
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-17 08:26:16 +0800
committerruki <[email protected]>2017-05-17 08:26:16 +0800
commit807c7db15fa3a5e640ecde32ede9e72c4d64391c (patch)
tree1ff7f32ba10ab23be15aff70167267996625c9f8 /xmake/core/project
parentc354c862526c9a149060639057bca380128a147a (diff)
improve find_program cache
Diffstat (limited to 'xmake/core/project')
-rw-r--r--xmake/core/project/cache.lua12
-rw-r--r--xmake/core/project/project.lua19
2 files changed, 25 insertions, 6 deletions
diff --git a/xmake/core/project/cache.lua b/xmake/core/project/cache.lua
index 1b3b63c7f..d96f12e00 100644
--- a/xmake/core/project/cache.lua
+++ b/xmake/core/project/cache.lua
@@ -56,6 +56,13 @@ function cache._instance(scopename)
-- init instance
local instance = table.inherit(cache)
+ -- memory cache?
+ if scopename:startswith("memory.") then
+ instance._CACHEDATA = instance._CACHEDATA or {__version = xmake._VERSION_SHORT}
+ instances[scopename] = instance
+ return instance
+ end
+
-- check scopename
if not scopename:find("local%.") and not scopename:find("global%.") then
os.raise("invalid cache scope: %s", scopename)
@@ -110,6 +117,11 @@ function cache:flush()
-- flush the version
self._CACHEDATA.__version = xmake._VERSION_SHORT
+ -- memory cache? ignore it directly
+ if not self._CACHEPATH then
+ return true
+ end
+
-- save to file
return io.save(self._CACHEPATH, self._CACHEDATA)
end
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 5fdc43636..6dff6d1a4 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -365,6 +365,13 @@ function project._load_target_deps(target, targets)
return table.unique(deptargets)
end
+-- get the project file
+function project.file()
+
+ -- get it
+ return xmake._PROJECT_FILE
+end
+
-- get the project directory
function project.directory()
@@ -420,7 +427,7 @@ function project.get(name)
assert(interp)
-- load infos
- infos = interp:load(xmake._PROJECT_FILE, nil, true, true)
+ infos = interp:load(project.file(), nil, true, true)
project._INFOS = infos
end
@@ -444,7 +451,7 @@ function project.load()
end
-- load targets
- local results, errors = interp:load(xmake._PROJECT_FILE, "target", true, true)
+ local results, errors = interp:load(project.file(), "target", true, true)
if not results then
return false, errors
end
@@ -505,7 +512,7 @@ function project.options(enable_filter)
assert(interp)
-- load the options from the the project file
- local results, errors = interp:load(xmake._PROJECT_FILE, "option", true, enable_filter)
+ local results, errors = interp:load(project.file(), "option", true, enable_filter)
if not results then
return nil, errors
end
@@ -538,12 +545,12 @@ function project.tasks()
assert(interp)
-- the project file is not found?
- if not os.isfile(xmake._PROJECT_FILE) then
+ if not os.isfile(project.file()) then
return {}, nil
end
-- load the tasks from the the project file
- local results, errors = interp:load(xmake._PROJECT_FILE, "task", true, true)
+ local results, errors = interp:load(project.file(), "task", true, true)
if not results then
return nil, errors
end
@@ -569,7 +576,7 @@ function project.menu()
-- attempt to load options from the project file
local options = nil
local errors = nil
- if os.isfile(xmake._PROJECT_FILE) then
+ if os.isfile(project.file()) then
options, errors = project.options(false)
end