Skip to content

Commit

Permalink
Dependency order fixes and faster runner builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Foereaper committed Aug 12, 2024
1 parent 8553d1f commit 88f8ac0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
- name: Build
run: |
cd Build
make -j 4 -k
make -j$(nproc) -k
50 changes: 35 additions & 15 deletions Premake/ProjectUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,40 @@ Solution.Util.CreateProject = function(name, projectType, binDir, dependencies,
-- Default Args here --
dependencies = dependencies or {}

local dependencyNameToIndex = { }
local resolvedDependencies = { }
local needToResolve = true

for _, v in pairs(dependencies) do
for _, v in ipairs(dependencies) do
projectTable.deps[v] =
{
deps = {}
}

resolvedDependencies[v] =
local resolvedDep =
{
name = v,
mustComeAfter = 0,
parent = projectTable.deps[v]
}

local depIndex = #resolvedDependencies + 1
table.insert(resolvedDependencies, resolvedDep)
dependencyNameToIndex[v] = depIndex
end

local numResolvedDependencies = 1
while needToResolve do
local numAddedDependencies = 0

for k, v in pairs(resolvedDependencies) do
local depInternalName = "Dependency-" .. k
local numDependenciesToResolve = #resolvedDependencies

for i = numResolvedDependencies, numDependenciesToResolve, 1 do
local v = resolvedDependencies[i]
local depInternalName = "Dependency-" .. v.name

local dep = _G[depInternalName]
if (dep == nil) then
Solution.Util.PrintError("'" .. name .. "' use undeclared dependency '" .. k .. "'")
Solution.Util.PrintError("'" .. name .. "' use undeclared dependency '" .. v.name .. "'")
end

if dep.Dependencies then
Expand All @@ -158,27 +168,41 @@ Solution.Util.CreateProject = function(name, projectType, binDir, dependencies,
end

if deps then
for _, newDep in pairs(deps) do
if not resolvedDependencies[newDep] then
for _, newDep in ipairs(deps) do
if not dependencyNameToIndex[newDep] then
v.parent.deps[newDep] =
{
deps = {}
}

resolvedDependencies[newDep] =
local resolvedDep =
{
name = newDep,
mustComeAfter = dependencyNameToIndex[v.name],
parent = v.parent.deps[newDep]
}

local depIndex = #resolvedDependencies + 1
table.insert(resolvedDependencies, resolvedDep)
dependencyNameToIndex[newDep] = depIndex

numAddedDependencies = numAddedDependencies + 1
else
local depIndex = dependencyNameToIndex[newDep]
resolvedDependencies[depIndex].mustComeAfter = dependencyNameToIndex[v.name]
end
end
end
end
end

numDependenciesToResolve = numResolvedDependencies
needToResolve = numAddedDependencies > 0
end

table.sort(resolvedDependencies, function(a, b)
return a.mustComeAfter < b.mustComeAfter
end)

project (name)
kind (projectType)
Expand Down Expand Up @@ -211,8 +235,8 @@ Solution.Util.CreateProject = function(name, projectType, binDir, dependencies,

filter { }

for k, v in pairs(resolvedDependencies) do
local depInternalName = "Dependency-" .. k
for _, v in ipairs(resolvedDependencies) do
local depInternalName = "Dependency-" .. v.name
if (_G[depInternalName].Callback ~= nil) then
_G[depInternalName].Callback()
filter {}
Expand All @@ -234,10 +258,6 @@ Solution.Util.CreateProject = function(name, projectType, binDir, dependencies,
end
end

-- START TEST ONLY START --
--DumpObject(projectTable)
-- END TEST ONLY END ---

_G[internalName] = projectTable

if callback then
Expand Down

0 comments on commit 88f8ac0

Please sign in to comment.