Skip to content

Commit

Permalink
Add new helper function to retrieve dependency table
Browse files Browse the repository at this point in the history
This can then be used to retrieve cached values
  • Loading branch information
Foereaper committed Aug 15, 2024
1 parent 017bb90 commit 6c1774f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Premake/ProjectUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,23 @@ Solution.Util.CreateDepTable = function(name, dependencies)
return dependency
end

Solution.Util.GetDepTable = function(depName)
local depInternalName = "Dependency-" .. depName
local dep = _G[depInternalName]
if (dep == nil) then
Solution.Util.PrintError("Tried to fetch undeclared dependency '" .. depName .. "'")
end

return dep
end

-- Cache a value inside the dep table
function Solution.Util.SetDepCache(dep, key, data)
Solution.Util.SetDepCache = function(dep, key, data)
dep.Cache[key] = data
end

-- Retrieve a cached value from the dep table, or return nil if not cached
function Solution.Util.GetDepCache(dep, key)
Solution.Util.GetDepCache = function(dep, key)
if dep.Cache[key] then
return dep.Cache[key]
end
Expand Down

0 comments on commit 6c1774f

Please sign in to comment.