Skip to content

Commit

Permalink
fix(rocks): only build rockspec when it has deps or an advanced build…
Browse files Browse the repository at this point in the history
… step
  • Loading branch information
folke committed Jun 24, 2024
1 parent dbffad6 commit 9a6c219
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lua/lazy/pkg/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local Config = require("lazy.core.config")
local Util = require("lazy.util")

local M = {}
M.VERSION = 8
M.VERSION = 10
M.dirty = false

---@class LazyPkg
Expand Down
43 changes: 29 additions & 14 deletions lua/lazy/pkg/rockspec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ M.skip = { "lua" }
---@field package string
---@field version string
---@field dependencies string[]
---@field build? {build_type?: string, modules?: any[]}

---@param plugin LazyPlugin
---@return LazyPkgSpec?
Expand All @@ -37,30 +38,44 @@ function M.get(plugin)
end
load()

if not rockspec then
return
end

local has_lua = not not vim.uv.fs_stat(plugin.dir .. "/lua")

---@param dep string
local rocks = vim.tbl_filter(function(dep)
local name = dep:gsub("%s.*", "")
return not vim.tbl_contains(M.skip, name)
end, rockspec and rockspec.dependencies or {})
end, rockspec.dependencies or {})

local use = #rocks > 0
use = true
local use = not has_lua
or #rocks > 0
or (
rockspec.build
and rockspec.build.build_type
and rockspec.build.build_type ~= "none"
and not (rockspec.build.build_type == "builtin" and not rockspec.build.modules)
)

if not use then
return
end

local lazy = nil
if not vim.uv.fs_stat(plugin.dir .. "/lua") then
if not has_lua then
lazy = false
end

return use
and {
file = vim.fn.fnamemodify(rockspec_file, ":t"),
spec = {
plugin.name,
build = "rockspec",
lazy = lazy,
},
}
or nil
return {
file = vim.fn.fnamemodify(rockspec_file, ":t"),
spec = {
plugin.name,
build = "rockspec",
lazy = lazy,
},
} or nil
end

return M

0 comments on commit 9a6c219

Please sign in to comment.