function transform(context, matrix)
local result = {}
local function enables_cpal_asio(pkg_name, pkg, feature, os, visited)
if os ~= "windows" then
return false, nil
end
visited = visited or {}
local visit_key = pkg_name .. "/" .. feature
if visited[visit_key] then
return false, nil end
visited[visit_key] = true
local activated_deps = pkg:feature_activates_dependencies(feature)
for _, dep in ipairs(activated_deps) do
for _, dep_feature in ipairs(dep.features) do
if dep.name == "cpal" and dep_feature == "asio" then
return true, string.format("%s/%s -> cpal/asio", pkg_name, feature)
end
if context:is_workspace_member(dep.name) then
local dep_pkg = context:get_package(dep.name)
local enables, chain = enables_cpal_asio(dep.name, dep_pkg, dep_feature, os, visited)
if enables then
return true, string.format("%s/%s -> %s", pkg_name, feature, chain)
end
end
end
end
return false, nil
end
for _, entry in ipairs(matrix) do
local package = entry.package
local os = entry.os
if not package or not os then
table.insert(result, entry)
else
local pkg = context:get_package(package)
if not pkg then
table.insert(result, entry)
else
local features = entry.features
if features and type(features) == "table" then
local filtered_features = {}
local skipped_features = {}
for _, feature in ipairs(features) do
local enables, chain = enables_cpal_asio(package, pkg, feature, os)
if enables then
table.insert(skipped_features, { feature = feature, chain = chain })
else
table.insert(filtered_features, feature)
end
end
if #skipped_features > 0 then
for _, skipped in ipairs(skipped_features) do
context:warn(
string.format(
"Removing feature '%s' from %s on %s (dependency chain: %s)",
skipped.feature,
package,
os,
skipped.chain
)
)
end
end
if #filtered_features > 0 then
entry.features = filtered_features
table.insert(result, entry)
else
context:warn(
string.format("Removing entire entry for %s on %s (all features filtered)", package, os)
)
end
elseif entry.feature then
local feature = entry.feature
local enables, chain = enables_cpal_asio(package, pkg, feature, os)
if enables then
context:warn(
string.format("Skipping %s/%s on %s (dependency chain: %s)", package, feature, os, chain)
)
else
table.insert(result, entry)
end
else
table.insert(result, entry)
end
end
end
end
return result
end