summaryrefslogtreecommitdiff
path: root/xmake/core/project/target.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-03 22:26:07 +0800
committerruki <[email protected]>2025-12-03 22:26:07 +0800
commit4f5dcfa9e413ebaa3709098bee5c1fbc91cda231 (patch)
tree8b4150640ea8312b46c3e9a979fc2389e9354b72 /xmake/core/project/target.lua
parent605ce1f6bcfa8bcbe1a1f8151361f2539fb09727 (diff)
mark target/package/toolchain:memcache as public
Diffstat (limited to 'xmake/core/project/target.lua')
-rw-r--r--xmake/core/project/target.lua48
1 files changed, 24 insertions, 24 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 40af6a2b4..b3b318e26 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -64,7 +64,7 @@ function _instance.new(name, info)
end
-- get memcache
-function _instance:_memcache()
+function _instance:memcache()
local cache = self._MEMCACHE
if not cache then
cache = memcache.cache("core.project.target." .. tostring(self))
@@ -232,7 +232,7 @@ end
function _instance:_invalidate(name)
self._CACHEID = self._CACHEID + 1
self._POLICIES = nil
- self:_memcache():clear()
+ self:memcache():clear()
-- we need to flush the source files cache if target/files are modified, e.g. `target:add("files", "xxx.c")`
if name == "files" then
self._SOURCEFILES = nil
@@ -1074,28 +1074,28 @@ function _instance:compiler(sourcekind)
if not sourcekind then
os.raise("please pass sourcekind to the first argument of target:compiler(), e.g. cc, cxx, as")
end
- local compilerinst = self:_memcache():get("compiler_" .. sourcekind)
+ local compilerinst = self:memcache():get("compiler_" .. sourcekind)
if not compilerinst then
local instance, errors = compiler.load(sourcekind, self)
if not instance then
os.raise(errors)
end
compilerinst = instance
- self:_memcache():set("compiler_" .. sourcekind, compilerinst)
+ self:memcache():set("compiler_" .. sourcekind, compilerinst)
end
return compilerinst
end
-- get the target linker
function _instance:linker()
- local linkerinst = self:_memcache():get("linker")
+ local linkerinst = self:memcache():get("linker")
if not linkerinst then
local instance, errors = linker.load(self:kind(), self:sourcekinds(), self)
if not instance then
os.raise(errors)
end
linkerinst = instance
- self:_memcache():set("linker", linkerinst)
+ self:memcache():set("linker", linkerinst)
end
return linkerinst
end
@@ -1282,13 +1282,13 @@ function _instance:opts(opt)
elseif opt.interface then
cachekey = cachekey .. "_interface"
end
- local opts = self:_memcache():get(cachekey)
+ local opts = self:memcache():get(cachekey)
if not opts then
opts = {}
for _, opt_ in ipairs(self:orderopts(opt)) do
opts[opt_:name()] = opt_
end
- self:_memcache():set(cachekey, opts)
+ self:memcache():set(cachekey, opts)
end
return opts
end
@@ -1302,7 +1302,7 @@ function _instance:orderopts(opt)
elseif opt.interface then
cachekey = cachekey .. "_interface"
end
- local orderopts = self:_memcache():get(cachekey)
+ local orderopts = self:memcache():get(cachekey)
if not orderopts then
orderopts = {}
for _, name in ipairs(table.wrap(self:get("options", opt))) do
@@ -1318,7 +1318,7 @@ function _instance:orderopts(opt)
table.insert(orderopts, opt_)
end
end
- self:_memcache():set(cachekey, orderopts)
+ self:memcache():set(cachekey, orderopts)
end
return orderopts
end
@@ -1337,13 +1337,13 @@ function _instance:pkgs(opt)
elseif opt.interface then
cachekey = cachekey .. "_interface"
end
- local packages = self:_memcache():get(cachekey)
+ local packages = self:memcache():get(cachekey)
if not packages then
packages = {}
for _, pkg in ipairs(self:orderpkgs(opt)) do
packages[pkg:name()] = pkg
end
- self:_memcache():set(cachekey, packages)
+ self:memcache():set(cachekey, packages)
end
return packages
end
@@ -1357,7 +1357,7 @@ function _instance:orderpkgs(opt)
elseif opt.interface then
cachekey = cachekey .. "_interface"
end
- local packages = self:_memcache():get(cachekey)
+ local packages = self:memcache():get(cachekey)
if not packages then
packages = {}
local requires = target._project().required_packages()
@@ -1380,7 +1380,7 @@ function _instance:orderpkgs(opt)
end
end
end
- self:_memcache():set(cachekey, packages)
+ self:memcache():set(cachekey, packages)
end
return packages
end
@@ -1850,7 +1850,7 @@ function _instance:filerules(sourcefile)
end
-- load all rules for this target with sourcekinds and extensions
- local key2rules = self:_memcache():get("key2rules")
+ local key2rules = self:memcache():get("key2rules")
if not key2rules then
key2rules = {}
for _, r in pairs(table.wrap(self:rules())) do
@@ -1868,7 +1868,7 @@ function _instance:filerules(sourcefile)
table.insert(key2rules[extension], r)
end
end
- self:_memcache():set("key2rules", key2rules)
+ self:memcache():set("key2rules", key2rules)
end
-- get target rules from the given sourcekind or extension
@@ -2513,7 +2513,7 @@ end
-- get runtimes
function _instance:runtimes()
- local runtimes = self:_memcache():get("runtimes")
+ local runtimes = self:memcache():get("runtimes")
if runtimes == nil then
runtimes = self:get("runtimes")
if runtimes then
@@ -2537,17 +2537,17 @@ function _instance:runtimes()
runtimes = table.unwrap(runtimes_current)
end
runtimes = runtimes or false
- self:_memcache():set("runtimes", runtimes)
+ self:memcache():set("runtimes", runtimes)
end
return runtimes or nil
end
-- has the given runtime for the current toolchains?
function _instance:has_runtime(...)
- local runtimes_set = self:_memcache():get("runtimes_set")
+ local runtimes_set = self:memcache():get("runtimes_set")
if runtimes_set == nil then
runtimes_set = hashset.from(table.wrap(self:runtimes()))
- self:_memcache():set("runtimes_set", runtimes_set)
+ self:memcache():set("runtimes_set", runtimes_set)
end
for _, v in ipairs(table.pack(...)) do
if runtimes_set:has(v) then
@@ -2558,20 +2558,20 @@ end
-- get the given toolchain
function _instance:toolchain(name)
- local toolchains_map = self:_memcache():get("toolchains_map")
+ local toolchains_map = self:memcache():get("toolchains_map")
if toolchains_map == nil then
toolchains_map = {}
for _, toolchain_inst in ipairs(self:toolchains()) do
toolchains_map[toolchain_inst:name()] = toolchain_inst
end
- self:_memcache():set("toolchains_map", toolchains_map)
+ self:memcache():set("toolchains_map", toolchains_map)
end
return toolchains_map[name]
end
-- get the toolchains
function _instance:toolchains()
- local toolchains = self:_memcache():get("toolchains")
+ local toolchains = self:memcache():get("toolchains")
if toolchains == nil then
-- load target toolchains first
@@ -2615,7 +2615,7 @@ function _instance:toolchains()
toolchains = self:platform():toolchains()
end
- self:_memcache():set("toolchains", toolchains)
+ self:memcache():set("toolchains", toolchains)
end
return toolchains
end