Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency caching and helper functions #5

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Dependencies/libpqxx/Libpqxx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ Solution.Util.CreateStaticLib(dep.Name, Solution.Projects.Current.BinDir, dep.De
end)

Solution.Util.CreateDep(dep.NameLow, dep.Dependencies, function()
local baseDir = dep.Path .. "/Libpqxx"
local _, _, foundLibs = getPostgresInfo()
Solution.Util.SetIncludes({baseDir .. "/include"})
local foundLibs = Solution.Util.GetDepCache(dep.NameLow, "cache")
if not foundLibs then
local _, _, foundLibs = getPostgresInfo()
Solution.Util.SetDepCache(dep.NameLow, "cache", foundLibs)
end

Solution.Util.SetIncludes({dep.Path .. "/Libpqxx/include"})
Solution.Util.SetLinks({ dep.Name, foundLibs })
end)
35 changes: 34 additions & 1 deletion Premake/ProjectUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,32 @@ 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
Solution.Util.SetDepCache = function(depName, key, data)
local dep = Solution.Util.GetDepTable(depName)
dep.Cache[key] = data
end

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

return nil
end

Solution.Util.IncludeSubmodule = function(name, rootDir, binDir)
local submoduleRootDir = path.getabsolute("Submodules/".. name .. "/", rootDir)
local submoduleBuildDir = path.getabsolute("Build/".. name .. "/", rootDir)
Expand Down Expand Up @@ -295,7 +321,8 @@ Solution.Util.CreateDep = function(name, dependencies, callback)
local dependencyTable =
{
Callback = callback,
Dependencies = dependencies
Dependencies = dependencies,
Cache = {}
}

_G[internalName] = dependencyTable
Expand Down Expand Up @@ -406,6 +433,12 @@ Solution.Util.ClearFilter = function()
filter { }
end

Solution.Util.MergeIntoTable = function(t, x)
for _, v in pairs(x) do
table.insert(t, v)
end
end

if InitBuildSettings == nil then
function InitBuildSettings(silentFailOnDuplicateSetting)
if BuildSettings == nil then
Expand Down
2 changes: 1 addition & 1 deletion Submodules/Engine