From 4cfcf9d8df1abd7cca9f2c3590402ada543df327 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 31 Oct 2023 21:28:45 -0300 Subject: feat: auto-add luarocks-build- build dependency (#1542) --- src/luarocks/rockspecs.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') diff --git a/src/luarocks/rockspecs.lua b/src/luarocks/rockspecs.lua index 94462951..c9e17530 100644 --- a/src/luarocks/rockspecs.lua +++ b/src/luarocks/rockspecs.lua @@ -8,6 +8,15 @@ local type_rockspec = require("luarocks.type.rockspec") local util = require("luarocks.util") local vers = require("luarocks.core.vers") +local vendored_build_type_set = { + ["builtin"] = true, + ["cmake"] = true, + ["command"] = true, + ["make"] = true, + ["module"] = true, -- compatibility alias + ["none"] = true, +} + local rockspec_mt = {} rockspec_mt.__index = rockspec_mt @@ -151,6 +160,27 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) end end + if rockspec.build + and rockspec.build.type + and not vendored_build_type_set[rockspec.build.type] then + local build_pkg_name = "luarocks-build-" .. rockspec.build.type + if not rockspec.build_dependencies then + rockspec.build_dependencies = {} + end + + local found = false + for _, dep in ipairs(rockspec.build_dependencies) do + if dep.name == build_pkg_name then + found = true + break + end + end + + if not found then + table.insert(rockspec.build_dependencies, queries.from_dep_string(build_pkg_name)) + end + end + if not quick then configure_paths(rockspec) end -- cgit v1.2.3-55-g6feb