From a0a1afad987a95e9b9ad30cbb62a7a4c8ea402e1 Mon Sep 17 00:00:00 2001 From: Foereaper Date: Fri, 16 Aug 2024 17:16:06 +0200 Subject: [PATCH] Add dependency caching and helper functions --- Dependencies/libpqxx/Libpqxx.lua | 10 ++++++--- Premake/ProjectUtil.lua | 35 +++++++++++++++++++++++++++++++- Submodules/Engine | 2 +- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Dependencies/libpqxx/Libpqxx.lua b/Dependencies/libpqxx/Libpqxx.lua index b196fe0..6d3a502 100644 --- a/Dependencies/libpqxx/Libpqxx.lua +++ b/Dependencies/libpqxx/Libpqxx.lua @@ -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) diff --git a/Premake/ProjectUtil.lua b/Premake/ProjectUtil.lua index 2bceaad..2de7063 100644 --- a/Premake/ProjectUtil.lua +++ b/Premake/ProjectUtil.lua @@ -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) @@ -295,7 +321,8 @@ Solution.Util.CreateDep = function(name, dependencies, callback) local dependencyTable = { Callback = callback, - Dependencies = dependencies + Dependencies = dependencies, + Cache = {} } _G[internalName] = dependencyTable @@ -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 diff --git a/Submodules/Engine b/Submodules/Engine index 88f8ac0..c301a87 160000 --- a/Submodules/Engine +++ b/Submodules/Engine @@ -1 +1 @@ -Subproject commit 88f8ac003ee22b1b7b0daf66b2051c6898d7786e +Subproject commit c301a87ff1a8ecdaa902d12494d6317a928bc665